Skip to content

Commit 8bec259

Browse files
committed
Add support for react-markup behind experimental.reactMarkup flag
1 parent c442986 commit 8bec259

31 files changed

+35560
-5
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
"react-dom-experimental-builtin": "npm:[email protected]",
216216
"react-experimental-builtin": "npm:[email protected]",
217217
"react-is-builtin": "npm:[email protected]",
218+
"react-markup-experimental-builtin": "npm:[email protected]",
218219
"react-server-dom-turbopack": "19.0.0-rc-1eaccd82-20240816",
219220
"react-server-dom-turbopack-experimental": "npm:[email protected]",
220221
"react-server-dom-webpack": "19.0.0-rc-1eaccd82-20240816",

packages/next/src/build/create-compiler-aliases.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ export function createRSCAliases(
272272
// optimizations to ignore the legacy build of react-dom/server in `server.browser` build
273273
'react-dom/server.edge$': `next/dist/build/webpack/alias/react-dom-server-edge${bundledReactChannel}.js`,
274274
'react-dom/server.browser$': `next/dist/build/webpack/alias/react-dom-server-browser${bundledReactChannel}.js`,
275+
'react-markup$': `next/dist/compiled/react-markup${bundledReactChannel}`,
275276
// react-server-dom-webpack alias
276277
...createRSCRendererAliases(bundledReactChannel),
277278
}
@@ -284,6 +285,7 @@ export function createRSCAliases(
284285
'react/compiler-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-compiler-runtime`,
285286
react$: `next/dist/server/route-modules/app-page/vendored/${layer}/react`,
286287
'react-dom$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-dom`,
288+
'react-markup$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-markup`,
287289
'react-server-dom-webpack/client.edge$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-client-edge`,
288290
})
289291
} else if (layer === WEBPACK_LAYERS.reactServerComponents) {
@@ -293,6 +295,7 @@ export function createRSCAliases(
293295
'react/compiler-runtime$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-compiler-runtime`,
294296
react$: `next/dist/server/route-modules/app-page/vendored/${layer}/react`,
295297
'react-dom$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-dom`,
298+
'react-markup$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-markup`,
296299
'react-server-dom-webpack/server.edge$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-edge`,
297300
'react-server-dom-webpack/server.node$': `next/dist/server/route-modules/app-page/vendored/${layer}/react-server-dom-webpack-server-node`,
298301
})
@@ -315,6 +318,9 @@ export function createRSCAliases(
315318
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
316319
'next/dist/compiled/react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
317320
'next/dist/compiled/react-dom-experimental$': `next/dist/compiled/react-dom-experimental/react-dom.react-server`,
321+
'react-markup$': `next/dist/compiled/react-markup${bundledReactChannel}/react-markup.react-server`,
322+
'next/dist/compiled/react-markup$': `next/dist/compiled/react-markup${bundledReactChannel}/react-markup.react-server`,
323+
'next/dist/compiled/react-markup-experimental$': `next/dist/compiled/react-markup-experimental/react-markup.react-server`,
318324
})
319325
}
320326
}

packages/next/src/build/handle-externals.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
} from './webpack-config'
1313
import { isWebpackBundledLayer, isWebpackServerOnlyLayer } from './utils'
1414
import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep'
15-
const reactPackagesRegex = /^(react|react-dom|react-server-dom-webpack)($|\/)/
15+
const reactPackagesRegex =
16+
/^(react|react-dom|react-markup|react-server-dom-webpack)($|\/)/
1617

1718
const pathSeparators = '[/\\\\]'
1819
const optionalEsmPart = `((${pathSeparators}esm)?${pathSeparators})`

packages/next/src/build/webpack-config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const browserNonTranspileModules = [
126126
/[\\/]node_modules[\\/]process[\\/]browser/,
127127
// Exclude precompiled react packages from browser compilation due to SWC helper insertion (#61791),
128128
// We fixed the issue but it's safer to exclude them from compilation since they don't need to be re-compiled.
129-
/[\\/]next[\\/]dist[\\/]compiled[\\/](react|react-dom|react-server-dom-webpack)(-experimental)?($|[\\/])/,
129+
/[\\/]next[\\/]dist[\\/]compiled[\\/](react|react-dom|react-markup|react-server-dom-webpack)(-experimental)?($|[\\/])/,
130130
]
131131
const precompileRegex = /[\\/]next[\\/]dist[\\/]compiled[\\/]/
132132

@@ -777,10 +777,12 @@ export default async function getBaseWebpackConfig(
777777
for (const packageName of [
778778
'react',
779779
'react-dom',
780+
'react-markup',
780781
...(hasAppDir
781782
? [
782783
`next/dist/compiled/react${bundledReactChannel}`,
783784
`next/dist/compiled/react-dom${bundledReactChannel}`,
785+
`next/dist/compiled/react-markup${bundledReactChannel}`,
784786
]
785787
: []),
786788
]) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Meta Platforms, Inc. and affiliates.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)