Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inlineDynamicImports: true and moduleSideEffects: 'no-treeshake' causes a hard-to-diagnose error #4098

Closed
lemonmade opened this issue May 26, 2021 · 2 comments · Fixed by #4104

Comments

@lemonmade
Copy link

lemonmade commented May 26, 2021

Expected Behavior

I can set inlineDynamicImports: true, and resolve a module with moduleSideEffects: 'no-treeshake', and have the build complete without an error (in the example, removing moduleSideEffects or inlineDynamicImports both work, and neither changes the output, but my real project requires both to be enabled).

Actual Behavior

The following error is thrown:

[!] TypeError: Cannot read property 'suggestedVariableName' of undefined
TypeError: Cannot read property 'suggestedVariableName' of undefined
    at Object.deconflictImportsOther (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:11071:80)
    at deconflictChunk (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:11038:52)
    at Chunk.setIdentifierRenderResolutions (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:12323:9)
    at Chunk.preRender (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:11707:14)
    at Bundle.prerenderChunks (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:13027:19)
    at Bundle.generate (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:12892:18)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async handleGenerateWrite (/home/runner/rollup-repro/node_modules/rollup/dist/shared/rollup.js:20623:23)
    at async Promise.all (index 0)
    at async build (/home/runner/rollup-repro/node_modules/rollup/dist/bin/rollup:1533:5)

I tracked this down a little bit, and noticed that we add the offending undefineds in

const dependencyChunk = chunkByModule.get(dependency)!;
if (dependencyChunk !== chunk) {
staticDependencies.push(dependencyChunk);
continue;
}
. Interestingly, the module that gets added here (e.g., has chunkByModule.get(dependency) == null) was always an index file that just re-exports other parts of the module being imported (I used a library from my real example, @remote-ui/core, but it was not specific to this library in my larger example).

Thanks in advance for your help, and for the amazing work on Rollup!

@lukastaegert
Copy link
Member

Thanks for spotting, fix at #4104

@lemonmade
Copy link
Author

@lukastaegert Thank you so much for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants