Skip to content

Use page extensions in next-swc transforms applying to pages#90650

Merged
eps1lon merged 9 commits intocanaryfrom
cursor/page-extensions-regex-usage-020f
Mar 4, 2026
Merged

Use page extensions in next-swc transforms applying to pages#90650
eps1lon merged 9 commits intocanaryfrom
cursor/page-extensions-regex-usage-020f

Conversation

@eps1lon
Copy link
Member

@eps1lon eps1lon commented Feb 27, 2026

Resolves #90273 (comment)

Previously some transforms hardcoded possible page extensions when matching pages (or layout.js, or default.js). This doesn't necessarily cover all pages as configured. Now we're using config.pageExtensions to consider modules consistently as pages.

This pull request contains changes generated by a Cursor Cloud Agent

Open in Web Open in Cursor 

cursoragent and others added 2 commits February 27, 2026 13:09
Replace hardcoded page extension regex patterns (ts|js)x? with dynamic
patterns built from configured page_extensions. This ensures custom
pageExtensions from next.config.js are respected in:

- react_server_components.rs: error file and app entry detection
- debug_instant_stack.rs: page/layout/default file matching
- next_strip_page_exports.rs: _document file exclusion

The page_extensions are passed through:
- Options struct in next-custom-transforms (with serde default for
  backward compatibility)
- Turbopack wrappers read from NextConfig::page_extensions()
- Webpack/SWC path via TransformOptions and swc/options.ts

Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
@cursor
Copy link

cursor bot commented Feb 27, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@nextjs-bot nextjs-bot added created-by: Next.js team PRs by the Next.js team. Turbopack Related to Turbopack with Next.js. type: next labels Feb 27, 2026
@eps1lon eps1lon changed the title Page extensions regex usage Use page extensions in next-swc transforms applying to pages Feb 27, 2026
@eps1lon eps1lon added the CI approved Approve running CI for fork label Feb 27, 2026
…Options

The pageExtensions parameter was added to the type annotations but was
missing from the parameter destructuring, causing TypeScript errors:
'Cannot find name pageExtensions' and 'No value exists in scope for
the shorthand property pageExtensions'.

Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
Upstream changed the transform from Fold+fold_pass to VisitMut+visit_mut_pass.
Resolved by keeping our page_extensions changes while adopting the new
VisitMut pattern from canary.

Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Feb 27, 2026

Stats from current PR

🟢 1 improvement

Metric Canary PR Change Trend
node_modules Size 476 MB 475 MB 🟢 275 kB (0%) ▁▁▁▁▁
📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 966ms 963ms ▁▁▁▃▁
Cold (Ready in log) 935ms 929ms ▂▂▂▃▁
Cold (First Request) 1.709s 1.695s ▄▄▄▄▁
Warm (Listen) 964ms 963ms ▁▁▁▃▁
Warm (Ready in log) 930ms 940ms ▁▁▁▃▁
Warm (First Request) 746ms 723ms ▁▁▁▃▁
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 507ms 507ms ▁▁▁▁▅
Cold (Ready in log) 473ms 476ms ▁▄▃▁▅
Cold (First Request) 2.106s 2.091s ▁▂▂▁▅
Warm (Listen) 508ms 508ms ▁▁▁▁▅
Warm (Ready in log) 473ms 474ms ▁▂▂▁▅
Warm (First Request) 2.085s 2.109s ▁▁▁▁▅

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 6.488s 6.593s ▁▁▁▆▁
Cached Build 6.429s 6.617s ▁▁▁▅▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 15.583s 15.663s ▂▁▁▁▄
Cached Build 15.660s 15.765s ▁▁▁▁▄
node_modules Size 476 MB 475 MB 🟢 275 kB (0%) ▁▁▁▁▁
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles: **401 kB** → **401 kB** ✅ -430 B

80 files with content-based hashes (individual files not comparable between builds)

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 769 B 764 B
Total 769 B 764 B ✅ -5 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 453 B 451 B
Total 453 B 451 B ✅ -2 B

📦 Webpack

Client

