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

Cannot read properties of undefined (reading 'type') error happens when manualChunks is used #4908

Closed
sapphi-red opened this issue Mar 17, 2023 · 5 comments · Fixed by #4921
Assignees

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Mar 17, 2023

Rollup Version

3.19.1 (from 3.13.0, 3.12.1 is fine)

Operating System (or Browser)

stackblitz

Node Version (if applicable)

No response

Link To Reproduction

https://stackblitz.com/edit/rollup-repro-8wae7q?file=rollup.config.js

Expected Behaviour

No error happens.

Actual Behaviour

The following error happens when building:

❯ npm run build
$ rollup -c rollup.config.js

src/main.js → dist...
[!] TypeError: Cannot read properties of undefined (reading 'type')
    at FunctionExpression.deoptimizeArgumentsOnInteractionAtPath (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:9075:25)
    at FunctionExpression.deoptimizeArgumentsOnInteractionAtPath (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:9471:15)
    at CallExpression.applyDeoptimizations (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:10192:21)
    at CallExpression.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:10158:22)
    at ExpressionStatement.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:6268:28)
    at Program.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:12133:22)
    at Program.hasCachedEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:12128:44)
    at Module.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:14019:75)
    at addSideEffectDependencies (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:14359:72)
    at Module.addRelevantSideEffectDependencies (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:14366:9)

rollup 3.13.0 throws a different error:

[!] TypeError: Cannot read properties of undefined (reading 'thisArg')
    at CallExpression.applyDeoptimizations (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:10025:30)
    at CallExpression.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:9991:22)
    at ExpressionStatement.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:6252:28)
    at Program.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:11949:22)
    at Program.hasCachedEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:11944:44)
    at Module.hasEffects (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:13845:75)
    at addSideEffectDependencies (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:14185:72)
    at Module.addRelevantSideEffectDependencies (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:14192:9)
    at Module.getDependenciesToBeIncluded (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:13706:18)
    at addStaticDependencies (file:///home/projects/rollup-repro-8wae7q/node_modules/rollup/dist/shared/rollup.js:15413:33)

Original issue: vitejs/vite#12448

@timdang
Copy link

timdang commented Mar 22, 2023

For us, migrating from Vite 4.1.4 to 4.2.1 bumped our Rollup dependency to 3.20.0 and we're now experiencing this issue as well.

@TrickyPi
Copy link
Member

TrickyPi commented Mar 23, 2023

It seems that the package in manualChunks config of Rollup@latest must included in module graph.

@TrickyPi
Copy link
Member

The earliest version of Rollup with this bug is 3.13.0.

@lukastaegert
Copy link
Member

The earliest version of Rollup with this bug is 3.13.0

Thanks @TrickyPi, that was extremely helpful! It turns out, 3.13.0 only contained one seemingly unrelated feature. But in implementing the feature I accidentally removed a conditional that was important to handle the case where the entry of a manual chunk is not part of the module graph. Fix at #4921

@rollup-bot
Copy link
Collaborator

This issue has been resolved via #4921 as part of rollup@3.20.2. You can test it via npm install rollup.

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.

5 participants