Skip to content

Instantly share code, notes, and snippets.

@mrkishi
Created January 24, 2018 18:36
Show Gist options
  • Save mrkishi/0accbb947df2b3a5b4968fb2c5baf0b4 to your computer and use it in GitHub Desktop.
Save mrkishi/0accbb947df2b3a5b4968fb2c5baf0b4 to your computer and use it in GitHub Desktop.
Rollup duplicate dynamic imports bug

node build

(node:7660) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
    at /repro/node_modules/rollup/dist/rollup.js:18666:69
    at Array.forEach (<anonymous>)
    at /repro/node_modules/rollup/dist/rollup.js:18654:45
    at Array.forEach (<anonymous>)
    at Chunk.setDynamicImportResolutions (/repro/node_modules/rollup/dist/rollup.js:18653:29)
    at /repro/node_modules/rollup/dist/rollup.js:18861:69
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:193:16)
(node:7660) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7660) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

node build codesplit

(node:8768) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'generateEntryExports' of undefined
    at /repro/node_modules/rollup/dist/rollup.js:19273:35
    at Array.forEach (<anonymous>)
    at /repro/node_modules/rollup/dist/rollup.js:19272:26
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
    at Function.Module.runMain (module.js:703:11)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:617:3
(node:8768) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:8768) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

node build external

OK

node build external codesplit

OK
const rollup = require('rollup')
const codesplit = process.argv.includes('codesplit')
const external = process.argv.includes('external')
const main = external ? 'main-external.js' : 'main.js'
if (codesplit) {
rollup.rollup({
input: [main],
experimentalDynamicImport: true,
experimentalCodeSplitting: true,
}).then((bundle) => {
bundle.write({
dir: 'build',
format: 'es',
})
})
} else {
rollup.rollup({
input: main,
experimentalDynamicImport: true,
}).then((bundle) => {
bundle.write({
file: 'build/main.js',
format: 'es',
})
})
}
export default 'dependency'
import('./external-dependency').then(console.log)
import('./external-dependency').then(console.log)
import('./dependency').then(console.log)
import('./dependency').then(console.log)
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"rollup": {
"version": "0.55.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.55.0.tgz",
"integrity": "sha512-uCwDXz2qHQ0XsPekrLIeIEORSF32Zfk1H057ENgb+sj84m10pWaG2YGQSvF8kvyf0WLcrzk2TzYuC/+iZP4hyA=="
}
}
}
{
"main": "main.js",
"scripts": {
"run": "node build"
},
"dependencies": {
"rollup": "^0.55.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment