question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next 12.2 - Custom SWC plugin causes failures during build

See original GitHub issue

Verify 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

experimental: {
    swcPlugins: [
      [
        "<absolute_path>/console_replace.wasm",
      ],
    ],
  },
  • Run yarn build
  • Notice the error:
image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
kwonojcommented, Jul 8, 2022

There’s bit rough edges around composing plugin we’d like to improve.

For now, try to use

swc_plugin = "0.59.0"
swc_common = "0.18.9"

to match with next-swc’s transitive deps version.

Also, config should be

[
 [${plugin_path/name}, {} /* empty object if there's no config options */ ]
]

This also need to be improved over.

1reaction
balazsorban44commented, Jul 8, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next failed to load SWC binary
I've tried uninstalling node and reinstalling it again with version 16.13 but without success, on the vercel page, but unsuccessful so far. Any ......
Read more >
Upgrade Guide
When an application has a custom Babel configuration, Next.js will automatically opt-out of using SWC for compiling JavaScript/Typescript and will fall back ...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/24 17 ...
... and LDFLAGS used during build" status:UNCONFIRMED resolution: severity:normal ... causes segmentation faults running x11-wm/openbox in _ft_bitmap_bc (in ...
Read more >
Internal error 500 when deploying next.js with SSR
hi, i want to deploy my next.js site on netlify but get this error 'internal ... cached build plugins 12:26:40 PM: Finished restoring...
Read more >
cannot find module 'next/babel' - parsing error
babelrc in your root directory and add this code: { "presets": ["next/babel"], "plugins": [] }. And in .eslintrc , replace the existing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found