Skip to content

Commit

Permalink
fix(rollup): unmark chunk names as external imports
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 10, 2022
1 parent 850b013 commit 59debad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/builder/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export async function rollupBuild (ctx: BuildContext) {
const allOutputOptions = rollupOptions.output! as OutputOptions[]
for (const outputOptions of allOutputOptions) {
const { output } = await buildResult.write(outputOptions)
const chunkFileNames = new Set<string>()
for (const entry of output.filter(e => e.type === 'chunk') as OutputChunk[]) {
chunkFileNames.add(entry.fileName)
for (const id of entry.imports) {
ctx.usedImports.add(id)
}
Expand All @@ -101,6 +103,9 @@ export async function rollupBuild (ctx: BuildContext) {
})
}
}
for (const chunkFileName of chunkFileNames) {
ctx.usedImports.delete(chunkFileName)
}
}

// Types
Expand Down Expand Up @@ -135,7 +140,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
ctx.options.rollup.emitCJS && {
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
entryFileNames: '[name].cjs',
chunkFileNames: `chunks/${ctx.options.name}.[hash].cjs`,
chunkFileNames: `${ctx.options.name}.[hash].cjs`,
format: 'cjs',
exports: 'auto',
preferConst: true,
Expand All @@ -145,7 +150,7 @@ export function getRollupOptions (ctx: BuildContext): RollupOptions {
{
dir: resolve(ctx.options.rootDir, ctx.options.outDir),
entryFileNames: '[name].mjs',
chunkFileNames: `chunks/${ctx.options.name}.[hash].mjs`,
chunkFileNames: `${ctx.options.name}.[hash].mjs`,
format: 'esm',
exports: 'auto',
preferConst: true,
Expand Down

0 comments on commit 59debad

Please sign in to comment.