- Click "Download zip" and extract to a folder
cd
into the extracted foldernpm install
npm start
The custom plugin in rollup.config.js
will show an undefined
value in the bundle
argument passed to the generateBundle
hook.
export default false | |
? import('./b.js') | |
: null; |
export default "b"; |
./a.js → ./dist...
{ entry: 'a.js', dynamicImports: [ undefined ] }
created ./dist in 21ms
./a.js → ./dist...
{ entry: 'a.js', dynamicImports: [ ] }
created ./dist in 20ms
./a.js → ./dist...
-{ entry: 'a.js', dynamicImports: [ ] }
+{ entry: 'a.js', dynamicImports: [ undefined ] }
created ./dist in 21ms
{ | |
"name": "rollup-code-splitting-treeshaking-bug", | |
"version": "1.0.0", | |
"description": "Repro for a rollup bug", | |
"scripts": { | |
"start": "rollup --config" | |
}, | |
"license": "MIT", | |
"devDependencies": { | |
"rollup": "^1.1.0" | |
} | |
} |
module.exports = { | |
input : [ | |
"./a.js", | |
], | |
output : { | |
dir : "./dist", | |
format : "esm", | |
}, | |
plugins : [ | |
{ | |
name : "rollup-code-splitting-treeshaking-bug", | |
generateBundle(options, bundle) { | |
Object.entries(bundle).forEach(([ entry, { dynamicImports }]) => { | |
console.log({ entry, dynamicImports }); | |
}); | |
}, | |
}, | |
], | |
}; |