vite 3.0 error Error [ERR_REQUIRE_ESM]: require()
gengjiawen opened this issue · 11 comments
Repro:
npx degit nvh95/vite-react-template-redux/typescript my-app --yarn
// bump vite to 3.0 in package.json
yarn dev
Error:
failed to load config from /Users/jiawengeng/code/monkey-rust/packages/playground/vite.config.ts
error when starting dev server:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/jiawengeng/code/monkey-rust/node_modules/.pnpm/vite-plugin-wasm@2.0.0_vite@3.0.2/node_modules/vite-plugin-wasm/dist/index.js from /Users/jiawengeng/code/monkey-rust/packages/playground/vite.config.ts not supported.
I am not using commonjs as far as I know. It's looks this error because vite loading this plugin.
Vite 3 is pure ESM. How did you imported Vite 3?
…
On Wed, Jul 20, 2022 at 16:41 Jiawen Geng @.> wrote: I am using commonjs as far as I know. It's looks this error because vite loading this plugin. — Reply to this email directly, view it on GitHub <#7 (comment)>, or unsubscribe <github.com/notifications/unsubscribe-auth/ACWRBAZOESTVFEN74IQSY4LVU63SBANCNFSM54CVMKBA> . You are receiving this because you commented.Message ID: @.>
the error comes from loading vite-plugin-wasm, if I remove the import, vite works.
I just the template to create a proj (npx degit nvh95/vite-react-template-redux/typescript my-app --yarn
).
https://codesandbox.io/s/vite-react-typescript-starter-forked-c6u43n?file=/vite.config.ts
codesandbox demo, if add the wasm plugin, the build will fail.
Sorry I'm wrong. Vite 3.0 is not pure ESM. I'll restore the CJS support of this plugin later.
Sorry I'm wrong. Vite 3.0 is not pure ESM. I'll restore the CJS support of this plugin later.
Thx. Another question, does this support wasm-pack build --release
? Without target web flags like wasm-pack build --release --target web
Please use wasm-pack build --target bundler
. The --target web
is NOT to be supported by this plugin.
Try the new version v2.1.0
.
@Menci Thx, works like a charm.