Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/next-core/src/base_loader_tree.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use indoc::formatdoc;
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, ResolvedVc, ValueToString, Vc};
use turbo_tasks::{FxIndexMap, ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack::{ModuleAssetContext, transition::Transition};
use turbopack_core::{
Expand Down Expand Up @@ -115,7 +115,10 @@ impl BaseLoaderTreeBuilder {
self.inner_assets
.insert(format!("MODULE_{i}").into(), module);

let module_path = module.ident().path().to_string().await?;
// Use the original source path, not the transformed module path.
// This is important for MDX files where page.mdx becomes page.mdx.tsx after
// transformation, but the font manifest uses the original source path.
let module_path = path.value_to_string().await?;

Ok(format!(
"[{identifier}, {path}]",
Expand Down
12 changes: 11 additions & 1 deletion crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,13 @@ mod tests {
"browser",
{
"path": { "type": "glob", "value": "*.svg"},
"query": {
"type": "regex",
"value": {
"source": "@someQuery",
"flags": ""
}
},
"content": {
"source": "@someTag",
"flags": ""
Expand Down Expand Up @@ -2140,7 +2147,10 @@ mod tests {
source: rcstr!("@someTag"),
flags: rcstr!(""),
}),
query: None,
query: Some(ConfigConditionQuery::Regex(RegexComponents {
source: rcstr!("@someQuery"),
flags: rcstr!(""),
})),
},
]
.into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,12 @@ async fn build_manifest(

// per layout segment chunks need to be emitted into the manifest too
for (server_component, client_assets) in layout_segment_client_chunks.iter() {
// Use source_path() to get the original source path (e.g., page.mdx) instead of
// server_path() which returns the transformed path (e.g., page.mdx.tsx).
// This ensures the manifest key matches what the LoaderTree stores and what
// the runtime looks up after stripping one extension.
let server_component_name = server_component
.server_path()
.source_path()
.await?
.with_extension("")
.value_to_string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,35 @@ use super::server_component_reference::NextServerComponentModuleReference;
#[turbo_tasks::value(shared)]
pub struct NextServerComponentModule {
pub module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
/// The original source path before any transformations (e.g., page.mdx before it becomes
/// page.mdx.tsx). This is used to generate consistent manifest keys that match what the
/// LoaderTree stores.
source_path: FileSystemPath,
}

#[turbo_tasks::value_impl]
impl NextServerComponentModule {
#[turbo_tasks::function]
pub fn new(module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>) -> Vc<Self> {
NextServerComponentModule { module }.cell()
pub fn new(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
source_path: FileSystemPath,
) -> Vc<Self> {
NextServerComponentModule {
module,
source_path,
}
.cell()
}

/// Returns the original source path (before transformations like MDX -> MDX.tsx).
/// Use this for manifest key generation to match the LoaderTree paths.
#[turbo_tasks::function]
pub fn source_path(&self) -> Vc<FileSystemPath> {
self.source_path.clone().cell()
}

/// Returns the transformed module path (e.g., page.mdx.tsx for MDX files).
/// This is the path of the actual compiled module.
#[turbo_tasks::function]
pub fn server_path(&self) -> Vc<FileSystemPath> {
self.module.ident().path()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use anyhow::{Result, bail};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack::{ModuleAssetContext, transition::Transition};
use turbopack_core::module::Module;
use turbopack_core::{
context::{AssetContext, ProcessResult},
reference_type::ReferenceType,
source::Source,
};
use turbopack_ecmascript::chunk::EcmascriptChunkPlaceable;

use super::server_component_module::NextServerComponentModule;
Expand All @@ -26,18 +30,40 @@ impl NextServerComponentTransition {

#[turbo_tasks::value_impl]
impl Transition for NextServerComponentTransition {
/// Override process to capture the original source path before transformation.
/// This is important for MDX files where page.mdx becomes page.mdx.tsx after
/// transformation, but we need the original path for manifest key generation.
#[turbo_tasks::function]
async fn process_module(
async fn process(
self: Vc<Self>,
module: Vc<Box<dyn Module>>,
_context: Vc<ModuleAssetContext>,
) -> Result<Vc<Box<dyn Module>>> {
let Some(module) =
Vc::try_resolve_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(module).await?
else {
bail!("not an ecmascript module");
};

Ok(Vc::upcast(NextServerComponentModule::new(module)))
source: Vc<Box<dyn Source>>,
module_asset_context: Vc<ModuleAssetContext>,
reference_type: ReferenceType,
) -> Result<Vc<ProcessResult>> {
// Capture the original source path before any transformation
let source_path = source.ident().path().owned().await?;

let source = self.process_source(source);
let module_asset_context = self.process_context(module_asset_context);

Ok(
match &*module_asset_context.process(source, reference_type).await? {
ProcessResult::Module(module) => {
let Some(module) =
ResolvedVc::try_sidecast::<Box<dyn EcmascriptChunkPlaceable>>(*module)
else {
bail!("not an ecmascript module");
};

// Create the server component module with the original source path
let server_component = NextServerComponentModule::new(*module, source_path);

ProcessResult::Module(ResolvedVc::upcast(server_component.to_resolved().await?))
.cell()
}
ProcessResult::Unknown(source) => ProcessResult::Unknown(*source).cell(),
ProcessResult::Ignore => ProcessResult::Ignore.cell(),
},
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ module.exports = {
{
any: [
{ path: '*.svg' },
// 'query' matches anywhere in the full query string,
// which can be empty, or start with `?`.
{ query: /[?&]svgr(?=&|$)/ },
// 'content' is always a RegExp, and can match
// anywhere in the file.
{ content: /\<svg\W/ },
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "16.2.0-canary.1"
"version": "16.2.0-canary.3"
}
17 changes: 15 additions & 2 deletions packages/create-next-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,18 @@ async function run(): Promise<void> {
conf.set('preferences', preferences)
}

const update = updateCheck(packageJson).catch(() => null)
// Determine the appropriate dist-tag to check for updates.
// For prerelease versions like "16.1.1-canary.32", extract "canary" and check
// against that dist-tag. This ensures canary users are notified about newer
// canary releases, not incorrectly prompted to "update" to stable.
function getDistTag(version: string): string {
const prereleaseMatch = version.match(/-([a-z]+)/)
return prereleaseMatch ? prereleaseMatch[1] : 'latest'
}

const update = updateCheck(packageJson, {
distTag: getDistTag(packageJson.version),
}).catch(() => null)

async function notifyUpdate(): Promise<void> {
try {
Expand All @@ -667,7 +678,9 @@ async function notifyUpdate(): Promise<void> {
pnpm: 'pnpm add -g',
bun: 'bun add -g',
}
const updateMessage = `${global[packageManager]} create-next-app`
const distTag = getDistTag(packageJson.version)
const pkgTag = distTag === 'latest' ? '' : `@${distTag}`
const updateMessage = `${global[packageManager]} create-next-app${pkgTag}`
console.log(
yellow(bold('A new version of `create-next-app` is available!')) +
'\n' +
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "ESLint configuration used by Next.js.",
"license": "MIT",
"repository": {
Expand All @@ -12,7 +12,7 @@
"dist"
],
"dependencies": {
"@next/eslint-plugin-next": "16.2.0-canary.1",
"@next/eslint-plugin-next": "16.2.0-canary.3",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.32.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next/eslint-plugin-internal",
"private": true,
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "ESLint plugin for working on Next.js.",
"exports": {
".": "./src/eslint-plugin-internal.js"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next/font",
"private": true,
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-routing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/routing",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-rspack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-rspack",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-rspack"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"private": true,
"files": [
"native/"
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "16.2.0-canary.1",
"version": "16.2.0-canary.3",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -97,7 +97,7 @@
]
},
"dependencies": {
"@next/env": "16.2.0-canary.1",
"@next/env": "16.2.0-canary.3",
"@swc/helpers": "0.5.15",
"baseline-browser-mapping": "^2.8.3",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -162,11 +162,11 @@
"@modelcontextprotocol/sdk": "1.18.1",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/font": "16.2.0-canary.1",
"@next/polyfill-module": "16.2.0-canary.1",
"@next/polyfill-nomodule": "16.2.0-canary.1",
"@next/react-refresh-utils": "16.2.0-canary.1",
"@next/swc": "16.2.0-canary.1",
"@next/font": "16.2.0-canary.3",
"@next/polyfill-module": "16.2.0-canary.3",
"@next/polyfill-nomodule": "16.2.0-canary.3",
"@next/react-refresh-utils": "16.2.0-canary.3",
"@next/swc": "16.2.0-canary.3",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.51.1",
"@rspack/core": "1.6.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/build/templates/app-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ export async function handler(
page: normalizedSrcPage,
sharedContext: {
buildId,
deploymentId,
},
serverComponentsHmrCache: getRequestMeta(
req,
Expand Down Expand Up @@ -659,7 +660,6 @@ export async function handler(
trailingSlash: nextConfig.trailingSlash,
images: nextConfig.images,
previewProps: prerenderManifest.preview,
deploymentId: deploymentId,
enableTainting: nextConfig.experimental.taint,
htmlLimitedBots: nextConfig.htmlLimitedBots,
reactMaxHeadersLength: nextConfig.reactMaxHeadersLength,
Expand Down
Loading
Loading