/ vite Public
Error in dev mode only (works in prod) with json import #4897
Bug in a dependency of Vite
Extra attention is needed
Inconsistency between dev & build
An edge case that only affects very specific usage (priority)
Describe the bug
Hello, I am part of the UI5 Web Components team (https://sap.github.io/ui5-webcomponents/) and we're recommending
vitejsas the to-go bundler for people looking to start using our web components. However, one of our demo apps fails in dev mode when we try to demonstrate the usage of our
.json-based assets (in this case CLDR data).
After importing a
.jsonfile I get the following error:
[plugin:vite:import-analysis] Failed to parse source for import analysis because the content contains invalid JS syntax. If you are using JSX, make sure to name the file with the .jsx or .tsx extension.
This works perfectly fine in prod mode (
npm run build), and only occurs for
npm run dev.
Create an empty project with the vanilla template:
npm init vite@latest my-test-app -- --template vanilla
@ui5/webcomponentsas a dependency
npm i @ui5/webcomponents
Import the following 2 modules in the
index.htmlfile, right after the body tag:
npm run dev
You will get the "Invalid JS syntax" error.
Now run the project in prod mode
npm run build
npm run serve
This works well and you can see the date picker on your page.
Used Package Manager
The text was updated successfully, but these errors were encountered: