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

RollupError: Unexpected token .. Expected * for generator, private key, identifier or async #5412

Open
bluemoon opened this issue Mar 1, 2024 · 3 comments

Comments

@bluemoon
Copy link

bluemoon commented Mar 1, 2024

Rollup Version

4.9.6

Operating System (or Browser)

macOS

Node Version (if applicable)

No response

Link To Reproduction

N/A

Expected Behaviour

Upgraded to svelte 2.0 and somewhere along the lines it stopped working with this error. Expected behavior is to spit out some location of the code.

Actual Behaviour

web:build: > Using @sveltejs/adapter-node
web:build: error during build:
web:build: RollupError: Unexpected token `.`. Expected * for generator, private key, identifier or async
web:build:     at error (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:337:30)
web:build:     at parseError (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:972:9)
web:build:     at convertNode (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2057:12)
web:build:     at convertProgram (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:965:12)
web:build:     at parseAstAsync (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/parseAst.js:2108:12)
web:build:     at async Module.tryParseAsync (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:13539:20)
web:build:     at async Module.setSource (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:13120:35)
web:build:     at async ModuleLoader.addModuleSource (file:///Users/bradford/projects/aegis/node_modules/.pnpm/rollup@4.9.6/node_modules/rollup/dist/es/shared/node-entry.js:17810:13)
@bluemoon
Copy link
Author

bluemoon commented Mar 5, 2024

Ok, I spent an enormous amount of time tracking it down to this syntax:

import json from './foo.json' assert { type: 'json' };

@ersinakinci
Copy link

Ah man. I'm in it right now! What an annoying bug. How did you end up finding your issue @bluemoon? Trial and error or something else?

@lukastaegert
Copy link
Member

If it stops at a JSON import, this sounds like Svelte is not adding something like https://www.npmjs.com/package/@rollup/plugin-json to its setup. At the moment, there is still no native JSON support in Rollup even with assertions (though we should probably try to match what runtimes offer, but nobody set it up)

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

No branches or pull requests

4 participants