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

feat(ecmascript-plugins): support swc ecmatransform plugins #5050

Merged
merged 7 commits into from
May 26, 2023

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented May 22, 2023

Description

Part 1 for WEB-998.

This PR implements a new turbopack-ecmascript plugin for the swc's ecmatransform plugin. New transform SwcEcmaTransformPluginsTransformer accepts array of plugin module contains CompiledPluginModuleBytes from swc's wasm plugin then executes it. It doesn't utilize SWC's internal cache mechanism to keep compiled / serialized wasm module (wasmer::Module), instead expect turbopack manages it. For those reason, we only accepts CompiledPluginModuleBytes from swc as it is a serialized copy does not requires re-compilation, while swc have few other different representation to the module bytes.

It is exposed as a separate feature instead of being default: there are some of platforms / targets we can't support plugins yet, and making it default will makes next-swc to fail to build.

@vercel
Copy link

vercel bot commented May 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-designsystem-docs 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 26, 2023 6:08pm
examples-kitchensink-blog 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 26, 2023 6:08pm
examples-nonmonorepo 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 26, 2023 6:08pm
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2023 6:08pm
7 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview May 26, 2023 6:08pm

@github-actions
Copy link
Contributor

✅ This change can build next-swc

@github-actions
Copy link
Contributor

github-actions bot commented May 22, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@kwonoj
Copy link
Contributor Author

kwonoj commented May 22, 2023

Looks like some of test snapshots failing with sourcemap differences, may comes with swc_core updates.

@github-actions
Copy link
Contributor

Linux Benchmark for 778ffcb

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8662.61µs ± 65.91µs 8569.20µs ± 63.13µs -1.08%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7767.59µs ± 30.44µs 7988.40µs ± 266.32µs +2.84%
bench_startup/Turbopack CSR/1000 modules 897.37ms ± 3.11ms 891.97ms ± 3.50ms -0.60%

@kdy1
Copy link
Member

kdy1 commented May 22, 2023

CI failure is not caused by swc_core update. See #5049
It does not have any failure.

@kwonoj
Copy link
Contributor Author

kwonoj commented May 22, 2023

@kdy1 hmm, any idea sourcemap would make differences then? The changes in this PR is not even enabled since it is behind compile time flag, also it doesn't affect normal transform's sourcemap.

@github-actions
Copy link
Contributor

MacOS Benchmark for 778ffcb

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 9686.23ms ± 2268.24ms 2831.78ms ± 59.73ms -70.76% -42.69%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 26.69ms ± 0.22ms 26.19ms ± 0.11ms -1.86%
bench_hmr_to_eval/Turbopack CSR/1000 modules 24.42ms ± 0.78ms 23.59ms ± 0.83ms -3.42%
bench_startup/Turbopack CSR/1000 modules 9686.23ms ± 2268.24ms 2831.78ms ± 59.73ms -70.76% -42.69%

@github-actions
Copy link
Contributor

Linux Benchmark for da9d54d

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 961.82ms ± 21.08ms 898.35ms ± 4.09ms -6.60% -1.43%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9180.49µs ± 44.69µs 9327.54µs ± 52.82µs +1.60%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8755.64µs ± 120.08µs 8616.06µs ± 279.79µs -1.59%
bench_startup/Turbopack CSR/1000 modules 961.82ms ± 21.08ms 898.35ms ± 4.09ms -6.60% -1.43%

@github-actions
Copy link
Contributor

MacOS Benchmark for da9d54d

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 9410.15ms ± 2219.73ms 2609.88ms ± 55.52ms -72.27% -45.26%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 26.98ms ± 0.24ms 26.98ms ± 0.28ms +0.01%
bench_hmr_to_eval/Turbopack CSR/1000 modules 26.99ms ± 1.64ms 24.33ms ± 0.17ms -9.87%
bench_startup/Turbopack CSR/1000 modules 9410.15ms ± 2219.73ms 2609.88ms ± 55.52ms -72.27% -45.26%

@github-actions
Copy link
Contributor

Linux Benchmark for 9a59d6a

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9476.31µs ± 53.64µs 9522.47µs ± 124.08µs +0.49%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8605.68µs ± 51.45µs 8596.97µs ± 36.15µs -0.10%
bench_startup/Turbopack CSR/1000 modules 931.46ms ± 6.17ms 926.01ms ± 8.60ms -0.59%

@kwonoj kwonoj force-pushed the feat-swc-turbopack-plugins branch from 637c6c7 to 31454cb Compare May 23, 2023 05:59
@github-actions
Copy link
Contributor

Linux Benchmark for fcac6b7

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9194.61µs ± 36.57µs 9242.03µs ± 82.91µs +0.52%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8299.65µs ± 41.15µs 8367.76µs ± 296.96µs +0.82%
bench_startup/Turbopack CSR/1000 modules 928.79ms ± 1.53ms 916.40ms ± 5.44ms -1.33%

@github-actions
Copy link
Contributor

MacOS Benchmark for fcac6b7

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.48ms ± 0.10ms 25.98ms ± 0.07ms +1.97% +0.62%
bench_hmr_to_eval/Turbopack CSR/1000 modules 25.37ms ± 0.08ms 24.92ms ± 0.14ms -1.78% -0.06%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.48ms ± 0.10ms 25.98ms ± 0.07ms +1.97% +0.62%
bench_hmr_to_eval/Turbopack CSR/1000 modules 25.37ms ± 0.08ms 24.92ms ± 0.14ms -1.78% -0.06%
bench_startup/Turbopack CSR/1000 modules 2969.52ms ± 17.45ms 3088.32ms ± 59.94ms +4.00%

@kwonoj kwonoj force-pushed the feat-swc-turbopack-plugins branch from 31454cb to ccdd3f0 Compare May 23, 2023 07:46
@github-actions
Copy link
Contributor

Linux Benchmark for 0b67215

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8637.50µs ± 103.25µs 8535.02µs ± 41.22µs -1.19%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7699.07µs ± 45.18µs 7674.65µs ± 88.85µs -0.32%
bench_startup/Turbopack CSR/1000 modules 882.80ms ± 2.45ms 883.76ms ± 5.53ms +0.11%

@github-actions
Copy link
Contributor

MacOS Benchmark for 0b67215

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 54.55ms ± 2.88ms 32.76ms ± 5.88ms -39.94% -8.75%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.40ms ± 1.04ms 25.65ms ± 0.31ms +9.63%
bench_hmr_to_eval/Turbopack CSR/1000 modules 54.55ms ± 2.88ms 32.76ms ± 5.88ms -39.94% -8.75%
bench_startup/Turbopack CSR/1000 modules 2633.59ms ± 37.83ms 2635.60ms ± 57.02ms +0.08%

@github-actions
Copy link
Contributor

Linux Benchmark for c9a2765

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8338.92µs ± 203.67µs 8297.84µs ± 193.19µs -0.49%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7379.63µs ± 158.16µs 7488.75µs ± 266.47µs +1.48%
bench_startup/Turbopack CSR/1000 modules 863.09ms ± 2.82ms 884.41ms ± 16.40ms +2.47%

@github-actions
Copy link
Contributor

MacOS Benchmark for c918cae

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.31ms ± 0.13ms 20.52ms ± 0.86ms -18.91% -11.27%
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.78ms ± 0.39ms 55.17ms ± 1.63ms +142.17% +120.33%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.31ms ± 0.13ms 20.52ms ± 0.86ms -18.91% -11.27%
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.78ms ± 0.39ms 55.17ms ± 1.63ms +142.17% +120.33%
bench_startup/Turbopack CSR/1000 modules 2746.68ms ± 120.32ms 2531.34ms ± 45.57ms -7.84%

@github-actions
Copy link
Contributor

Linux Benchmark for 215e9d1

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8416.87µs ± 51.44µs 8487.99µs ± 41.94µs +0.84%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7595.08µs ± 88.70µs 7720.50µs ± 120.22µs +1.65%
bench_startup/Turbopack CSR/1000 modules 892.03ms ± 1.38ms 895.30ms ± 5.25ms +0.37%

@github-actions
Copy link
Contributor

MacOS Benchmark for 215e9d1

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 2600.11ms ± 23.11ms 2847.61ms ± 47.95ms +9.52% +3.98%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.98ms ± 0.20ms 25.92ms ± 0.07ms -0.23%
bench_hmr_to_eval/Turbopack CSR/1000 modules 26.40ms ± 0.45ms 25.97ms ± 0.09ms -1.63%
bench_startup/Turbopack CSR/1000 modules 2600.11ms ± 23.11ms 2847.61ms ± 47.95ms +9.52% +3.98%

@kwonoj kwonoj force-pushed the feat-swc-turbopack-plugins branch from 86c2a18 to 9ccf357 Compare May 24, 2023 15:52
@github-actions
Copy link
Contributor

Linux Benchmark for 06d1dd4

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8622.63µs ± 82.19µs 8676.13µs ± 98.74µs +0.62%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7641.02µs ± 54.80µs 8288.76µs ± 499.11µs +8.48%
bench_startup/Turbopack CSR/1000 modules 891.91ms ± 2.88ms 895.01ms ± 6.65ms +0.35%

@github-actions
Copy link
Contributor

MacOS Benchmark for 06d1dd4

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 23.65ms ± 0.91ms 60.82ms ± 1.27ms +157.14% +128.80%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 26.25ms ± 0.14ms 25.28ms ± 0.97ms -3.67%
bench_hmr_to_eval/Turbopack CSR/1000 modules 23.65ms ± 0.91ms 60.82ms ± 1.27ms +157.14% +128.80%
bench_startup/Turbopack CSR/1000 modules 2910.38ms ± 55.02ms 2693.71ms ± 67.32ms -7.44%

@github-actions
Copy link
Contributor

Linux Benchmark for cfd71de

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9298.24µs ± 87.53µs 9256.84µs ± 55.90µs -0.45%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8329.63µs ± 61.93µs 8156.65µs ± 44.22µs -2.08%
bench_startup/Turbopack CSR/1000 modules 900.44ms ± 2.52ms 897.24ms ± 2.32ms -0.36%

@github-actions
Copy link
Contributor

MacOS Benchmark for cfd71de

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 21.87ms ± 0.40ms 26.10ms ± 0.23ms +19.35% +13.04%
bench_hmr_to_eval/Turbopack CSR/1000 modules 53.86ms ± 2.36ms 31.68ms ± 4.70ms -41.19% -16.41%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 21.87ms ± 0.40ms 26.10ms ± 0.23ms +19.35% +13.04%
bench_hmr_to_eval/Turbopack CSR/1000 modules 53.86ms ± 2.36ms 31.68ms ± 4.70ms -41.19% -16.41%
bench_startup/Turbopack CSR/1000 modules 2981.64ms ± 81.08ms 2839.85ms ± 24.40ms -4.76%

kwonoj and others added 7 commits May 26, 2023 11:07
…nsform_plugins.rs

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
…nsform_plugins.rs

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
…nsform_plugins.rs

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
…nsform_plugins.rs

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
@github-actions
Copy link
Contributor

Linux Benchmark for f63593e

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8499.95µs ± 34.56µs 8553.40µs ± 53.85µs +0.63%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7725.88µs ± 71.49µs 7779.30µs ± 200.92µs +0.69%
bench_startup/Turbopack CSR/1000 modules 890.10ms ± 4.01ms 905.88ms ± 9.95ms +1.77%

@kwonoj kwonoj merged commit af8505e into main May 26, 2023
42 of 43 checks passed
@kwonoj kwonoj deleted the feat-swc-turbopack-plugins branch May 26, 2023 19:07
@github-actions
Copy link
Contributor

MacOS Benchmark for f63593e

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.28ms ± 1.06ms 25.27ms ± 0.15ms +13.42% +2.36%
bench_startup/Turbopack CSR/1000 modules 14.77s ± 2.33s 3732.84ms ± 1044.35ms -74.72% -42.41%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 26.30ms ± 0.15ms 26.28ms ± 0.08ms -0.05%
bench_hmr_to_eval/Turbopack CSR/1000 modules 22.28ms ± 1.06ms 25.27ms ± 0.15ms +13.42% +2.36%
bench_startup/Turbopack CSR/1000 modules 14.77s ± 2.33s 3732.84ms ± 1044.35ms -74.72% -42.41%

kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request May 30, 2023
## What

* updates swc_core
* updates turbopack

# Turbopack Changes

* vercel/turbo#5050 
* vercel/turbo#5107 
* vercel/turbo#5094
hydRAnger pushed a commit to hydRAnger/next.js that referenced this pull request Jun 12, 2023
## What

* updates swc_core
* updates turbopack

# Turbopack Changes

* vercel/turbo#5050 
* vercel/turbo#5107 
* vercel/turbo#5094
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants