RollupError: Unexpected token `.`. Expected * for generator, private key, identifier or async
bluemoon opened this issue · 4 comments
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)
Ok, I spent an enormous amount of time tracking it down to this syntax:
import json from './foo.json' assert { type: 'json' };
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?
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)