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

initial work for compile-time evaluation #3495

Merged
merged 30 commits into from
Feb 3, 2023

Conversation

sokra
Copy link
Member

@sokra sokra commented Jan 26, 2023

Allows to skip unreachable code based on compile-time constant conditions

e. g.

if (!process.turbopack) {
  require("will-not-be-processed");
}
  • add if() and process.turbopack fixes WEB-491
  • Removes unreachable code fixes WEB-498
  • evaluate some logical operations &&, ||, ??, !
  • fix arguments handling fixes WEB-529
  • nested effects for function called with closures
  • handle closures when array methods are used fixes WEB-538
  • evaluates process.turbopack fixes WEB-496

@vercel
Copy link

vercel bot commented Jan 26, 2023

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

10 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Feb 3, 2023 at 2:32PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Feb 3, 2023 at 2:32PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Feb 3, 2023 at 2:32PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)
examples-vite-web ⬜️ Ignored (Inspect) Feb 3, 2023 at 2:32PM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Feb 3, 2023 at 2:32PM (UTC)

@github-actions
Copy link
Contributor

Benchmark for 178ea44

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 7373.63µs ± 74.99µs 7468.99µs ± 46.63µs +1.29%
bench_hmr_to_commit/Turbopack RCC/1000 modules 7906.36µs ± 44.59µs 7848.89µs ± 51.59µs -0.73%
bench_hmr_to_commit/Turbopack RSC/1000 modules 432.26ms ± 2.21ms 432.47ms ± 1.52ms +0.05%
bench_hmr_to_commit/Turbopack SSR/1000 modules 7663.22µs ± 48.81µs 7639.57µs ± 57.56µs -0.31%
bench_hmr_to_eval/Turbopack CSR/1000 modules 6581.07µs ± 69.45µs 6688.39µs ± 62.44µs +1.63%
bench_hmr_to_eval/Turbopack RCC/1000 modules 6979.92µs ± 117.11µs 6915.33µs ± 64.94µs -0.93%
bench_hmr_to_eval/Turbopack SSR/1000 modules 6783.21µs ± 44.39µs 6782.72µs ± 52.54µs -0.01%
bench_hydration/Turbopack RCC/1000 modules 3074.47ms ± 7.48ms 3095.14ms ± 7.02ms +0.67%
bench_hydration/Turbopack RSC/1000 modules 2678.83ms ± 5.30ms 2700.05ms ± 7.72ms +0.79%
bench_hydration/Turbopack SSR/1000 modules 2526.21ms ± 8.60ms 2541.00ms ± 9.57ms +0.59%
bench_startup/Turbopack CSR/1000 modules 1577.34ms ± 4.02ms 1593.26ms ± 9.40ms +1.01%
bench_startup/Turbopack RCC/1000 modules 2080.24ms ± 5.11ms 2094.76ms ± 6.86ms +0.70%
bench_startup/Turbopack RSC/1000 modules 1997.02ms ± 5.97ms 2003.05ms ± 7.43ms +0.30%
bench_startup/Turbopack SSR/1000 modules 1696.26ms ± 5.74ms 1705.57ms ± 3.11ms +0.55%

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests

See workflow summary for details

@sokra sokra marked this pull request as ready for review January 26, 2023 23:28
@sokra sokra requested review from a team as code owners January 26, 2023 23:28
@github-actions
Copy link
Contributor

Benchmark for de0f2d5

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack RSC/1000 modules 454.69ms ± 3.38ms 473.92ms ± 1.05ms +4.23% +2.25%
bench_hydration/Turbopack RCC/1000 modules 3637.08ms ± 15.40ms 3766.88ms ± 9.73ms +3.57% +2.17%
bench_hydration/Turbopack RSC/1000 modules 3222.45ms ± 10.71ms 3338.75ms ± 11.59ms +3.61% +2.21%
bench_hydration/Turbopack SSR/1000 modules 3039.72ms ± 11.98ms 3142.76ms ± 9.66ms +3.39% +1.95%
bench_startup/Turbopack CSR/1000 modules 2059.82ms ± 7.07ms 2121.63ms ± 12.73ms +3.00% +1.07%
bench_startup/Turbopack RCC/1000 modules 2381.12ms ± 4.43ms 2474.06ms ± 9.08ms +3.90% +2.76%
bench_startup/Turbopack RSC/1000 modules 2304.46ms ± 9.60ms 2384.62ms ± 7.07ms +3.48% +2.01%
bench_startup/Turbopack SSR/1000 modules 1990.86ms ± 3.71ms 2047.49ms ± 5.79ms +2.84% +1.88%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9930.16µs ± 159.57µs 9739.09µs ± 97.31µs -1.92%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9460.11µs ± 91.83µs 9522.31µs ± 87.64µs +0.66%
bench_hmr_to_commit/Turbopack RSC/1000 modules 454.69ms ± 3.38ms 473.92ms ± 1.05ms +4.23% +2.25%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9786.00µs ± 157.15µs 9763.79µs ± 153.49µs -0.23%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8690.80µs ± 138.07µs 8706.25µs ± 110.55µs +0.18%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8627.15µs ± 76.41µs 8655.22µs ± 82.64µs +0.33%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8884.41µs ± 117.61µs 8729.97µs ± 189.82µs -1.74%
bench_hydration/Turbopack RCC/1000 modules 3637.08ms ± 15.40ms 3766.88ms ± 9.73ms +3.57% +2.17%
bench_hydration/Turbopack RSC/1000 modules 3222.45ms ± 10.71ms 3338.75ms ± 11.59ms +3.61% +2.21%
bench_hydration/Turbopack SSR/1000 modules 3039.72ms ± 11.98ms 3142.76ms ± 9.66ms +3.39% +1.95%
bench_startup/Turbopack CSR/1000 modules 2059.82ms ± 7.07ms 2121.63ms ± 12.73ms +3.00% +1.07%
bench_startup/Turbopack RCC/1000 modules 2381.12ms ± 4.43ms 2474.06ms ± 9.08ms +3.90% +2.76%
bench_startup/Turbopack RSC/1000 modules 2304.46ms ± 9.60ms 2384.62ms ± 7.07ms +3.48% +2.01%
bench_startup/Turbopack SSR/1000 modules 1990.86ms ± 3.71ms 2047.49ms ± 5.79ms +2.84% +1.88%

Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs please!

crates/turbopack-ecmascript/src/analyzer/builtin.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
require("fail");
import("fail");
}
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that verifies the error case as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with the error case?

I added a check if it runs through the "then" branch. Is that enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error case is when require("fail") or import("fail") fail to compile. Do we have a test case for this?

crates/turbopack-ecmascript/src/analyzer/builtin.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/graph.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/references/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/references/mod.rs Outdated Show resolved Hide resolved
@chris-olszewski chris-olszewski removed their request for review January 27, 2023 17:20
@github-actions
Copy link
Contributor

Benchmark for 4a91ae7

Test Base PR % Significant %
bench_hydration/Turbopack SSR/1000 modules 2962.86ms ± 12.38ms 3351.65ms ± 15.22ms +13.12% +11.17%
bench_startup/Turbopack CSR/1000 modules 2074.68ms ± 14.59ms 2422.71ms ± 14.77ms +16.78% +13.75%
bench_startup/Turbopack RCC/1000 modules 2709.16ms ± 5.78ms 3176.46ms ± 10.63ms +17.25% +15.97%
bench_startup/Turbopack RSC/1000 modules 2606.95ms ± 4.82ms 3124.14ms ± 6.14ms +19.84% +18.93%
bench_startup/Turbopack SSR/1000 modules 1978.40ms ± 4.47ms 2211.46ms ± 5.35ms +11.78% +10.74%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9019.28µs ± 155.08µs 9040.28µs ± 139.56µs +0.23%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9546.22µs ± 181.23µs 9082.43µs ± 109.68µs -4.86%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8219.90µs ± 100.93µs 8181.04µs ± 87.37µs -0.47%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8287.30µs ± 76.19µs 8126.62µs ± 94.94µs -1.94%
bench_hydration/Turbopack SSR/1000 modules 2962.86ms ± 12.38ms 3351.65ms ± 15.22ms +13.12% +11.17%
bench_startup/Turbopack CSR/1000 modules 2074.68ms ± 14.59ms 2422.71ms ± 14.77ms +16.78% +13.75%
bench_startup/Turbopack RCC/1000 modules 2709.16ms ± 5.78ms 3176.46ms ± 10.63ms +17.25% +15.97%
bench_startup/Turbopack RSC/1000 modules 2606.95ms ± 4.82ms 3124.14ms ± 6.14ms +19.84% +18.93%
bench_startup/Turbopack SSR/1000 modules 1978.40ms ± 4.47ms 2211.46ms ± 5.35ms +11.78% +10.74%

@wbinnssmith
Copy link
Member

x-ref: #3347

@github-actions
Copy link
Contributor

Benchmark for 840f922

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 3693.17ms ± 10.05ms 4138.33ms ± 7.94ms +12.05% +11.02%
bench_hydration/Turbopack RSC/1000 modules 3218.08ms ± 13.84ms 3683.23ms ± 12.29ms +14.45% +12.72%
bench_hydration/Turbopack SSR/1000 modules 2994.74ms ± 11.55ms 3382.85ms ± 9.99ms +12.96% +11.43%
bench_startup/Turbopack CSR/1000 modules 2029.05ms ± 7.01ms 2376.24ms ± 14.86ms +17.11% +14.85%
bench_startup/Turbopack RCC/1000 modules 2436.31ms ± 6.87ms 2730.87ms ± 5.90ms +12.09% +10.98%
bench_startup/Turbopack RSC/1000 modules 2341.62ms ± 5.45ms 2625.68ms ± 5.70ms +12.13% +11.13%
bench_startup/Turbopack SSR/1000 modules 1981.43ms ± 5.79ms 2183.46ms ± 3.78ms +10.20% +9.18%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8759.85µs ± 61.22µs 8839.30µs ± 79.23µs +0.91%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9084.99µs ± 60.23µs 9242.65µs ± 58.80µs +1.74%
bench_hmr_to_commit/Turbopack RSC/1000 modules 470.50ms ± 0.99ms 470.37ms ± 1.99ms -0.03%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9042.81µs ± 112.79µs 9052.38µs ± 83.52µs +0.11%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7764.91µs ± 69.32µs 7906.07µs ± 87.88µs +1.82%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8035.14µs ± 64.93µs 8061.49µs ± 84.12µs +0.33%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8189.00µs ± 102.82µs 8151.67µs ± 92.45µs -0.46%
bench_hydration/Turbopack RCC/1000 modules 3693.17ms ± 10.05ms 4138.33ms ± 7.94ms +12.05% +11.02%
bench_hydration/Turbopack RSC/1000 modules 3218.08ms ± 13.84ms 3683.23ms ± 12.29ms +14.45% +12.72%
bench_hydration/Turbopack SSR/1000 modules 2994.74ms ± 11.55ms 3382.85ms ± 9.99ms +12.96% +11.43%
bench_startup/Turbopack CSR/1000 modules 2029.05ms ± 7.01ms 2376.24ms ± 14.86ms +17.11% +14.85%
bench_startup/Turbopack RCC/1000 modules 2436.31ms ± 6.87ms 2730.87ms ± 5.90ms +12.09% +10.98%
bench_startup/Turbopack RSC/1000 modules 2341.62ms ± 5.45ms 2625.68ms ± 5.70ms +12.13% +11.13%
bench_startup/Turbopack SSR/1000 modules 1981.43ms ± 5.79ms 2183.46ms ± 3.78ms +10.20% +9.18%

@github-actions
Copy link
Contributor

Benchmark for 906ada4

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 3725.19ms ± 9.83ms 3599.71ms ± 14.39ms -3.37% -2.08%
bench_hydration/Turbopack RSC/1000 modules 3253.25ms ± 10.03ms 3100.75ms ± 8.31ms -4.69% -3.58%
bench_hydration/Turbopack SSR/1000 modules 3023.54ms ± 11.32ms 2909.89ms ± 8.79ms -3.76% -2.45%
bench_startup/Turbopack RCC/1000 modules 2473.54ms ± 6.10ms 2372.38ms ± 6.69ms -4.09% -3.07%
bench_startup/Turbopack RSC/1000 modules 2349.68ms ± 4.77ms 2267.69ms ± 6.21ms -3.49% -2.57%
bench_startup/Turbopack SSR/1000 modules 2012.64ms ± 5.59ms 1942.76ms ± 3.19ms -3.47% -2.61%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9189.69µs ± 58.37µs 9179.80µs ± 74.82µs -0.11%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9404.95µs ± 98.77µs 9501.77µs ± 68.01µs +1.03%
bench_hmr_to_commit/Turbopack RSC/1000 modules 480.08ms ± 1.11ms 481.07ms ± 2.96ms +0.21%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9379.24µs ± 84.68µs 9396.43µs ± 63.71µs +0.18%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8222.17µs ± 75.76µs 8282.84µs ± 41.18µs +0.74%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8405.09µs ± 89.41µs 8432.07µs ± 92.10µs +0.32%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8486.91µs ± 75.51µs 8424.96µs ± 71.88µs -0.73%
bench_hydration/Turbopack RCC/1000 modules 3725.19ms ± 9.83ms 3599.71ms ± 14.39ms -3.37% -2.08%
bench_hydration/Turbopack RSC/1000 modules 3253.25ms ± 10.03ms 3100.75ms ± 8.31ms -4.69% -3.58%
bench_hydration/Turbopack SSR/1000 modules 3023.54ms ± 11.32ms 2909.89ms ± 8.79ms -3.76% -2.45%
bench_startup/Turbopack CSR/1000 modules 2051.93ms ± 14.36ms 1967.17ms ± 37.06ms -4.13%
bench_startup/Turbopack RCC/1000 modules 2473.54ms ± 6.10ms 2372.38ms ± 6.69ms -4.09% -3.07%
bench_startup/Turbopack RSC/1000 modules 2349.68ms ± 4.77ms 2267.69ms ± 6.21ms -3.49% -2.57%
bench_startup/Turbopack SSR/1000 modules 2012.64ms ± 5.59ms 1942.76ms ± 3.19ms -3.47% -2.61%

@github-actions
Copy link
Contributor

Benchmark for ecd6823

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 3726.17ms ± 12.84ms 3587.32ms ± 9.32ms -3.73% -2.55%
bench_hydration/Turbopack RSC/1000 modules 3236.80ms ± 8.69ms 3116.17ms ± 15.26ms -3.73% -2.26%
bench_hydration/Turbopack SSR/1000 modules 3032.75ms ± 9.70ms 2918.31ms ± 21.10ms -3.77% -1.75%
bench_startup/Turbopack CSR/1000 modules 2054.26ms ± 11.99ms 1947.25ms ± 23.97ms -5.21% -1.73%
bench_startup/Turbopack RCC/1000 modules 2467.64ms ± 15.54ms 2361.22ms ± 9.61ms -4.31% -2.30%
bench_startup/Turbopack RSC/1000 modules 2370.08ms ± 6.55ms 2275.81ms ± 5.10ms -3.98% -3.01%
bench_startup/Turbopack SSR/1000 modules 1996.05ms ± 5.04ms 1941.65ms ± 7.45ms -2.73% -1.48%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9024.80µs ± 66.12µs 9043.69µs ± 62.08µs +0.21%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9551.59µs ± 99.73µs 9435.06µs ± 78.48µs -1.22%
bench_hmr_to_commit/Turbopack RSC/1000 modules 474.30ms ± 1.39ms 473.66ms ± 1.97ms -0.14%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9241.77µs ± 70.61µs 9310.66µs ± 100.35µs +0.75%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8118.26µs ± 32.48µs 8174.91µs ± 72.89µs +0.70%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8356.22µs ± 78.14µs 8447.29µs ± 42.38µs +1.09%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8285.74µs ± 73.02µs 8317.07µs ± 59.18µs +0.38%
bench_hydration/Turbopack RCC/1000 modules 3726.17ms ± 12.84ms 3587.32ms ± 9.32ms -3.73% -2.55%
bench_hydration/Turbopack RSC/1000 modules 3236.80ms ± 8.69ms 3116.17ms ± 15.26ms -3.73% -2.26%
bench_hydration/Turbopack SSR/1000 modules 3032.75ms ± 9.70ms 2918.31ms ± 21.10ms -3.77% -1.75%
bench_startup/Turbopack CSR/1000 modules 2054.26ms ± 11.99ms 1947.25ms ± 23.97ms -5.21% -1.73%
bench_startup/Turbopack RCC/1000 modules 2467.64ms ± 15.54ms 2361.22ms ± 9.61ms -4.31% -2.30%
bench_startup/Turbopack RSC/1000 modules 2370.08ms ± 6.55ms 2275.81ms ± 5.10ms -3.98% -3.01%
bench_startup/Turbopack SSR/1000 modules 1996.05ms ± 5.04ms 1941.65ms ± 7.45ms -2.73% -1.48%

@mehulkar mehulkar removed their request for review January 31, 2023 01:05
@ForsakenHarmony
Copy link
Contributor

Do any other bundlers have a specific value dedicated to detecting them? (process.webpack, process.rollup)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

Benchmark for 1501f94

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 4729.47ms ± 23.72ms 5289.65ms ± 25.13ms +11.84% +9.68%
bench_hydration/Turbopack RSC/1000 modules 4236.16ms ± 17.01ms 4791.52ms ± 19.32ms +13.11% +11.30%
bench_hydration/Turbopack SSR/1000 modules 3908.00ms ± 28.25ms 4280.37ms ± 26.91ms +9.53% +6.61%
bench_startup/Turbopack CSR/1000 modules 2790.82ms ± 13.83ms 3084.84ms ± 10.62ms +10.54% +8.70%
bench_startup/Turbopack RCC/1000 modules 3024.83ms ± 11.25ms 3364.13ms ± 8.98ms +11.22% +9.81%
bench_startup/Turbopack RSC/1000 modules 2937.88ms ± 7.67ms 3303.83ms ± 10.16ms +12.46% +11.18%
bench_startup/Turbopack SSR/1000 modules 2402.26ms ± 8.91ms 2580.70ms ± 11.28ms +7.43% +5.70%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9532.52µs ± 79.55µs 9489.65µs ± 51.25µs -0.45%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9846.62µs ± 109.37µs 9785.32µs ± 95.71µs -0.62%
bench_hmr_to_commit/Turbopack RSC/1000 modules 518.71ms ± 3.13ms 518.70ms ± 2.95ms -0.00%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9918.07µs ± 112.90µs 9793.20µs ± 61.83µs -1.26%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8602.58µs ± 76.60µs 8691.93µs ± 84.54µs +1.04%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8824.49µs ± 90.29µs 8925.43µs ± 71.34µs +1.14%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8804.42µs ± 115.68µs 8863.25µs ± 67.94µs +0.67%
bench_hydration/Turbopack RCC/1000 modules 4729.47ms ± 23.72ms 5289.65ms ± 25.13ms +11.84% +9.68%
bench_hydration/Turbopack RSC/1000 modules 4236.16ms ± 17.01ms 4791.52ms ± 19.32ms +13.11% +11.30%
bench_hydration/Turbopack SSR/1000 modules 3908.00ms ± 28.25ms 4280.37ms ± 26.91ms +9.53% +6.61%
bench_startup/Turbopack CSR/1000 modules 2790.82ms ± 13.83ms 3084.84ms ± 10.62ms +10.54% +8.70%
bench_startup/Turbopack RCC/1000 modules 3024.83ms ± 11.25ms 3364.13ms ± 8.98ms +11.22% +9.81%
bench_startup/Turbopack RSC/1000 modules 2937.88ms ± 7.67ms 3303.83ms ± 10.16ms +12.46% +11.18%
bench_startup/Turbopack SSR/1000 modules 2402.26ms ± 8.91ms 2580.70ms ± 11.28ms +7.43% +5.70%

@sokra
Copy link
Member Author

sokra commented Feb 3, 2023

Do any other bundlers have a specific value dedicated to detecting them? (process.webpack, process.rollup)

Not as far as I know.

crates/turbopack-ecmascript/src/analyzer/builtin.rs Outdated Show resolved Hide resolved
}
_ => false,
},
JsValue::MemberCall(_, box ref mut obj, box ref mut prop, _) => match obj {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to name these members (struct-like variant vs. tuple-like variant). There's a possibility to confuse prop and obj otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but that's something for a follow-up PR

crates/turbopack-ecmascript/src/analyzer/builtin.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/analyzer/well_known.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/references/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/references/mod.rs Outdated Show resolved Hide resolved
crates/turbopack-ecmascript/src/references/unreachable.rs Outdated Show resolved Hide resolved
/// Checks if we known that the value ends with a given string. Returns
/// None if we don't know. Returns Some if we know if or if not the
/// value ends with the given string.
pub fn ends_with(&self, str: &str) -> Option<bool> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to give an example of why this particular function is needed too.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

Benchmark for 5a967cf

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack RSC/1000 modules 499.46ms ± 1.38ms 504.49ms ± 0.69ms +1.01% +0.17%
bench_hydration/Turbopack RCC/1000 modules 4551.61ms ± 35.70ms 5136.59ms ± 18.71ms +12.85% +10.30%
bench_hydration/Turbopack RSC/1000 modules 4065.66ms ± 13.66ms 4574.76ms ± 14.83ms +12.52% +11.05%
bench_hydration/Turbopack SSR/1000 modules 3774.84ms ± 22.55ms 4129.48ms ± 5.33ms +9.39% +7.82%
bench_startup/Turbopack CSR/1000 modules 2690.41ms ± 7.07ms 2989.82ms ± 10.32ms +11.13% +9.78%
bench_startup/Turbopack RCC/1000 modules 2883.42ms ± 6.63ms 3223.19ms ± 5.75ms +11.78% +10.87%
bench_startup/Turbopack RSC/1000 modules 2802.16ms ± 11.60ms 3168.23ms ± 8.46ms +13.06% +11.54%
bench_startup/Turbopack SSR/1000 modules 2315.67ms ± 6.99ms 2486.39ms ± 7.97ms +7.37% +6.04%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9708.39µs ± 60.69µs 9803.56µs ± 64.51µs +0.98%
bench_hmr_to_commit/Turbopack RCC/1000 modules 10.07ms ± 0.09ms 9995.25µs ± 65.90µs -0.75%
bench_hmr_to_commit/Turbopack RSC/1000 modules 499.46ms ± 1.38ms 504.49ms ± 0.69ms +1.01% +0.17%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9978.38µs ± 88.29µs 9946.52µs ± 88.44µs -0.32%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8766.39µs ± 88.23µs 8788.40µs ± 94.62µs +0.25%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8906.64µs ± 81.10µs 8917.39µs ± 99.65µs +0.12%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8904.36µs ± 57.99µs 8863.78µs ± 62.49µs -0.46%
bench_hydration/Turbopack RCC/1000 modules 4551.61ms ± 35.70ms 5136.59ms ± 18.71ms +12.85% +10.30%
bench_hydration/Turbopack RSC/1000 modules 4065.66ms ± 13.66ms 4574.76ms ± 14.83ms +12.52% +11.05%
bench_hydration/Turbopack SSR/1000 modules 3774.84ms ± 22.55ms 4129.48ms ± 5.33ms +9.39% +7.82%
bench_startup/Turbopack CSR/1000 modules 2690.41ms ± 7.07ms 2989.82ms ± 10.32ms +11.13% +9.78%
bench_startup/Turbopack RCC/1000 modules 2883.42ms ± 6.63ms 3223.19ms ± 5.75ms +11.78% +10.87%
bench_startup/Turbopack RSC/1000 modules 2802.16ms ± 11.60ms 3168.23ms ± 8.46ms +13.06% +11.54%
bench_startup/Turbopack SSR/1000 modules 2315.67ms ± 6.99ms 2486.39ms ± 7.97ms +7.37% +6.04%

@sokra sokra requested a review from alexkirsz February 3, 2023 13:45
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2023

Benchmark for ae45cde

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack RSC/1000 modules 496.57ms ± 1.80ms 505.14ms ± 2.24ms +1.73% +0.10%
bench_hydration/Turbopack RCC/1000 modules 4668.42ms ± 50.84ms 5173.72ms ± 25.52ms +10.82% +7.39%
bench_hydration/Turbopack RSC/1000 modules 4172.40ms ± 29.31ms 4582.79ms ± 18.72ms +9.84% +7.43%
bench_hydration/Turbopack SSR/1000 modules 3839.39ms ± 21.32ms 4176.60ms ± 14.58ms +8.78% +6.84%
bench_startup/Turbopack CSR/1000 modules 2709.06ms ± 12.20ms 3013.44ms ± 8.64ms +11.24% +9.61%
bench_startup/Turbopack RCC/1000 modules 2950.81ms ± 12.05ms 3246.21ms ± 12.07ms +10.01% +8.31%
bench_startup/Turbopack RSC/1000 modules 2861.92ms ± 11.48ms 3200.04ms ± 16.18ms +11.81% +9.80%
bench_startup/Turbopack SSR/1000 modules 2340.89ms ± 5.79ms 2491.76ms ± 5.01ms +6.44% +5.49%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9939.48µs ± 65.65µs 9884.97µs ± 45.30µs -0.55%
bench_hmr_to_commit/Turbopack RCC/1000 modules 10.34ms ± 0.06ms 10.25ms ± 0.08ms -0.90%
bench_hmr_to_commit/Turbopack RSC/1000 modules 496.57ms ± 1.80ms 505.14ms ± 2.24ms +1.73% +0.10%
bench_hmr_to_commit/Turbopack SSR/1000 modules 10.13ms ± 0.08ms 10.06ms ± 0.11ms -0.63%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8979.91µs ± 95.57µs 9076.97µs ± 65.29µs +1.08%
bench_hmr_to_eval/Turbopack RCC/1000 modules 9004.85µs ± 113.10µs 8953.74µs ± 138.50µs -0.57%
bench_hmr_to_eval/Turbopack SSR/1000 modules 9171.76µs ± 80.18µs 9188.70µs ± 101.70µs +0.18%
bench_hydration/Turbopack RCC/1000 modules 4668.42ms ± 50.84ms 5173.72ms ± 25.52ms +10.82% +7.39%
bench_hydration/Turbopack RSC/1000 modules 4172.40ms ± 29.31ms 4582.79ms ± 18.72ms +9.84% +7.43%
bench_hydration/Turbopack SSR/1000 modules 3839.39ms ± 21.32ms 4176.60ms ± 14.58ms +8.78% +6.84%
bench_startup/Turbopack CSR/1000 modules 2709.06ms ± 12.20ms 3013.44ms ± 8.64ms +11.24% +9.61%
bench_startup/Turbopack RCC/1000 modules 2950.81ms ± 12.05ms 3246.21ms ± 12.07ms +10.01% +8.31%
bench_startup/Turbopack RSC/1000 modules 2861.92ms ± 11.48ms 3200.04ms ± 16.18ms +11.81% +9.80%
bench_startup/Turbopack SSR/1000 modules 2340.89ms ± 5.79ms 2491.76ms ± 5.01ms +6.44% +5.49%

@sokra sokra merged commit 4f66bf6 into main Feb 3, 2023
@sokra sokra deleted the sokra/web-492-handle-if-statements branch February 3, 2023 16:34
mehulkar pushed a commit that referenced this pull request Feb 3, 2023
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
sokra added a commit to vercel/next.js that referenced this pull request Mar 13, 2023
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
Allows to skip unreachable code based on compile-time constant
conditions

e. g.

```
if (!process.turbopack) {
  require("will-not-be-processed");
}
```

* add if() and process.turbopack fixes WEB-491
* Removes unreachable code fixes WEB-498
* evaluate some logical operations `&&`, `||`, `??`, `!`
* fix arguments handling fixes WEB-529
* nested effects for function called with closures
* handle closures when array methods are used fixes WEB-538
* evaluates `process.turbopack` fixes WEB-496
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.

5 participants