Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next 12.2 - Custom SWC plugin causes failures during build #38428

Closed
1 task done
AdarshKonchady opened this issue Jul 7, 2022 · 5 comments
Closed
1 task done

Next 12.2 - Custom SWC plugin causes failures during build #38428

AdarshKonchady opened this issue Jul 7, 2022 · 5 comments
Labels
bug Issue was opened via the bug report template.

Comments

@AdarshKonchady
Copy link
Contributor

AdarshKonchady commented Jul 7, 2022

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

@AdarshKonchady AdarshKonchady added the bug Issue was opened via the bug report template. label Jul 7, 2022
@AdarshKonchady AdarshKonchady changed the title Next 12.2 SWC plugin causes memory issues during build Next 12.2 SWC plugin causes failures during build Jul 7, 2022
@AdarshKonchady AdarshKonchady changed the title Next 12.2 SWC plugin causes failures during build Next 12.2 - Custom SWC plugin causes failures during build Jul 7, 2022
@kwonoj
Copy link
Contributor

kwonoj commented 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.

@AdarshKonchady
Copy link
Contributor Author

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.

@kwonoj
That worked 🎉 Thank you !

You mentioned those versions and

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

Could you clarify where I should be checking next-swc's version in future since I don't see that dependency in my next-app-demo's yarn.lock file, nor do I see it in Cargo.toml on the plugin.

@kwonoj
Copy link
Contributor

kwonoj commented Jul 8, 2022

It's statically compiled into next-swc already, so you can't find it in cargo's lockfile and have to check next-swc's repo itself. In short, there isn't good story for this yet.

swc-project/swc#5149 is filed to track these ergonomics.

@balazsorban44
Copy link
Member

Closing as per #38428 (comment) for now. Given this is an experimental feature, some rough edges are expected as pointed out, but thanks for the feedback!

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants