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

Automatically apply babel-loader for apps with babel configs #3862

Merged
merged 8 commits into from
Feb 22, 2023

Conversation

wbinnssmith
Copy link
Member

This will automatically apply babel-loader to Next.js apps that include a babel configuration file alongside next.config.js. It requires the app to provide babel-loader itself.

Test Plan: Added an integration test.

This will automatically apply `babel-loader` to Next.js apps that include a babel configuration file alongside `next.config.js`. It requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
@vercel
Copy link

vercel bot commented Feb 17, 2023

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

Name Status Preview Comments Updated
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-cra-web ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-kitchensink-blog ❌ Failed (Inspect) Feb 22, 2023 at 4:21PM (UTC)
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-svelte-web ❌ Failed (Inspect) Feb 22, 2023 at 4:21PM (UTC)
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 22, 2023 at 4:21PM (UTC)

@socket-security
Copy link

Socket Security Pull Request Report

👍 No new dependency issues detected in pull request

Pull request report summary
Issue Status
Install scripts ✅ 0 issues
Native code ✅ 0 issues
Bin script confusion ✅ 0 issues
Bin script shell injection ✅ 0 issues
Unresolved require ✅ 0 issues
Invalid package.json ✅ 0 issues
HTTP dependency ✅ 0 issues
Git dependency ✅ 0 issues
Potential typo squat ✅ 0 issues
Known Malware ✅ 0 issues
Telemetry ✅ 0 issues
Protestware/Troll package ✅ 0 issues
Bot Commands

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@2.4.2

Powered by socket.dev

crates/turbopack-node/src/transforms/webpack.rs Outdated Show resolved Hide resolved
crates/next-core/src/util.rs Outdated Show resolved Hide resolved
crates/next-core/src/util.rs Outdated Show resolved Hide resolved
crates/next-core/src/util.rs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 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

Benchmark for b730c7e

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 10.22ms ± 0.07ms 10.21ms ± 0.06ms -0.06%
bench_hmr_to_commit/Turbopack RCC/1000 modules 12.37ms ± 0.29ms 12.34ms ± 0.35ms -0.24%
bench_hmr_to_commit/Turbopack RSC/1000 modules 515.99ms ± 1.50ms 513.12ms ± 2.28ms -0.56%
bench_hmr_to_commit/Turbopack SSR/1000 modules 10.29ms ± 0.07ms 10.27ms ± 0.08ms -0.19%
bench_hmr_to_eval/Turbopack CSR/1000 modules 9331.50µs ± 69.86µs 9168.69µs ± 74.94µs -1.74%
bench_hmr_to_eval/Turbopack RCC/1000 modules 10.88ms ± 0.11ms 11.02ms ± 0.16ms +1.28%
bench_hmr_to_eval/Turbopack SSR/1000 modules 9232.05µs ± 71.06µs 9226.31µs ± 76.62µs -0.06%
bench_hydration/Turbopack RCC/1000 modules 3768.79ms ± 26.54ms 3761.41ms ± 16.93ms -0.20%
bench_hydration/Turbopack RSC/1000 modules 3403.96ms ± 8.53ms 3417.03ms ± 8.99ms +0.38%
bench_hydration/Turbopack SSR/1000 modules 3441.22ms ± 12.29ms 3439.97ms ± 11.85ms -0.04%
bench_startup/Turbopack CSR/1000 modules 2725.46ms ± 9.64ms 2705.56ms ± 13.51ms -0.73%
bench_startup/Turbopack RCC/1000 modules 2294.97ms ± 4.79ms 2297.21ms ± 6.24ms +0.10%
bench_startup/Turbopack RSC/1000 modules 2248.97ms ± 8.76ms 2223.84ms ± 5.03ms -1.12%
bench_startup/Turbopack SSR/1000 modules 2105.58ms ± 3.01ms 2099.08ms ± 3.18ms -0.31%

@github-actions
Copy link
Contributor

Benchmark for 4c7aa1d

