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

TypeError: Cannot read properties of undefined (reading 'indexOf') #5084

Closed
janosh opened this issue Aug 3, 2023 · 6 comments · Fixed by #5087
Closed

TypeError: Cannot read properties of undefined (reading 'indexOf') #5084

janosh opened this issue Aug 3, 2023 · 6 comments · Fixed by #5087

Comments

@janosh
Copy link

janosh commented Aug 3, 2023

Rollup Version

3.27.1

Operating System (or Browser)

macOS

Node Version (if applicable)

No response

Link To Reproduction

https://stackblitz.com/edit/rollup-repro-ughg9c?file=package.json

Expected Behaviour

npm run build succeeds.

Actual Behaviour

Lazy computing decoded mappings in #5075 seems to cause undefined mappings at vite build time in SvelteKit.

https://github.com/janosh/elementari/actions/runs/5754572660/job/15600143441#step:6:18

vite v4.4.8 building SSR bundle for production...
transforming...
✓ 5 modules transformed.
✓ built in 556ms
Cannot read properties of undefined (reading 'indexOf')
error during build:
TypeError: Cannot read properties of undefined (reading 'indexOf')
    at indexOf (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:91:26)
    at decode (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:54:22)
    at get mappings [as mappings] (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:13281:37)
    at decodedSourcemap (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:13254:13)
    at file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:13997:104
    at Array.map (<anonymous>)
    at Module.setSource (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:13997:46)
    at ModuleLoader.addModuleSource (file:///home/runner/work/elementari/elementari/node_modules/rollup/dist/es/shared/node-entry.js:24523:[20](https://github.com/janosh/elementari/actions/runs/5754572660/job/15600143441#step:6:21))
@lukastaegert
Copy link
Member

Unfortunately your npm run build does not run for me in your reproduction. There are several images missing, and when I remove the references I get other errors. Could have a look? In any case, that sounds rather serious, so I will try to re-release the previous version for now.
cc @thebanjomatic, maybe you have an idea how to handle this?

@thebanjomatic
Copy link
Contributor

I'll take a look at this today.

@thebanjomatic
Copy link
Contributor

This is failing because of unexpected input. One of the plugins is returning {mappings: null} and the types are expecting {mappings: ''} to signal the empty sourcemap. I have a PR that should be ready soon that loosens the types for the decodedSourcemap function to cover mappings; null | undefined, and a few other small changes to ensure that we are then handling those cases correctly.

@thebanjomatic
Copy link
Contributor

thebanjomatic commented Aug 4, 2023

@lukastaegert A fix for the above issue is in the second commit of the linked PR: #5087

@thebanjomatic
Copy link
Contributor

thebanjomatic commented Aug 4, 2023

FYI I also had issues with the stackblitz reproducer, but I was able to reproduce by pulling down https://github.com/janosh/elementari and setting a resolution to rollup 3.27.1. Then I tested the fix there by linking in my built branch.

It looks like this particular problem is stemming from this plugin returning mappings: null:
https://github.com/mattjennings/mdsvexamples/blob/eae8ffbf808f59aeec91a00a4df278eb410f6d6f/src/lib/plugin.js#L134C13-L136

@rollup-bot
Copy link
Collaborator

This issue has been resolved via #5087 as part of rollup@3.28.0. 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.

4 participants