Next 12.2 - Custom SWC plugin causes failures during build
See original GitHub issueVerify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
Binaries:
Node: 16.14.2
npm: 8.5.0
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.2.1-canary.4
eslint-config-next: 12.2.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 102.0.5005.115
How are you deploying your application? (if relevant)
next build fails
Describe the Bug
I am trying to test a simple plugin since next 12.2 landed support for experimental SWC plugins written in WASM.
To achieve this, I created a plugin sample here - https://github.com/AdarshKonchady/swc-console-replace-plugin Compiled that to WASM to use in a sample NextJS app. I’ve put the compiled WASM binary in that repo as well here
Testing this on a sample NextJS app though results in a build error. My real usecase for this is different from this of course but added the repo above for demonstration purposes.
Would appreciate any help in debugging this further. Thank you !
Expected Behavior
SWC plugin should work as expected
Link to reproduction
https://github.com/AdarshKonchady/swc-console-replace-plugin and https://github.com/AdarshKonchady/next-app-demo
To Reproduce
- Clone https://github.com/AdarshKonchady/swc-console-replace-plugin and https://github.com/AdarshKonchady/next-app-demo into the same folder
- Add local absolute path to https://github.com/AdarshKonchady/swc-console-replace-plugin/blob/master/target/wasm32-wasi/release/console_replace.wasm into the next-app next.config.js
experimental: {
swcPlugins: [
[
"<absolute_path>/console_replace.wasm",
],
],
},
- Run yarn build
- Notice the error:
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
There’s bit rough edges around composing plugin we’d like to improve.
For now, try to use
to match with
next-swc
’s transitive deps version.Also, config should be
This also need to be improved over.
Closing as per https://github.com/vercel/next.js/issues/38428#issuecomment-1178486302 for now. Given this is an experimental feature, some rough edges are expected as pointed out, but thanks for the feedback!