Test Base PR % Significant %
bench_hydration/Turbopack RSC/1000 modules 3410.40ms ± 6.13ms 3455.89ms ± 8.65ms +1.33% +0.47%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9439.20µs ± 72.64µs 9394.75µs ± 66.14µs -0.47%
bench_hmr_to_commit/Turbopack RCC/1000 modules 11.87ms ± 0.10ms 11.61ms ± 0.14ms -2.13%
bench_hmr_to_commit/Turbopack RSC/1000 modules 524.07ms ± 3.14ms 523.88ms ± 3.74ms -0.04%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9569.19µs ± 79.40µs 9471.84µs ± 122.04µs -1.02%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8431.32µs ± 82.68µs 8478.70µs ± 38.85µs +0.56%
bench_hmr_to_eval/Turbopack RCC/1000 modules 10.67ms ± 0.15ms 10.74ms ± 0.29ms +0.64%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8597.98µs ± 69.48µs 8615.45µs ± 106.59µs +0.20%
bench_hydration/Turbopack RCC/1000 modules 3767.63ms ± 20.78ms 3852.94ms ± 29.98ms +2.26%
bench_hydration/Turbopack RSC/1000 modules 3410.40ms ± 6.13ms 3455.89ms ± 8.65ms +1.33% +0.47%
bench_hydration/Turbopack SSR/1000 modules 3478.63ms ± 8.97ms 3471.47ms ± 12.69ms -0.21%
bench_startup/Turbopack CSR/1000 modules 2744.88ms ± 9.97ms 2707.65ms ± 11.22ms -1.36%
bench_startup/Turbopack RCC/1000 modules 2328.98ms ± 11.05ms 2313.09ms ± 9.78ms -0.68%
bench_startup/Turbopack RSC/1000 modules 2276.62ms ± 11.28ms 2242.59ms ± 8.80ms -1.49%
bench_startup/Turbopack SSR/1000 modules 2131.03ms ± 7.69ms 2123.20ms ± 5.89ms -0.37%

@github-actions
Copy link
Contributor

Benchmark for 2c599ad

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9311.86µs ± 32.64µs 9447.22µs ± 88.92µs +1.45%
bench_hmr_to_commit/Turbopack RCC/1000 modules 12.41ms ± 0.16ms 12.59ms ± 0.16ms +1.44%
bench_hmr_to_commit/Turbopack RSC/1000 modules 503.42ms ± 1.61ms 506.15ms ± 2.42ms +0.54%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9492.81µs ± 55.98µs 9536.64µs ± 76.56µs +0.46%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8467.75µs ± 71.55µs 8375.57µs ± 99.03µs -1.09%
bench_hmr_to_eval/Turbopack RCC/1000 modules 11.21ms ± 0.23ms 10.84ms ± 0.25ms -3.36%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8480.05µs ± 57.95µs 8499.53µs ± 67.61µs +0.23%
bench_hydration/Turbopack RCC/1000 modules 3695.92ms ± 23.78ms 3682.89ms ± 17.07ms -0.35%
bench_hydration/Turbopack RSC/1000 modules 3334.34ms ± 10.81ms 3343.58ms ± 9.99ms +0.28%
bench_hydration/Turbopack SSR/1000 modules 3377.75ms ± 10.45ms 3386.51ms ± 10.03ms +0.26%
bench_startup/Turbopack CSR/1000 modules 2678.90ms ± 11.30ms 2665.98ms ± 11.18ms -0.48%
bench_startup/Turbopack RCC/1000 modules 2270.55ms ± 7.36ms 2265.75ms ± 4.16ms -0.21%
bench_startup/Turbopack RSC/1000 modules 2186.46ms ± 5.14ms 2212.60ms ± 10.83ms +1.20%
bench_startup/Turbopack SSR/1000 modules 2065.36ms ± 3.48ms 2068.99ms ± 2.90ms +0.18%

let has_babel_config = {
let mut has_babel_config = false;
for filename in BABEL_CONFIG_FILES {
let metadata = project_root.join(filename).metadata().await;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let metadata = project_root.join(filename).metadata().await;
let metadata = project_root.join(filename).get_type().await;

We usually use get_type for existence checks as it's cheaper as it doesn't require a syscall

Copy link
Contributor

Choose a reason for hiding this comment

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

There's also find_context_file which does tree lookups.

RequestVc::parse(Value::new(Pattern::Constant(
"babel-loader/package.json".to_string(),
))),
resolve_options(
Copy link
Member

Choose a reason for hiding this comment

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

There are node_resolve_options somewhere in our repo. You can use them.

Copy link
Contributor

Choose a reason for hiding this comment

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

See assert_can_resolve_react_refresh

let has_babel_config = {
let mut has_babel_config = false;
for filename in BABEL_CONFIG_FILES {
let metadata = project_root.join(filename).metadata().await;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's also find_context_file which does tree lookups.


if has_babel_config {
let mut options = (*webpack_options.await?).clone();
for ext in [".js", ".jsx", ".ts", ".tsx", ".cjs", ".mjs"] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be using next_config.page_extensions() instead? Also, what about .cts, .mts, .ctsx, and .mtsx?

}
.cell()
.as_issue()
.emit()
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 going to be emitted for every extension?

RequestVc::parse(Value::new(Pattern::Constant(
"babel-loader/package.json".to_string(),
))),
resolve_options(
Copy link
Contributor

Choose a reason for hiding this comment

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

See assert_can_resolve_react_refresh

@github-actions
Copy link
Contributor

Benchmark for 7380915

Test Base PR % Significant %
bench_hydration/Turbopack RCC/1000 modules 3780.38ms ± 7.09ms 3972.66ms ± 18.78ms +5.09% +3.70%
bench_hydration/Turbopack RSC/1000 modules 3437.89ms ± 10.58ms 3602.36ms ± 9.94ms +4.78% +3.57%
bench_hydration/Turbopack SSR/1000 modules 3380.47ms ± 6.85ms 3641.85ms ± 11.53ms +7.73% +6.62%
bench_startup/Turbopack CSR/1000 modules 2628.32ms ± 13.97ms 2904.51ms ± 8.83ms +10.51% +8.68%
bench_startup/Turbopack RCC/1000 modules 2371.79ms ± 7.40ms 2422.64ms ± 7.31ms +2.14% +0.90%
bench_startup/Turbopack RSC/1000 modules 2268.34ms ± 5.13ms 2324.42ms ± 8.60ms +2.47% +1.26%
bench_startup/Turbopack SSR/1000 modules 2075.87ms ± 2.52ms 2194.18ms ± 6.24ms +5.70% +4.84%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9386.30µs ± 91.64µs 9369.55µs ± 65.47µs -0.18%
bench_hmr_to_commit/Turbopack RCC/1000 modules 11.77ms ± 0.19ms 11.45ms ± 0.20ms -2.69%
bench_hmr_to_commit/Turbopack RSC/1000 modules 510.67ms ± 2.65ms 518.38ms ± 1.97ms +1.51%
bench_hmr_to_commit/Turbopack SSR/1000 modules 9592.31µs ± 77.49µs 9493.79µs ± 88.14µs -1.03%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8536.13µs ± 121.36µs 8468.95µs ± 88.69µs -0.79%
bench_hmr_to_eval/Turbopack RCC/1000 modules 10.85ms ± 0.16ms 10.40ms ± 0.07ms -4.11%
bench_hmr_to_eval/Turbopack SSR/1000 modules 8557.96µs ± 91.32µs 8540.39µs ± 68.49µs -0.21%
bench_hydration/Turbopack RCC/1000 modules 3780.38ms ± 7.09ms 3972.66ms ± 18.78ms +5.09% +3.70%
bench_hydration/Turbopack RSC/1000 modules 3437.89ms ± 10.58ms 3602.36ms ± 9.94ms +4.78% +3.57%
bench_hydration/Turbopack SSR/1000 modules 3380.47ms ± 6.85ms 3641.85ms ± 11.53ms +7.73% +6.62%
bench_startup/Turbopack CSR/1000 modules 2628.32ms ± 13.97ms 2904.51ms ± 8.83ms +10.51% +8.68%
bench_startup/Turbopack RCC/1000 modules 2371.79ms ± 7.40ms 2422.64ms ± 7.31ms +2.14% +0.90%
bench_startup/Turbopack RSC/1000 modules 2268.34ms ± 5.13ms 2324.42ms ± 8.60ms +2.47% +1.26%
bench_startup/Turbopack SSR/1000 modules 2075.87ms ± 2.52ms 2194.18ms ± 6.24ms +5.70% +4.84%

@wbinnssmith wbinnssmith merged commit 01a004e into main Feb 22, 2023
@wbinnssmith wbinnssmith deleted the wbinnssmith/auto-babel-loader branch February 22, 2023 18:07
wbinnssmith added a commit that referenced this pull request Feb 24, 2023
This:
* Addresses feedback from #3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these
wbinnssmith added a commit that referenced this pull request Feb 27, 2023
This:
* Addresses feedback from #3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
…turborepo#3862)

This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
jridgewell added a commit to vercel/next.js that referenced this pull request Mar 10, 2023
This:
* Addresses feedback from vercel/turborepo#3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
…turborepo#3862)

This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
This:
* Addresses feedback from vercel/turborepo#3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
…turborepo#3862)

This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
This:
* Addresses feedback from vercel/turborepo#3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…turborepo#3862)

This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
This:
* Addresses feedback from vercel/turborepo#3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
…turborepo#3862)

This will automatically apply `babel-loader` to Next.js apps that
include a babel configuration file alongside `next.config.js`. It
requires the app to provide `babel-loader` itself.

Test Plan: Added an integration test.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
This:
* Addresses feedback from vercel/turborepo#3862
* Exempts VirtualAssets from webpack loaders. This addresses a bug where
next-hydrate.tsx could not be read.
	* Adds `ModuleRuleCondition::ResourceIsVirtualAsset` to filter these

---------

Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
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.

4 participants