Please only file bugs/feature requests for rollup-plugin-closure-compiler here.
Rollup provides an output option called preserveModules.
Instead of creating as few chunks as possible, this mode will create separate chunks for all modules using the original module names as file names.
Generating one big fat esm chunk is less effective than multiple small modules because of latter can benefit from sideEffects, while a single file can only rely on dead code elimination for unused export.
Is your feature request related to a problem? Please describe.
However, when I add this flag when aggregating exports like this happens,
test/aggregating-export/fixtures/re-export.js
export * as dep from './foo-dep'
export * as dep1 from './bar-dep'
the below error occurs:
✖ aggregating-export › re-export › re-export works correctly with Promise returned by test never resolved
Unhandled rejection in test/aggregating-export/re-export.test.js
/workspaces/rollup-plugin-closure-compiler/node_modules/acorn/dist/acorn.js:2927
SyntaxError: Export 'fooDep' is not defined (1:7)
Parser.pp$4.raise (node_modules/acorn/dist/acorn.js:2927:15)
Parser.pp$1.parseTopLevel (node_modules/acorn/dist/acorn.js:763:16)
Parser.parse (node_modules/acorn/dist/acorn.js:555:17)
Function.parse (node_modules/acorn/dist/acorn.js:578:37)
Object.parse (node_modules/acorn/dist/acorn.js:5095:19)
Object.parse (src/acorn.ts:52:19)
ImportTransform.post (src/transformers/chunk/imports.ts:159:27)
Object.chunkLifecycle (src/transform.ts:92:50)
processTicksAndRejections (node:internal/process/task_queues:95:5)
Object.postCompilation (src/transformers/chunk/transforms.ts:100:10)
I add a mini repo to reproduce this problem
test/aggregating-export/re-export.test.js
import * as fooDep from './foo-dep.js';
export { fooDep as dep };
import * as barDep from './bar-dep.js';
export { barDep as dep1 };
In the posting closure compiler phrase,ExportTransform which adds the exports back first
generates something like
export{fooDep as dep,barDep as dep1}
which lacks the form keyword
Describe alternatives you've considered
Change the transform order to add back import first.
But I can't find a way to do it elegantly.
Additional context
The Rollup version must be close to 2.28.1, the higher version produces more problems due to the tests being quite fragile.
Simple string comparison highly relies on rollup's implementation for output.
However, the package.json file states that all versions above 1.27 are compatible.
Please only file bugs/feature requests for rollup-plugin-closure-compiler here. Rollup provides an output option called preserveModules.
Generating one big fat esm chunk is less effective than multiple small modules because of latter can benefit from sideEffects, while a single file can only rely on dead code elimination for unused export.
Is your feature request related to a problem? Please describe.
However, when I add this flag when aggregating exports like this happens, test/aggregating-export/fixtures/re-export.js
the below error occurs:
I add a mini repo to reproduce this problem test/aggregating-export/re-export.test.js
test/aggregating-export/fixtures/foo-dep.js test/aggregating-export/fixtures/bar-dep.js
Describe the solution you'd like
Turns out that the order of chunk transformers causes this issue.
rollup transpiles the above code into:
In the posting closure compiler phrase,
ExportTransform
which adds the exports back first generates something likewhich lacks the
form
keywordDescribe alternatives you've considered
Change the transform order to add back import first. But I can't find a way to do it elegantly.
Additional context
The Rollup version must be close to 2.28.1, the higher version produces more problems due to the tests being quite fragile. Simple string comparison highly relies on rollup's implementation for output. However, the package.json file states that all versions above 1.27 are compatible.