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(turbopack): basic sass-loader support #4985

Merged
merged 3 commits into from
May 18, 2023
Merged

feat(turbopack): basic sass-loader support #4985

merged 3 commits into from
May 18, 2023

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented May 16, 2023

Description

WEB-654.

This is pairing PR from next.js vercel/next.js#49882 (not a breaking change though) to have necessary support to run sass-loader. Mainly, it adds near-dummy context in webpack-loaders as well as assigning specific module types for the scss / sass.

I'm not entirely in favor of having internal custom module type logic in webpack loaders setup by extension - however next.config.js itself doesn't have enough information other than extension + loader to determine module type. Something would like to address.

@kwonoj kwonoj requested a review from a team as a code owner May 16, 2023 22:12
@vercel
Copy link

vercel bot commented May 16, 2023

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

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

@github-actions
Copy link
Contributor

✅ This change can build next-swc

@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

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

See workflow summary for details

@github-actions
Copy link
Contributor

Linux Benchmark for ed89e67

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8425.22µs ± 27.56µs 8616.89µs ± 40.57µs +2.28% +0.65%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8425.22µs ± 27.56µs 8616.89µs ± 40.57µs +2.28% +0.65%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7685.47µs ± 55.90µs 7807.72µs ± 57.29µs +1.59%
bench_startup/Turbopack CSR/1000 modules 928.17ms ± 1.99ms 920.88ms ± 3.73ms -0.79%

@github-actions
Copy link
Contributor

MacOS Benchmark for ed89e67

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 9172.35ms ± 1931.07ms 2873.85ms ± 48.72ms -68.67% -44.05%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 25.87ms ± 0.18ms 26.65ms ± 0.24ms +3.01%
bench_hmr_to_eval/Turbopack CSR/1000 modules 24.94ms ± 0.20ms 25.20ms ± 0.36ms +1.07%
bench_startup/Turbopack CSR/1000 modules 9172.35ms ± 1931.07ms 2873.85ms ± 48.72ms -68.67% -44.05%

Comment on lines +70 to +74
for (let i = 0; i < errorStack.length; i++) {
if (errorStack[i].includes(flag)) {
errorStack.length = i;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this missing a break statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same goes for https://github.com/vercel/turbo/pull/4985/files#r1197370422, could cut it but thought it'd better to preserve these logics as much as same.

crates/turbopack-node/js/src/transforms/webpack-loaders.ts Outdated Show resolved Hide resolved
crates/turbopack-node/js/src/transforms/webpack-loaders.ts Outdated Show resolved Hide resolved
* @param {string} stack stack trace
* @returns {string} stack trace without the loader execution flag included
*/
const cutOffLoaderExecution = (stack) => cutOffByFlag(stack, loaderFlag);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are copy-paste from what webpack does for the logging with its levels. We could not do it, but tried to mimic its behavior as much.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@github-actions
Copy link
Contributor

Linux Benchmark for 2a6680d

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8114.40µs ± 63.45µs 8230.99µs ± 76.44µs +1.44%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7401.83µs ± 42.01µs 7309.20µs ± 34.86µs -1.25%
bench_startup/Turbopack CSR/1000 modules 872.11ms ± 1.62ms 865.99ms ± 2.30ms -0.70%

@github-actions
Copy link
Contributor

MacOS Benchmark for 2a6680d

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 19.10ms ± 0.76ms 24.24ms ± 0.14ms +26.94% +16.24%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 24.72ms ± 0.14ms 25.10ms ± 0.21ms +1.56%
bench_hmr_to_eval/Turbopack CSR/1000 modules 19.10ms ± 0.76ms 24.24ms ± 0.14ms +26.94% +16.24%
bench_startup/Turbopack CSR/1000 modules 2609.89ms ± 90.57ms 2476.65ms ± 33.38ms -5.11%

rootContext: contextDir,
getOptions() {
const entry = this.loaders[this.loaderIndex];
return entry.options && typeof entry.options === "object"
? entry.options
: {};
},
getResolve: () => ({
// [TODO] this is incomplete
Copy link
Contributor

Choose a reason for hiding this comment

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

We should have a __turbopack_require_context__.resolve() which is our module runtime's resolver.

@kwonoj kwonoj added the pr: automerge Kodiak will merge these automatically after checks pass label May 18, 2023
kwonoj and others added 3 commits May 18, 2023 11:47
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
@kodiakhq kodiakhq bot merged commit 4b91af9 into main May 18, 2023
41 of 42 checks passed
@kodiakhq kodiakhq bot deleted the feat-sass-loader branch May 18, 2023 19:04
@github-actions
Copy link
Contributor

Linux Benchmark for 7905ffe

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 901.49ms ± 1.88ms 917.44ms ± 5.19ms +1.77% +0.20%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8691.36µs ± 76.10µs 8904.56µs ± 86.93µs +2.45%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7943.94µs ± 36.66µs 8190.54µs ± 217.80µs +3.10%
bench_startup/Turbopack CSR/1000 modules 901.49ms ± 1.88ms 917.44ms ± 5.19ms +1.77% +0.20%

@github-actions
Copy link
Contributor

Windows Benchmark for 7905ffe

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 15.52ms ± 0.01ms 15.48ms ± 0.01ms -0.28% -0.01%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 15.74ms ± 0.31ms 15.58ms ± 0.05ms -1.04%
bench_hmr_to_eval/Turbopack CSR/1000 modules 15.52ms ± 0.01ms 15.48ms ± 0.01ms -0.28% -0.01%
bench_startup/Turbopack CSR/1000 modules 2948.59ms ± 6.05ms 3034.57ms ± 37.97ms +2.92%

@github-actions
Copy link
Contributor

MacOS Benchmark for 7905ffe

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.31ms ± 1.28ms 47.54ms ± 5.70ms +103.92% +39.74%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 23.31ms ± 1.28ms 47.54ms ± 5.70ms +103.92% +39.74%
bench_hmr_to_eval/Turbopack CSR/1000 modules 27.36ms ± 1.07ms 25.99ms ± 0.17ms -5.03%
bench_startup/Turbopack CSR/1000 modules 2694.36ms ± 35.33ms 2783.53ms ± 53.45ms +3.31%

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.

None yet

2 participants