WIP: split app-render

parent 39f5d0f3
...@@ -169,6 +169,19 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => { ...@@ -169,6 +169,19 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
}) })
: {} : {}
const aliasReactServer = {
react$: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
[`next/dist/compiled/react${bundledReactChannel}$`]: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
'react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
[`next/dist/compiled/react${bundledReactChannel}/jsx-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
'react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
[`next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
'react/compiler-runtime$': `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
[`next/dist/compiled/react${bundledReactChannel}/compiler-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
[`next/dist/compiled/react-dom${bundledReactChannel}$`]: `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
}
return { return {
entry: bundleTypes[bundleType], entry: bundleTypes[bundleType],
target: 'node', target: 'node',
...@@ -183,7 +196,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => { ...@@ -183,7 +196,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
devtool: 'source-map', devtool: 'source-map',
optimization: { optimization: {
moduleIds: 'named', moduleIds: 'named',
minimize: true, minimize: false,
concatenateModules: true, concatenateModules: true,
minimizer: [ minimizer: [
new webpack.SwcJsMinimizerRspackPlugin({ new webpack.SwcJsMinimizerRspackPlugin({
...@@ -250,21 +263,13 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => { ...@@ -250,21 +263,13 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
layer: 'react-server', layer: 'react-server',
}, },
{ {
include: /vendored[\\/]rsc[\\/]entrypoints/, include: [
/vendored[\\/]rsc[\\/]entrypoints/,
/server[\\/]app-render[\\/]app-render.react-server/,
],
resolve: { resolve: {
conditionNames: ['react-server', '...'], conditionNames: ['react-server', '...'],
alias: { alias: aliasReactServer,
react$: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
[`next/dist/compiled/react${bundledReactChannel}$`]: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
'react/jsx-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
[`next/dist/compiled/react${bundledReactChannel}/jsx-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/jsx-runtime.react-server`,
'react/jsx-dev-runtime$': `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
[`next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/jsx-dev-runtime.react-server`,
'react/compiler-runtime$': `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
[`next/dist/compiled/react${bundledReactChannel}/compiler-runtime$`]: `next/dist/compiled/react${bundledReactChannel}/compiler-runtime`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
[`next/dist/compiled/react-dom${bundledReactChannel}$`]: `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
},
}, },
layer: 'react-server', layer: 'react-server',
}, },
...@@ -272,12 +277,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => { ...@@ -272,12 +277,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
issuerLayer: 'react-server', issuerLayer: 'react-server',
resolve: { resolve: {
conditionNames: ['react-server', '...'], conditionNames: ['react-server', '...'],
alias: { alias: aliasReactServer,
react$: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
[`next/dist/compiled/react${bundledReactChannel}$`]: `next/dist/compiled/react${bundledReactChannel}/react.react-server`,
'react-dom$': `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
[`next/dist/compiled/react-dom${bundledReactChannel}$`]: `next/dist/compiled/react-dom${bundledReactChannel}/react-dom.react-server`,
},
}, },
}, },
], ],
......
import type { LoaderTree } from '../lib/app-dir-module'
import type { Params } from '../request/params'
import type { GetDynamicParamFromSegment } from './app-render'
import { parseLoaderTree } from './parse-loader-tree'
export function getRootParams(
loaderTree: LoaderTree,
getDynamicParamFromSegment: GetDynamicParamFromSegment
): Params {
return getRootParamsImpl({}, loaderTree, getDynamicParamFromSegment)
}
function getRootParamsImpl(
parentParams: Params,
loaderTree: LoaderTree,
getDynamicParamFromSegment: GetDynamicParamFromSegment
): Params {
const {
segment,
modules: { layout },
parallelRoutes,
} = parseLoaderTree(loaderTree)
const segmentParam = getDynamicParamFromSegment(segment)
let currentParams: Params = parentParams
if (segmentParam && segmentParam.value !== null) {
currentParams = {
...parentParams,
[segmentParam.param]: segmentParam.value,
}
}
const isRootLayout = typeof layout !== 'undefined'
if (isRootLayout) {
return currentParams
} else if (!parallelRoutes.children) {
// This should really be an error but there are bugs in Turbopack that cause
// the _not-found LoaderTree to not have any layouts. For rootParams sake
// this is somewhat irrelevant when you are not customizing the 404 page.
// If you are customizing 404
// TODO update rootParams to make all params optional if `/app/not-found.tsx` is defined
return currentParams
} else {
return getRootParamsImpl(
currentParams,
// We stop looking for root params as soon as we hit the first layout and
// it is not possible to use parallel route children above the root layout
// so every parallelRoutes object that this function can visit will
// necessarily have a single `children` prop and no others.
parallelRoutes.children,
getDynamicParamFromSegment
)
}
}
...@@ -87,6 +87,7 @@ export function makeGetServerInsertedHTML({ ...@@ -87,6 +87,7 @@ export function makeGetServerInsertedHTML({
return '' return ''
} }
// TODO: Use `prerender`?
const stream = await renderToReadableStream( const stream = await renderToReadableStream(
<> <>
{ {
......
...@@ -49,6 +49,14 @@ export function io(expression: string, type: ApiType) { ...@@ -49,6 +49,14 @@ export function io(expression: string, type: ApiType) {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
const ownerStack = workUnitStore.captureOwnerStack!() const ownerStack = workUnitStore.captureOwnerStack!()
console.log(
'WORK UNIT STORE',
workUnitStore.type,
'STACK\n',
errorWithStack.stack,
'OWNER STACK\n',
ownerStack
)
if (ownerStack) { if (ownerStack) {
// TODO: Instead of stitching the stacks here, we should log the // TODO: Instead of stitching the stacks here, we should log the
......
...@@ -111,7 +111,7 @@ module.exports = function (task) { ...@@ -111,7 +111,7 @@ module.exports = function (task) {
runtime: 'automatic', runtime: 'automatic',
pragmaFrag: 'React.Fragment', pragmaFrag: 'React.Fragment',
throwIfNamespace: true, throwIfNamespace: true,
development: false, development: true,
useBuiltins: true, useBuiltins: true,
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment