Build error with JSON file as asset on wagmiV2
dellwatson opened this issue · comments
Dale Watson commented
Describe the bug
So recently just upgraded my wagmi into v2, and I found this bug on vite react.
I tried all versions v2, and same issue. on local dev it will be fine, but encounter error on building the app
with this build config on vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// import react from "@vitejs/plugin-react-swc";
import path from "path";
// import glsl from "vite-plugin-glsl";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
// unocss(),
react(),
],
assetsInclude: [
"**/*.json",
"**/*.gltf",
"**/*.glb",
"**/*.jpeg",
"**/*.png",
"**/*.lottie",
"**/*.mp3",
"**/*.cube",
"**/*.hdr",
"**/*.glsl",
],
});
the build will get error
yarn build
yarn run v1.22.21
$ vite build
vite v4.5.3 building for production...
✓ 926 modules transformed.
✓ built in 2.22s
[commonjs] Failed to parse JSON file.
file: /Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/@safe-global/safe-apps-sdk/dist/src/sdk.js
error during build:
RollupError: Failed to parse JSON file.
at error (file:///Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
at Object.error (file:///Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/rollup/dist/es/shared/node-entry.js:25351:20)
at Object.error (file:///Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/rollup/dist/es/shared/node-entry.js:24472:42)
at Object.transform (file:///Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:40372:22)
at file:///Users/dellwatson/Downloads/new-wagmi-y6kxvw/node_modules/rollup/dist/es/shared/node-entry.js:25544:40
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
this make my vite-react app unable to use JSOn as file,
so either i remove the json options from that array or I use wagmi v1.
Link to Minimal Reproducible Example
https://github.com/dellwatson/wagmi-v2-bug
Steps To Reproduce
- clone
- install package
- add json file as asset
- build app -> encounter error
fix: downgrade to wagmi v1 or remove js from asset include
Wagmi Version
v2.*
Viem Version
v2.*
TypeScript Version
5.4.5
Check existing issues
- I checked there isn't already an issue for the bug I encountered.
Anything else?
No response