Original issue context: In a Svelte project I added a typescript file (which was not referenced in the project) to build.rollupOptions.input so it was processed and outputted as a separate file with the intent to dynamically import it.
This works when doing npm run build (vite build), but when doing npm run dev (vite) Rollup ends up trying to parse it as a javascript file.
This only occurs when the crx plugin is present.
Reproduction
To reproduce you only need an empty dir with these files in the root:
npm install
vite build # ok
vite # Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Comment out crx plugin in vite.config.js
Run:
vite build # ok
vite # ok
I should note that the same thing happens with vite@3.
I also tried overriding the build-related dependency versions of vite-plugin to be the latest ones, but that didn't lead to anything.
Logs
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
at error (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at Module.error (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:12429:16)
at Module.tryParse (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:12806:25)
at Module.setSource (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:12711:24)
at ModuleLoader.addModuleSource (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:22153:20) {
code: 'PARSE_ERROR',
parserError: SyntaxError: Unexpected token (1:12)
at pp$4.raise (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:19614:13)
at pp$9.unexpected (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:16908:8)
at pp$8.parseVar (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:17453:12)
at pp$8.parseVarStatement (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:17315:8)
at pp$8.parseStatement (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:17063:17)
at pp$8.parseTopLevel (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:16965:21)
at Parser.parse (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:16737:15)
at Function.parse (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:16787:35)
at Graph.contextParse (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:22921:38)
at Module.tryParse (file://<PROJECT_ROOT>/node_modules/rollup/dist/es/shared/rollup.js:12796:31) {
pos: 12,
loc: Position { line: 1, column: 12 },
raisedAt: 13
},
id: '<PROJECT_ROOT>/independent.ts',
pos: 12,
loc: {
column: 12,
file: '<PROJECT_ROOT>/independent.ts',
line: 1
},
frame: '1: const ts: string = "typed variable";\n' +
' ^\n' +
'2: console.log(ts);',
watchFiles: [
'/@crx/manifest',
'<PROJECT_ROOT>/independent.ts'
]
}
Build tool
Vite
Where do you see the problem?
Describe the bug
Original issue context: In a Svelte project I added a typescript file (which was not referenced in the project) to
build.rollupOptions.input
so it was processed and outputted as a separate file with the intent to dynamically import it.This works when doing
npm run build
(vite build
), but when doingnpm run dev
(vite
) Rollup ends up trying to parse it as a javascript file. This only occurs when thecrx
plugin is present.Reproduction
To reproduce you only need an empty dir with these files in the root:
independent.ts
package.json
vite.config.js
Run:
Comment out
crx
plugin invite.config.js
Run:
I should note that the same thing happens with
vite@3
. I also tried overriding the build-related dependency versions ofvite-plugin
to be the latest ones, but that didn't lead to anything.Logs
System Info
Severity
annoyance