WIP: split app-render

parent 39f5d0f3
......@@ -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 {
entry: bundleTypes[bundleType],
target: 'node',
......@@ -183,7 +196,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
devtool: 'source-map',
optimization: {
moduleIds: 'named',
minimize: true,
minimize: false,
concatenateModules: true,
minimizer: [
new webpack.SwcJsMinimizerRspackPlugin({
......@@ -250,21 +263,13 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
layer: 'react-server',
},
{
include: /vendored[\\/]rsc[\\/]entrypoints/,
include: [
/vendored[\\/]rsc[\\/]entrypoints/,
/server[\\/]app-render[\\/]app-render.react-server/,
],
resolve: {
conditionNames: ['react-server', '...'],
alias: {
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`,
},
alias: aliasReactServer,
},
layer: 'react-server',
},
......@@ -272,12 +277,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
issuerLayer: 'react-server',
resolve: {
conditionNames: ['react-server', '...'],
alias: {
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`,
},
alias: aliasReactServer,
},
},
],
......
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({
return ''
}
// TODO: Use `prerender`?
const stream = await renderToReadableStream(
<>
{
......
......@@ -49,6 +49,14 @@ export function io(expression: string, type: ApiType) {
if (process.env.NODE_ENV !== 'production') {
const ownerStack = workUnitStore.captureOwnerStack!()
console.log(
'WORK UNIT STORE',
workUnitStore.type,
'STACK\n',
errorWithStack.stack,
'OWNER STACK\n',
ownerStack
)
if (ownerStack) {
// TODO: Instead of stitching the stacks here, we should log the
......
......@@ -111,7 +111,7 @@ module.exports = function (task) {
runtime: 'automatic',
pragmaFrag: 'React.Fragment',
throwIfNamespace: true,
development: false,
development: 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