-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Enable Wasm plugins #37063
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
Enable Wasm plugins #37063
Conversation
Since features are additive it's not technically necessary to do it for every usage, but it seems more correct to keep them all the same. This causes an issue with js-sys since it's locked to 0.3.49 but wasmer requires ^0.3.51.
This gets rid of the js-sys issue but introduces language features that can't be used with the overridden toolchain nightly-2022-02-23.
This allows for compilation, now we're running into the issue that wasmer-vfs requires either host-fs or mem-fs feature to be enabled.
This fixes our features issue but should be properly solved in swc.
Failing test suitesCommit: 7056b9b
Expand output● CLI Usage › info › should print output Read more about building and testing Next.js in contributing.md.
Expand output● ReactRefreshLogBox › logbox: can recover from a syntax error without losing state Read more about building and testing Next.js in contributing.md. |
Stats from current PRDefault Build (Increase detected
|
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| buildDuration | 16.1s | 16s | -108ms |
| buildDurationCached | 6.1s | 6.3s | |
| nodeModulesSize | 595 MB | 595 MB |
Page Load Tests Overall increase ✓
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| / failed reqs | 0 | 0 | ✓ |
| / total time (seconds) | 3.878 | 3.803 | -0.08 |
| / avg req/sec | 644.69 | 657.38 | +12.69 |
| /error-in-render failed reqs | 0 | 0 | ✓ |
| /error-in-render total time (seconds) | 1.368 | 1.37 | 0 |
| /error-in-render avg req/sec | 1827.45 | 1825.04 |
Client Bundles (main, webpack)
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| 925.HASH.js gzip | 179 B | 179 B | ✓ |
| framework-HASH.js gzip | 42 kB | 42 kB | ✓ |
| main-HASH.js gzip | 29 kB | 29 kB | ✓ |
| webpack-HASH.js gzip | 1.44 kB | 1.44 kB | ✓ |
| Overall change | 72.6 kB | 72.6 kB | ✓ |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
| Overall change | 31 kB | 31 kB | ✓ |
Client Pages
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| _app-HASH.js gzip | 1.36 kB | 1.36 kB | ✓ |
| _error-HASH.js gzip | 193 B | 193 B | ✓ |
| amp-HASH.js gzip | 308 B | 308 B | ✓ |
| css-HASH.js gzip | 327 B | 327 B | ✓ |
| dynamic-HASH.js gzip | 2.71 kB | 2.71 kB | ✓ |
| head-HASH.js gzip | 359 B | 359 B | ✓ |
| hooks-HASH.js gzip | 920 B | 920 B | ✓ |
| image-HASH.js gzip | 5.73 kB | 5.73 kB | ✓ |
| index-HASH.js gzip | 263 B | 263 B | ✓ |
| link-HASH.js gzip | 2.65 kB | 2.65 kB | ✓ |
| routerDirect..HASH.js gzip | 320 B | 320 B | ✓ |
| script-HASH.js gzip | 391 B | 391 B | ✓ |
| withRouter-HASH.js gzip | 318 B | 318 B | ✓ |
| 85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
| Overall change | 16 kB | 16 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 458 B | 458 B | ✓ |
| Overall change | 458 B | 458 B | ✓ |
Rendered Page Sizes
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| index.html gzip | 533 B | 533 B | ✓ |
| link.html gzip | 547 B | 547 B | ✓ |
| withRouter.html gzip | 528 B | 528 B | ✓ |
| Overall change | 1.61 kB | 1.61 kB | ✓ |
Default Build with SWC (Increase detected ⚠️ )
General Overall increase ⚠️
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| buildDuration | 17.8s | 18.5s | |
| buildDurationCached | 6.1s | 6.4s | |
| nodeModulesSize | 595 MB | 595 MB |
Page Load Tests Overall increase ✓
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| / failed reqs | 0 | 0 | ✓ |
| / total time (seconds) | 3.784 | 3.863 | |
| / avg req/sec | 660.66 | 647.23 | |
| /error-in-render failed reqs | 0 | 0 | ✓ |
| /error-in-render total time (seconds) | 1.332 | 1.302 | -0.03 |
| /error-in-render avg req/sec | 1876.18 | 1920.65 | +44.47 |
Client Bundles (main, webpack)
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| 925.HASH.js gzip | 178 B | 178 B | ✓ |
| framework-HASH.js gzip | 42.7 kB | 42.7 kB | ✓ |
| main-HASH.js gzip | 29.5 kB | 29.5 kB | ✓ |
| webpack-HASH.js gzip | 1.45 kB | 1.45 kB | ✓ |
| Overall change | 73.8 kB | 73.8 kB | ✓ |
Legacy Client Bundles (polyfills)
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
| Overall change | 31 kB | 31 kB | ✓ |
Client Pages
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| _app-HASH.js gzip | 1.35 kB | 1.35 kB | ✓ |
| _error-HASH.js gzip | 179 B | 179 B | ✓ |
| amp-HASH.js gzip | 311 B | 311 B | ✓ |
| css-HASH.js gzip | 324 B | 324 B | ✓ |
| dynamic-HASH.js gzip | 2.89 kB | 2.89 kB | ✓ |
| head-HASH.js gzip | 357 B | 357 B | ✓ |
| hooks-HASH.js gzip | 920 B | 920 B | ✓ |
| image-HASH.js gzip | 5.82 kB | 5.82 kB | ✓ |
| index-HASH.js gzip | 261 B | 261 B | ✓ |
| link-HASH.js gzip | 2.78 kB | 2.78 kB | ✓ |
| routerDirect..HASH.js gzip | 322 B | 322 B | ✓ |
| script-HASH.js gzip | 392 B | 392 B | ✓ |
| withRouter-HASH.js gzip | 317 B | 317 B | ✓ |
| 85e02e95b279..7e3.css gzip | 107 B | 107 B | ✓ |
| Overall change | 16.3 kB | 16.3 kB | ✓ |
Client Build Manifests
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| _buildManifest.js gzip | 457 B | 457 B | ✓ |
| Overall change | 457 B | 457 B | ✓ |
Rendered Page Sizes
| vercel/next.js canary | martindisch/next.js wasm-plugins | Change | |
|---|---|---|---|
| index.html gzip | 531 B | 531 B | ✓ |
| link.html gzip | 546 B | 546 B | ✓ |
| withRouter.html gzip | 527 B | 527 B | ✓ |
| Overall change | 1.6 kB | 1.6 kB | ✓ |
|
Duplicate #36790 |
|
Great to see you've started working on it, thanks! We're looking forward to improving our buildtimes. If you need any help or would like someone to test it, let us know. We've already built two plugins we want to try out. |
|
The other one also seems up to date with canary, so I don't think it matters much. Bundling together the additional optional dependencies/feature activations in a new feature seems like a good idea too, so I think if we have any suggestions we can easily add them there. |
Many people would love to take advantage of SWC and have even begun porting some Babel plugins to WebAssembly in order to use it in their projects. This PR enables SWC's experimental plugin system so it can be used in Next.js.
Thanks @kdy1 for the support.
Usage
In
next.config.jsadd the list of plugins (in this case loaded from a package) with their options.Feature
fixes #numbercontributing.mdfixes #34384 #30212