-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
[plugin:vite:esbuild] Transform failed - Importing JSON files with { type: "json" }; #385
Comments
It looks like babel transform breaks import attributes. I added I'm not sure if silently stripping UPDATE: reported upstream babel/babel#16975 |
I missed the warning on first look, but it's there indicating that
To preserve export default defineConfig({
plugins: [
react({
babel: {
generatorOpts: {
importAttributesKeyword: 'with',
},
},
}),
],
}); This might not be totally intuitive, but it looks clear enough for users to take actions, so I think we can close this. |
We could add the default in the plugin, this current behavior is not great and they should have break people that were using unspec features instead |
Oh right, default generator option would be a one liner without dependency, so that makes sense. I think we can simply add it here? vite-plugin-react/packages/plugin-react/src/index.ts Lines 250 to 253 in 063fa5e
|
Yep! |
Describe the bug
Reproduction here: https://stackblitz.com/edit/vitejs-vite-no1xpg?file=src%2FApp.tsx
I am trying to import
json
files, with code like so:But running it with
vite
causes it to crash with this error:Strange enough, in the stacktrace, it shows line 3 and 4 with missing braces like so:
import enUs from "../locales/en-US.json" with type: "json";
even though the actual code has braces like so:{ with type: "json" }
.Using
npm:vite@^5.4.11
npm:react@^18.3.1
npm:@vitejs/plugin-react@^4.3.3
npm:@deno/vite-plugin@^1.0.0
Reproduction
https://stackblitz.com/edit/vitejs-vite-no1xpg?file=src%2FApp.tsx
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: