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

turbopackLoaders: accept basic loader options #3540

Merged
merged 3 commits into from
Jan 31, 2023

Conversation

wbinnssmith
Copy link
Member

@wbinnssmith wbinnssmith commented Jan 31, 2023

Fixes WEB-525

This allows webpack loaders defined by experimental.turbopackLoaders in next.config.js to pass serializable options to loaders.

It expands turbopackLoaders to accept not just loader names for a given extension, but also {loader: string, options: Object}. These options are verified to be serializable and passed to loader-runner and exposed as getOptions() to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing class Foo {}; new Foo() as an option value and verified the error was displayed.

@wbinnssmith wbinnssmith requested a review from a team as a code owner January 31, 2023 01:30
@vercel
Copy link

vercel bot commented Jan 31, 2023

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

Name Status Preview Comments Updated
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 31, 2023 at 5:20PM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)
examples-vite-web ⬜️ Ignored (Inspect) Jan 31, 2023 at 5:20PM (UTC)

@@ -73,6 +73,7 @@ ignore!(
ignore!((), String, Duration, anyhow::Error);
ignore!(Path, PathBuf);
ignore!(serde_json::Value);
ignore!(serde_json::Map<String, serde_json::Value>);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think this is too specific, and would put it as a #[turbo_tasks(trace_ignore)] on the struct field.

});
loaders = loaders.map((loader: any) =>
typeof loader === "string"
? resolveLoader(loader)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we normalize the object here and avoid the ternary later?

@github-actions
Copy link
Contributor

Benchmark for bd04bf6

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 8338.62µs ± 74.97µs 8559.90µs ± 26.74µs +2.65% +0.21%
bench_hydration/Turbopack SSR/1000 modules 3186.89ms ± 19.48ms 3118.32ms ± 11.75ms -2.15% -0.19%
bench_startup/Turbopack RCC/1000 modules 2527.18ms ± 6.97ms 2494.37ms ± 6.71ms -1.30% -0.22%
bench_startup/Turbopack RSC/1000 modules 2448.59ms ± 7.63ms 2398.46ms ± 5.32ms -2.05% -1.00%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9278.52µs ± 72.91µs 9240.91µs ± 110.39µs -0.41%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9573.17µs ± 101.30µs 9622.24µs ± 74.68µs +0.51%
bench_hmr_to_commit/Turbopack RSC/1000 modules 492.85ms ± 2.98ms 495.32ms ± 2.36ms +0.50%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9621.50µs ± 99.81µs 9498.04µs ± 114.50µs -1.28%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8338.62µs ± 74.97µs 8559.90µs ± 26.74µs +2.65% +0.21%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8772.00µs ± 156.16µs 8569.40µs ± 75.76µs -2.31%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8521.78µs ± 107.08µs 8344.44µs ± 120.79µs -2.08%
bench_hydration/Turbopack RCC/1000 modules 3839.97ms ± 11.98ms 3817.44ms ± 9.91ms -0.59%
bench_hydration/Turbopack RSC/1000 modules 3385.07ms ± 9.91ms 3373.07ms ± 14.71ms -0.35%
bench_hydration/Turbopack SSR/1000 modules 3186.89ms ± 19.48ms 3118.32ms ± 11.75ms -2.15% -0.19%
bench_startup/Turbopack CSR/1000 modules 2083.54ms ± 8.73ms 2098.48ms ± 15.59ms +0.72%
bench_startup/Turbopack RCC/1000 modules 2527.18ms ± 6.97ms 2494.37ms ± 6.71ms -1.30% -0.22%
bench_startup/Turbopack RSC/1000 modules 2448.59ms ± 7.63ms 2398.46ms ± 5.32ms -2.05% -1.00%
bench_startup/Turbopack SSR/1000 modules 2047.22ms ± 5.29ms 2050.27ms ± 7.05ms +0.15%

@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2023

🟢 CI successful 🟢

Thanks

@wbinnssmith wbinnssmith added the pr: automerge Kodiak will merge these automatically after checks pass label Jan 31, 2023
@github-actions
Copy link
Contributor

Benchmark for 673fa95

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9158.74µs ± 61.60µs 9220.10µs ± 54.80µs +0.67%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9568.50µs ± 99.85µs 9483.24µs ± 88.92µs -0.89%
bench_hmr_to_commit/Turbopack RSC/1000 modules 478.28ms ± 1.50ms 478.86ms ± 1.17ms +0.12%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9419.90µs ± 67.48µs 9436.18µs ± 94.37µs +0.17%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8243.95µs ± 62.97µs 8182.14µs ± 82.84µs -0.75%
bench_hmr_to_eval/Turbopack RCC/1000 modules 8499.56µs ± 68.38µs 8493.85µs ± 65.57µs -0.07%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8486.06µs ± 77.27µs 8471.85µs ± 88.39µs -0.17%
bench_hydration/Turbopack RCC/1000 modules 3693.59ms ± 10.74ms 3688.88ms ± 10.68ms -0.13%
bench_hydration/Turbopack RSC/1000 modules 3264.50ms ± 12.00ms 3226.38ms ± 9.95ms -1.17%
bench_hydration/Turbopack SSR/1000 modules 3050.21ms ± 7.02ms 3031.57ms ± 8.97ms -0.61%
bench_startup/Turbopack CSR/1000 modules 2043.11ms ± 16.08ms 2032.41ms ± 14.11ms -0.52%
bench_startup/Turbopack RCC/1000 modules 2468.69ms ± 10.75ms 2466.28ms ± 8.15ms -0.10%
bench_startup/Turbopack RSC/1000 modules 2360.51ms ± 8.36ms 2361.89ms ± 4.26ms +0.06%
bench_startup/Turbopack SSR/1000 modules 2008.72ms ± 5.47ms 2000.25ms ± 5.48ms -0.42%

@kodiakhq kodiakhq bot merged commit 752319a into main Jan 31, 2023
@kodiakhq kodiakhq bot deleted the wbinnssmith/loader-options branch January 31, 2023 20:44
mehulkar pushed a commit that referenced this pull request Feb 1, 2023
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
@pete-willard
Copy link

pete-willard commented Apr 14, 2024

Sorry for necroing a thread but I think it would be beneficial to reflect this change in the docs. Thanks for the change!

ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
Fixes WEB-525

This allows webpack loaders defined by `experimental.turbopackLoaders` in `next.config.js` to pass serializable options to loaders.

It expands `turbopackLoaders` to accept not just loader names for a given extension, but also `{loader: string, options: Object}`. These options are verified to be serializable and passed to `loader-runner` and exposed as `getOptions()` to the loader.

Test Plan: Added an integration test for basic options. Verified the serializable check by passing `class Foo {}; new Foo()` as an option value and verified the error was displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants