Use page extensions in next-swc transforms applying to pages#90650
Use page extensions in next-swc transforms applying to pages#90650
Conversation
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 Agent can help with this pull request. Just |
…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>
Stats from current PR🟢 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles: **401 kB** → **401 kB** ✅ -430 B80 files with content-based hashes (individual files not comparable between builds) Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (25 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsfailed to diffapp-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page.runtime.dev.jsfailed to diffapp-page.runtime.prod.jsfailed to diffapp-route-ex..ntime.dev.jsDiff too large to display app-route-ex..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route.runtime.dev.jsDiff too large to display app-route.ru..time.prod.jsDiff too large to display pages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display 📎 Tarball URL |
Tests Passed |
Merging this PR will degrade performance by 3.09%
Performance Changes
Comparing Footnotes
|
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>
crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs
Outdated
Show resolved
Hide resolved
…ports.rs Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
crates/next-core/src/next_shared/transforms/next_strip_page_exports.rs
Outdated
Show resolved
Hide resolved
…ports.rs Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
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>
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.pageExtensionsto consider modules consistently as pages.This pull request contains changes generated by a Cursor Cloud Agent