When importing a .json file, it's required from node 18, 20 to add import assertions/attributes through the use of assert keyword, and from node 21 the with is introduced as well.
I'm using node 18/20, and I have a .json document that I'm trying to import, but I get warnings at dev and build time.
I hit this in solid-start but found I can repro it just with vinxi.
➜ pnpm run dev
> solid-ssr-basic@ dev /Users/admin/repos/vinxi/examples/solid/ssr/basic
> vinxi dev
vinxi v0.3.10
vinxi starting dev server
(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling.
➜ Local: http://localhost:3000/
➜ Network: use --host to expose
12:03:04 PM [vite] Pre-transform error: /Users/admin/repos/vinxi/examples/solid/ssr/basic/app/app.tsx: Support for the experimental syntax 'importAttributes' isn't currently enabled (4:32):
2 | import Logo from "./logo.png";
3 | import "./style.css";
> 4 | import data from "./data.json" assert { "type" : "json"};
| ^
5 |
6 | export default function App({ assets, scripts }) {
7 | return (
Add @babel/plugin-syntax-import-attributes (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-import-attributes) to the 'plugins' section of your Babel config to enable parsing.
12:03:04 PM [vite] Error when evaluating SSR module /app/server.tsx: failed to import "/app/app.tsx"
|- SyntaxError: /Users/admin/repos/vinxi/examples/solid/ssr/basic/app/app.tsx: Support for the experimental syntax 'importAttributes' isn't currently enabled (4:32):
I've attempted to install @babel/plugin-syntax-import-attributes through vite-plugin-babel, and .babelrc files to no avail
When importing a .json file, it's required from node 18, 20 to add import assertions/attributes through the use of assert keyword, and from node 21 the with is introduced as well.
I'm using node 18/20, and I have a .json document that I'm trying to import, but I get warnings at dev and build time.
I hit this in solid-start but found I can repro it just with vinxi.
Reproduce 🕹
Stackblitz: https://stackblitz.com/edit/github-ctndfc?file=app%2Fapp.tsx
examples/solid/ssr/basic/app
with content:{ "test": 3}
import data from "./data.json" assert { "type" : "json"};
<p>${JSON.stringify(data)}</p>
Error:
I've attempted to install @babel/plugin-syntax-import-attributes through vite-plugin-babel, and .babelrc files to no avail