( context: RollupContext, inputs: string[], res: Map<string, RollupResolution>, cwd: string )
| 2593 | // the bundle's entries as modules, reading a page's module scripts as Vite |
| 2594 | // builds them, or why one can't be scanned |
| 2595 | const rollupEntriesOf = async ( |
| 2596 | context: RollupContext, |
| 2597 | inputs: string[], |
| 2598 | res: Map<string, RollupResolution>, |
| 2599 | cwd: string |
| 2600 | ): Promise<ScanEntry[] | string> => { |
| 2601 | const entries: ScanEntry[] = [] |
| 2602 | for (const input of inputs) { |
| 2603 | const resolved = await context.resolve(input, undefined, { isEntry: true }) |
| 2604 | if (!resolved || resolved.external) |
| 2605 | return `the entry "${input}" doesn't resolve to a module` |
| 2606 | res.set(resolved.id, resolved) |
| 2607 | if (!htmlId.test(resolved.id)) { |
| 2608 | entries.push({ id: resolved.id }) |
| 2609 | continue |
| 2610 | } |
| 2611 | const source = scriptsOf(readFileSync(resolved.id, "utf8")) |
| 2612 | if (source === undefined) |
| 2613 | return `${printablePathOf(cwd, resolved.id)} holds an inline module script, which it can't read before the build writes it as a module` |
| 2614 | entries.push({ id: resolved.id, source }) |
| 2615 | } |
| 2616 | return entries |
| 2617 | } |
| 2618 | |
| 2619 | const htmlId = /\.html$/ |
| 2620 |
no test coverage detected