Main Bundles
Canary PR Change
5528-HASH.js gzip 5.54 kB N/A -
6280-HASH.js gzip 58.8 kB N/A -
6335.HASH.js gzip 169 B N/A -
912-HASH.js gzip 4.59 kB N/A -
e8aec2e4-HASH.js gzip 62.6 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 256 B 253 B 🟢 3 B (-1%)
main-HASH.js gzip 39.1 kB 39.1 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
262-HASH.js gzip N/A 4.59 kB -
2889.HASH.js gzip N/A 169 B -
5602-HASH.js gzip N/A 5.55 kB -
6948ada0-HASH.js gzip N/A 62.6 kB -
9544-HASH.js gzip N/A 59.1 kB -
Total 233 kB 233 kB ⚠️ +314 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 194 B 194 B
_error-HASH.js gzip 183 B 180 B 🟢 3 B (-2%)
css-HASH.js gzip 331 B 330 B
dynamic-HASH.js gzip 1.81 kB 1.81 kB
edge-ssr-HASH.js gzip 256 B 256 B
head-HASH.js gzip 351 B 352 B
hooks-HASH.js gzip 384 B 383 B
image-HASH.js gzip 579 B 581 B
index-HASH.js gzip 260 B 260 B
link-HASH.js gzip 2.51 kB 2.5 kB
routerDirect..HASH.js gzip 320 B 319 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 315 B 315 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.97 kB ✅ -13 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 125 kB 125 kB
page.js gzip 254 kB 255 kB
Total 379 kB 379 kB ⚠️ +102 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 617 B 614 B
middleware-r..fest.js gzip 156 B 155 B
middleware.js gzip 43.6 kB 43.8 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.3 kB 45.5 kB ⚠️ +203 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 714 B 718 B
Total 714 B 718 B ⚠️ +4 B
Build Cache
Canary PR Change
0.pack gzip 4.06 MB 4.03 MB 🟢 27.2 kB (-1%)
index.pack gzip 104 kB 103 kB 🟢 1.27 kB (-1%)
index.pack.old gzip 103 kB 104 kB 🔴 +1.1 kB (+1%)
Total 4.27 MB 4.24 MB ✅ -27.3 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 321 kB 320 kB
app-page-exp..prod.js gzip 170 kB 170 kB
app-page-tur...dev.js gzip 320 kB 320 kB
app-page-tur..prod.js gzip 170 kB 170 kB
app-page-tur...dev.js gzip 317 kB 316 kB
app-page-tur..prod.js gzip 168 kB 168 kB
app-page.run...dev.js gzip 317 kB 317 kB
app-page.run..prod.js gzip 168 kB 168 kB
app-route-ex...dev.js gzip 70.8 kB 70.8 kB
app-route-ex..prod.js gzip 49.3 kB 49.2 kB
app-route-tu...dev.js gzip 70.9 kB 70.9 kB
app-route-tu..prod.js gzip 49.3 kB 49.3 kB
app-route-tu...dev.js gzip 70.5 kB 70.4 kB
app-route-tu..prod.js gzip 49 kB 49 kB
app-route.ru...dev.js gzip 70.4 kB 70.4 kB
app-route.ru..prod.js gzip 49 kB 49 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.2 kB 43.2 kB
pages-api-tu..prod.js gzip 32.9 kB 32.9 kB
pages-api.ru...dev.js gzip 43.2 kB 43.2 kB
pages-api.ru..prod.js gzip 32.9 kB 32.9 kB
pages-turbo....dev.js gzip 52.6 kB 52.6 kB
pages-turbo...prod.js gzip 38.5 kB 38.5 kB
pages.runtim...dev.js gzip 52.6 kB 52.6 kB
pages.runtim..prod.js gzip 38.5 kB 38.5 kB
server.runti..prod.js gzip 62 kB 61.9 kB
Total 2.83 MB 2.82 MB ✅ -3.81 kB
📝 Changed Files (25 files)

Files with changes:

  • app-page-exp..ntime.dev.js
  • app-page-exp..time.prod.js
  • app-page-tur..ntime.dev.js
  • app-page-tur..time.prod.js
  • app-page-tur..ntime.dev.js
  • app-page-tur..time.prod.js
  • app-page.runtime.dev.js
  • app-page.runtime.prod.js
  • app-route-ex..ntime.dev.js
  • app-route-ex..time.prod.js
  • app-route-tu..ntime.dev.js
  • app-route-tu..time.prod.js
  • app-route-tu..ntime.dev.js
  • app-route-tu..time.prod.js
  • app-route.runtime.dev.js
  • app-route.ru..time.prod.js
  • pages-api-tu..ntime.dev.js
  • pages-api-tu..time.prod.js
  • pages-api.runtime.dev.js
  • pages-api.ru..time.prod.js
  • ... and 5 more
View diffs
app-page-exp..ntime.dev.js
failed to diff
app-page-exp..time.prod.js
failed to diff
app-page-tur..ntime.dev.js
failed to diff
app-page-tur..time.prod.js
failed to diff
app-page-tur..ntime.dev.js
failed to diff
app-page-tur..time.prod.js
failed to diff
app-page.runtime.dev.js
failed to diff
app-page.runtime.prod.js
failed to diff
app-route-ex..ntime.dev.js

Diff too large to display

app-route-ex..time.prod.js

Diff too large to display

app-route-tu..ntime.dev.js

Diff too large to display

app-route-tu..time.prod.js

Diff too large to display

app-route-tu..ntime.dev.js

Diff too large to display

app-route-tu..time.prod.js

Diff too large to display

app-route.runtime.dev.js

Diff too large to display

app-route.ru..time.prod.js

Diff too large to display

pages-api-tu..ntime.dev.js

Diff too large to display

pages-api-tu..time.prod.js

Diff too large to display

pages-api.runtime.dev.js

Diff too large to display

pages-api.ru..time.prod.js

Diff too large to display

pages-turbo...ntime.dev.js

Diff too large to display

pages-turbo...time.prod.js

Diff too large to display

pages.runtime.dev.js

Diff too large to display

pages.runtime.prod.js

Diff too large to display

server.runtime.prod.js

Diff too large to display

📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/ccd1be6a7edde53c658150d795f383a1df63aabc/next

@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Feb 27, 2026

Tests Passed

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 27, 2026

Merging this PR will degrade performance by 3.09%

❌ 1 regressed benchmark
✅ 16 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation react-dom-client.development.js[full] 494.6 ms 510.4 ms -3.09%

Comparing cursor/page-extensions-regex-usage-020f (ccd1be6) with canary (ad3296b)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

cursoragent and others added 2 commits February 27, 2026 13:56
The #[serde(flatten)] on TransformOptions.swc causes unknown fields
to be passed to swc_core::base::config::Options, which rejects them.
Instead of a top-level page_extensions field, extract it from the
server_components config where it's already available via Options.

This fixes the 'unknown field pageExtensions' serde deserialization
error in the webpack SWC transform path.

Co-authored-by: Sebastian "Sebbie" Silbermann <silbermann.sebastian@gmail.com>
@eps1lon eps1lon marked this pull request as ready for review February 28, 2026 13:22
@eps1lon eps1lon requested a review from unstubbable February 28, 2026 13:44
@unstubbable unstubbable requested review from mischnic and removed request for unstubbable March 4, 2026 12:19
…ports.rs

Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
@eps1lon eps1lon requested a review from mischnic March 4, 2026 13:04
…ports.rs

Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
@eps1lon eps1lon enabled auto-merge (squash) March 4, 2026 13:12
@eps1lon eps1lon merged commit cb44b43 into canary Mar 4, 2026
288 of 291 checks passed
@eps1lon eps1lon deleted the cursor/page-extensions-regex-usage-020f branch March 4, 2026 16:13
sokra pushed a commit that referenced this pull request Mar 6, 2026
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI approved Approve running CI for fork created-by: Next.js team PRs by the Next.js team. Turbopack Related to Turbopack with Next.js. type: next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants