Unverified Commit b0f87fbc authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Bundle ssr client layer excepts react externals (#41606)

Bundle the ssr client layer for RSC, this solves the problem when
there's an esm package is using on client components, but esm imports
the installed react instead of the built-in react version since esm
imports is not intercepted by require hook.

After bundling the ssr client layer and treating react as externals, now
react compiles as cjs externals and could be intercepted by require
hook, other code are bundled together which can also get optimized.

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see `contributing.md`
Co-authored-by: 's avatarShu Ding <g@shud.in>
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 73499e4b
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
"lint-staged": "lint-staged", "lint-staged": "lint-staged",
"next-with-deps": "./scripts/next-with-deps.sh", "next-with-deps": "./scripts/next-with-deps.sh",
"next": "node --trace-deprecation --enable-source-maps packages/next/dist/bin/next", "next": "node --trace-deprecation --enable-source-maps packages/next/dist/bin/next",
"next-react-exp": "__NEXT_REACT_CHANNEL=exp node --trace-deprecation --enable-source-maps -r ./test/lib/react-channel-require-hook.js packages/next/dist/bin/next",
"next-no-sourcemaps": "node --trace-deprecation packages/next/dist/bin/next", "next-no-sourcemaps": "node --trace-deprecation packages/next/dist/bin/next",
"clean-trace-jaeger": "rm -rf test/integration/basic/.next && TRACE_TARGET=JAEGER node --trace-deprecation --enable-source-maps packages/next/dist/bin/next build test/integration/basic", "clean-trace-jaeger": "rm -rf test/integration/basic/.next && TRACE_TARGET=JAEGER node --trace-deprecation --enable-source-maps packages/next/dist/bin/next build test/integration/basic",
"debug": "node --inspect packages/next/dist/bin/next", "debug": "node --inspect packages/next/dist/bin/next",
...@@ -179,10 +178,10 @@ ...@@ -179,10 +178,10 @@
"random-seed": "0.3.0", "random-seed": "0.3.0",
"react": "18.2.0", "react": "18.2.0",
"react-17": "npm:react@17.0.2", "react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@0.0.0-experimental-9cdf8a99e-20221018",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2", "react-dom-17": "npm:react-dom@17.0.2",
"react-exp": "npm:react@0.0.0-experimental-9cdf8a99e-20221018", "react-dom-builtin": "npm:react-dom@0.0.0-experimental-9cdf8a99e-20221018",
"react-dom-exp": "npm:react-dom@0.0.0-experimental-9cdf8a99e-20221018",
"react-server-dom-webpack": "0.0.0-experimental-9cdf8a99e-20221018", "react-server-dom-webpack": "0.0.0-experimental-9cdf8a99e-20221018",
"react-ssr-prepass": "1.0.8", "react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3", "react-virtualized": "9.22.3",
...@@ -198,6 +197,7 @@ ...@@ -198,6 +197,7 @@
"shell-quote": "1.7.3", "shell-quote": "1.7.3",
"styled-components": "5.3.3", "styled-components": "5.3.3",
"styled-jsx-plugin-postcss": "3.0.2", "styled-jsx-plugin-postcss": "3.0.2",
"swr": "2.0.0-rc.0",
"tailwindcss": "1.1.3", "tailwindcss": "1.1.3",
"taskr": "1.1.0", "taskr": "1.1.0",
"tree-kill": "1.2.2", "tree-kill": "1.2.2",
......
...@@ -207,7 +207,7 @@ export function getEdgeServerEntry(opts: { ...@@ -207,7 +207,7 @@ export function getEdgeServerEntry(opts: {
// The Edge bundle includes the server in its entrypoint, so it has to // The Edge bundle includes the server in its entrypoint, so it has to
// be in the SSR layer — we later convert the page request to the RSC layer // be in the SSR layer — we later convert the page request to the RSC layer
// via a webpack rule. // via a webpack rule.
layer: undefined, layer: WEBPACK_LAYERS.client,
} }
} }
......
...@@ -120,7 +120,6 @@ import { RemotePattern } from '../shared/lib/image-config' ...@@ -120,7 +120,6 @@ import { RemotePattern } from '../shared/lib/image-config'
import { eventSwcPlugins } from '../telemetry/events/swc-plugins' import { eventSwcPlugins } from '../telemetry/events/swc-plugins'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
import { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin' import { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin'
import { verifyAppReactVersion } from '../lib/verifyAppReactVersion'
export type SsgRoute = { export type SsgRoute = {
initialRevalidateSeconds: number | false initialRevalidateSeconds: number | false
...@@ -307,10 +306,6 @@ export default async function build( ...@@ -307,10 +306,6 @@ export default async function build(
process.env.NEXT_PREBUNDLED_REACT = '1' process.env.NEXT_PREBUNDLED_REACT = '1'
} }
const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled) const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled)
if (isAppDirEnabled) {
await verifyAppReactVersion({ dir })
}
const hasPublicDir = await fileExists(publicDir) const hasPublicDir = await fileExists(publicDir)
telemetry.record( telemetry.record(
......
This diff is collapsed.
...@@ -67,6 +67,7 @@ export class FlightClientEntryPlugin { ...@@ -67,6 +67,7 @@ export class FlightClientEntryPlugin {
compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => { compiler.hooks.afterCompile.tap(PLUGIN_NAME, (compilation) => {
traverseModules(compilation, (mod) => { traverseModules(compilation, (mod) => {
// const modId = compilation.chunkGraph.getModuleId(mod) + ''
// The module must has request, and resource so it's not a new entry created with loader. // The module must has request, and resource so it's not a new entry created with loader.
// Using the client layer module, which doesn't have `rsc` tag in buildInfo. // Using the client layer module, which doesn't have `rsc` tag in buildInfo.
if (mod.request && mod.resource && !mod.buildInfo.rsc) { if (mod.request && mod.resource && !mod.buildInfo.rsc) {
...@@ -76,17 +77,17 @@ export class FlightClientEntryPlugin { ...@@ -76,17 +77,17 @@ export class FlightClientEntryPlugin {
} }
}) })
const recordModule = (id: number | string, mod: any) => { const recordModule = (modId: string, mod: any) => {
const modResource = mod.resourceResolveData?.path || mod.resource const modResource = mod.resourceResolveData?.path || mod.resource
if ( if (
mod.resourceResolveData?.context?.issuerLayer === mod.resourceResolveData?.context?.issuerLayer !==
WEBPACK_LAYERS.server WEBPACK_LAYERS.client
) { ) {
return return
} }
if (typeof id !== 'undefined' && modResource) { if (typeof modId !== 'undefined' && modResource) {
// Note that this isn't that reliable as webpack is still possible to assign // Note that this isn't that reliable as webpack is still possible to assign
// additional queries to make sure there's no conflict even using the `named` // additional queries to make sure there's no conflict even using the `named`
// module ID strategy. // module ID strategy.
...@@ -99,16 +100,16 @@ export class FlightClientEntryPlugin { ...@@ -99,16 +100,16 @@ export class FlightClientEntryPlugin {
if (this.isEdgeServer) { if (this.isEdgeServer) {
edgeServerModuleIds.set( edgeServerModuleIds.set(
ssrNamedModuleId.replace(/\/next\/dist\/esm\//, '/next/dist/'), ssrNamedModuleId.replace(/\/next\/dist\/esm\//, '/next/dist/'),
id modId
) )
} else { } else {
serverModuleIds.set(ssrNamedModuleId, id) serverModuleIds.set(ssrNamedModuleId, modId)
} }
} }
} }
traverseModules(compilation, (mod, _chunk, _chunkGroup, modId) => { traverseModules(compilation, (mod, _chunk, _chunkGroup, modId) => {
recordModule(modId, mod) recordModule(modId + '', mod)
}) })
}) })
} }
...@@ -230,9 +231,10 @@ export class FlightClientEntryPlugin { ...@@ -230,9 +231,10 @@ export class FlightClientEntryPlugin {
function collectModule(entryName: string, mod: any) { function collectModule(entryName: string, mod: any) {
const resource = mod.resource const resource = mod.resource
if (resource) { const modId = resource // compilation.chunkGraph.getModuleId(mod) + ''
if (regexCSS.test(resource)) { if (modId) {
cssImportsForChunk[entryName].push(resource) if (regexCSS.test(modId)) {
cssImportsForChunk[entryName].push(modId)
} }
} }
} }
...@@ -348,18 +350,20 @@ export class FlightClientEntryPlugin { ...@@ -348,18 +350,20 @@ export class FlightClientEntryPlugin {
// native or installed js module: -> raw request, e.g. next/head // native or installed js module: -> raw request, e.g. next/head
// client js or css: -> user request // client js or css: -> user request
const rawRequest = mod.rawRequest const rawRequest = mod.rawRequest
// Request could be undefined or '' // Request could be undefined or ''
if (!rawRequest) return if (!rawRequest) return
const isCSS = regexCSS.test(rawRequest) const isCSS = regexCSS.test(rawRequest)
const modRequest: string | undefined = const isLocal =
!isCSS && !isCSS &&
!rawRequest.startsWith('.') && !rawRequest.startsWith('.') &&
!rawRequest.startsWith('/') && !rawRequest.startsWith('/') &&
!rawRequest.startsWith(APP_DIR_ALIAS) !rawRequest.startsWith(APP_DIR_ALIAS)
? rawRequest
: mod.resourceResolveData?.path + mod.resourceResolveData?.query const modRequest: string | undefined = isLocal
? rawRequest // compilation.chunkGraph.getModuleId(mod) + ''
: mod.resourceResolveData?.path + mod.resourceResolveData?.query
// console.log('modId:after', modRequest)
// Ensure module is not walked again if it's already been visited // Ensure module is not walked again if it's already been visited
if (!visitedBySegment[layoutOrPageRequest]) { if (!visitedBySegment[layoutOrPageRequest]) {
...@@ -501,9 +505,9 @@ export class FlightClientEntryPlugin { ...@@ -501,9 +505,9 @@ export class FlightClientEntryPlugin {
{ {
// By using the same entry name // By using the same entry name
name: entryName, name: entryName,
// Layer should be undefined for the SSR modules // Layer should be client for the SSR modules
// This ensures the client components are // This ensures the client components are bundled on client layer
layer: undefined, layer: WEBPACK_LAYERS.client,
} }
) )
......
...@@ -186,6 +186,8 @@ export class FlightManifestPlugin { ...@@ -186,6 +186,8 @@ export class FlightManifestPlugin {
context, context,
mod.resourceResolveData?.path || resource mod.resourceResolveData?.path || resource
) )
// if (resource.includes('script'))
// console.log('ssrNamedModuleId', ssrNamedModuleId, modId)
if (!ssrNamedModuleId.startsWith('.')) if (!ssrNamedModuleId.startsWith('.'))
// TODO use getModuleId instead // TODO use getModuleId instead
ssrNamedModuleId = `./${ssrNamedModuleId.replace(/\\/g, '/')}` ssrNamedModuleId = `./${ssrNamedModuleId.replace(/\\/g, '/')}`
...@@ -317,7 +319,7 @@ export class FlightManifestPlugin { ...@@ -317,7 +319,7 @@ export class FlightManifestPlugin {
// TODO: Update type so that it doesn't have to be cast. // TODO: Update type so that it doesn't have to be cast.
) as Iterable<webpack.NormalModule> ) as Iterable<webpack.NormalModule>
for (const mod of chunkModules) { for (const mod of chunkModules) {
const modId = compilation.chunkGraph.getModuleId(mod) const modId: string = compilation.chunkGraph.getModuleId(mod) + ''
recordModule(chunk, modId, mod) recordModule(chunk, modId, mod)
......
...@@ -45,7 +45,6 @@ export function loadRequireHook(aliases: [string, string][] = []) { ...@@ -45,7 +45,6 @@ export function loadRequireHook(aliases: [string, string][] = []) {
} }
export function overrideBuiltInReactPackages() { export function overrideBuiltInReactPackages() {
/*
setRequireOverrides([ setRequireOverrides([
['react', require.resolve('next/dist/compiled/react')], ['react', require.resolve('next/dist/compiled/react')],
[ [
...@@ -73,5 +72,4 @@ export function overrideBuiltInReactPackages() { ...@@ -73,5 +72,4 @@ export function overrideBuiltInReactPackages() {
require.resolve('next/dist/compiled/react-dom/server.browser'), require.resolve('next/dist/compiled/react-dom/server.browser'),
], ],
]) ])
*/
} }
...@@ -259,7 +259,7 @@ function Script(props: ScriptProps): JSX.Element | null { ...@@ -259,7 +259,7 @@ function Script(props: ScriptProps): JSX.Element | null {
// For the app directory, we need React Float to preload these scripts. // For the app directory, we need React Float to preload these scripts.
if (appDir) { if (appDir) {
// Before interactive scripts need to be loaded by Next.js' runtime instead // Before interactive scripts need to be loaded by Next.js' runtime instead
// of native <script> tags, becasue they no longer have `defer`. // of native <script> tags, because they no longer have `defer`.
if (strategy === 'beforeInteractive') { if (strategy === 'beforeInteractive') {
if (!src) { if (!src) {
// For inlined scripts, we put the content in `children`. // For inlined scripts, we put the content in `children`.
......
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/**
* @license React
* react-dom-server-rendering-stub.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
if (process.env.NODE_ENV !== "production") {
(function() {
'use strict';
var ReactVersion = '18.3.0-experimental-9cdf8a99e-20221018';
var Internals = {
usingClientEntryPoint: false,
Events: null,
Dispatcher: {
current: null
}
};
function createPortal() {
throw new Error('createPortal was called on the server. Portals are not currently' + ' supported on the server. Update your program to conditionally call' + ' createPortal on the client only.');
}
function flushSync() {
throw new Error('flushSync was called on the server. This is likely caused by a' + ' function being called during render or in module scope that was' + ' intended to be called from an effect or event handler. Update your' + ' to not call flushSync no the server.');
}
function preinit() {
var dispatcher = Internals.Dispatcher.current;
if (dispatcher) {
dispatcher.preinit.apply(this, arguments);
} // We don't error because preinit needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
function preload() {
var dispatcher = Internals.Dispatcher.current;
if (dispatcher) {
dispatcher.preload.apply(this, arguments);
} // We don't error because preload needs to be resilient to being called in a variety of scopes
// and the runtime may not be capable of responding. The function is optimistic and not critical
// so we favor silent bailout over warning or erroring.
}
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
exports.createPortal = createPortal;
exports.flushSync = flushSync;
exports.preinit = preinit;
exports.preload = preload;
exports.version = ReactVersion;
})();
}
/**
* @license React
* react-dom-server-rendering-stub.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var b={usingClientEntryPoint:!1,Events:null,Dispatcher:{current:null}};function d(a){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)e+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=b;
exports.createPortal=function(){throw Error(d(448));};exports.flushSync=function(){throw Error(d(449));};exports.preinit=function(){var a=b.Dispatcher.current;a&&a.preinit.apply(this,arguments)};exports.preload=function(){var a=b.Dispatcher.current;a&&a.preload.apply(this,arguments)};exports.version="18.3.0-experimental-9cdf8a99e-20221018";
This diff is collapsed.
'use strict';
var m = require('react-dom');
if (process.env.NODE_ENV === 'production') {
exports.createRoot = m.createRoot;
exports.hydrateRoot = m.hydrateRoot;
} else {
var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
exports.createRoot = function(c, o) {
i.usingClientEntryPoint = true;
try {
return m.createRoot(c, o);
} finally {
i.usingClientEntryPoint = false;
}
};
exports.hydrateRoot = function(c, h, o) {
i.usingClientEntryPoint = true;
try {
return m.hydrateRoot(c, h, o);
} finally {
i.usingClientEntryPoint = false;
}
};
}
'use strict';
function checkDCE() {
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'
) {
return;
}
if (process.env.NODE_ENV !== 'production') {
// This branch is unreachable because this function is only called
// in production, but the condition is true only in development.
// Therefore if the branch is still here, dead code elimination wasn't
// properly applied.
// Don't change the message. React DevTools relies on it. Also make sure
// this message doesn't occur elsewhere in this function, or it will cause
// a false positive.
throw new Error('^_^');
}
try {
// Verify that the code above has been dead code eliminated (DCE'd).
__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
} catch (err) {
// DevTools shouldn't crash React, no matter what.
// We should still report in case we break this code.
console.error(err);
}
}
if (process.env.NODE_ENV === 'production') {
// DCE check should happen before ReactDOM bundle executes so that
// DevTools can report bad minification during injection.
checkDCE();
module.exports = require('./cjs/react-dom.production.min.js');
} else {
module.exports = require('./cjs/react-dom.development.js');
}
{
"name": "react-dom",
"version": "0.0.0-experimental-9cdf8a99e-20221018",
"description": "React package for working with the DOM.",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react-dom"
},
"keywords": [
"react"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://reactjs.org/",
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "0.0.0-experimental-9cdf8a99e-20221018"
},
"peerDependencies": {
"react": "0.0.0-experimental-9cdf8a99e-20221018"
},
"files": [
"LICENSE",
"README.md",
"index.js",
"client.js",
"profiling.js",
"server.js",
"server.browser.js",
"server.node.js",
"static.js",
"static.browser.js",
"static.node.js",
"server-rendering-stub.js",
"test-utils.js",
"unstable_testing.js",
"unstable_server-external-runtime.js",
"cjs/",
"umd/"
],
"exports": {
".": "./index.js",
"./client": "./client.js",
"./server": {
"deno": "./server.browser.js",
"worker": "./server.browser.js",
"browser": "./server.browser.js",
"default": "./server.node.js"
},
"./server.browser": "./server.browser.js",
"./server.node": "./server.node.js",
"./static": {
"deno": "./static.browser.js",
"worker": "./static.browser.js",
"browser": "./static.browser.js",
"default": "./static.node.js"
},
"./static.browser": "./static.browser.js",
"./static.node": "./static.node.js",
"./server-rendering-stub": "./server-rendering-stub.js",
"./profiling": "./profiling.js",
"./test-utils": "./test-utils.js",
"./unstable_testing": "./unstable_testing.js",
"./package.json": "./package.json"
},
"browser": {
"./server.js": "./server.browser.js",
"./static.js": "./static.browser.js"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}
\ No newline at end of file
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-dom-server-rendering-stub.production.min.js');
} else {
module.exports = require('./cjs/react-dom-server-rendering-stub.development.js');
}
'use strict';
var l, s;
if (process.env.NODE_ENV === 'production') {
l = require('./cjs/react-dom-server-legacy.browser.production.min.js');
s = require('./cjs/react-dom-server.browser.production.min.js');
} else {
l = require('./cjs/react-dom-server-legacy.browser.development.js');
s = require('./cjs/react-dom-server.browser.development.js');
}
exports.version = l.version;
exports.renderToString = l.renderToString;
exports.renderToStaticMarkup = l.renderToStaticMarkup;
exports.renderToNodeStream = l.renderToNodeStream;
exports.renderToStaticNodeStream = l.renderToStaticNodeStream;
exports.renderToReadableStream = s.renderToReadableStream;
'use strict';
module.exports = require('./server.node');
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
/**
* @license React
* react-jsx-dev-runtime.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var a=Symbol.for("react.fragment");exports.Fragment=a;exports.jsxDEV=void 0;
/**
* @license React
* react-jsx-dev-runtime.profiling.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var a=Symbol.for("react.fragment");exports.Fragment=a;exports.jsxDEV=void 0;
/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var f=require("react"),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;
/**
* @license React
* react-jsx-runtime.profiling.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var f=require("react"),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q;
This diff is collapsed.
/**
* @license React
* react.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var k=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.context"),v=Symbol.for("react.server_context"),w=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),B=Symbol.for("react.debug_trace_mode"),aa=Symbol.for("react.offscreen"),ba=Symbol.for("react.cache"),
C=Symbol.for("react.default_value"),D=Symbol.iterator;function ca(a){if(null===a||"object"!==typeof a)return null;a=D&&a[D]||a["@@iterator"];return"function"===typeof a?a:null}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,G={};function H(a,b,d){this.props=a;this.context=b;this.refs=G;this.updater=d||E}H.prototype.isReactComponent={};
H.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,a,b,"setState")};H.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function I(){}I.prototype=H.prototype;function J(a,b,d){this.props=a;this.context=b;this.refs=G;this.updater=d||E}var K=J.prototype=new I;
K.constructor=J;F(K,H.prototype);K.isPureReactComponent=!0;var L=Array.isArray,M=Object.prototype.hasOwnProperty,N={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};
function P(a,b,d){var c,e={},l=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(l=""+b.key),b)M.call(b,c)&&!O.hasOwnProperty(c)&&(e[c]=b[c]);var g=arguments.length-2;if(1===g)e.children=d;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];e.children=f}if(a&&a.defaultProps)for(c in g=a.defaultProps,g)void 0===e[c]&&(e[c]=g[c]);return{$$typeof:k,type:a,key:l,ref:h,props:e,_owner:N.current}}
function da(a,b){return{$$typeof:k,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function Q(a){return"object"===typeof a&&null!==a&&a.$$typeof===k}function escape(a){var b={"=":"=0",":":"=2"};return"$"+a.replace(/[=:]/g,function(a){return b[a]})}var R=/\/+/g;function S(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
function T(a,b,d,c,e){var l=typeof a;if("undefined"===l||"boolean"===l)a=null;var h=!1;if(null===a)h=!0;else switch(l){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case k:case n:h=!0}}if(h)return h=a,e=e(h),a=""===c?"."+S(h,0):c,L(e)?(d="",null!=a&&(d=a.replace(R,"$&/")+"/"),T(e,b,d,"",function(a){return a})):null!=e&&(Q(e)&&(e=da(e,d+(!e.key||h&&h.key===e.key?"":(""+e.key).replace(R,"$&/")+"/")+a)),b.push(e)),1;h=0;c=""===c?".":c+":";if(L(a))for(var g=0;g<a.length;g++){l=
a[g];var f=c+S(l,g);h+=T(l,b,d,f,e)}else if(f=ca(a),"function"===typeof f)for(a=f.call(a),g=0;!(l=a.next()).done;)l=l.value,f=c+S(l,g++),h+=T(l,b,d,f,e);else if("object"===l)throw b=String(a),Error("Objects are not valid as a React child (found: "+("[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b)+"). If you meant to render a collection of children, use an array instead.");return h}
function U(a,b,d){if(null==a)return a;var c=[],e=0;T(a,c,"","",function(a){return b.call(d,a,e++)});return c}function ea(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b});-1===a._status&&(a._status=0,a._result=b)}if(1===a._status)return a._result.default;throw a._result;}
var V={current:null},W={current:null},X={transition:null},Y={ReactCurrentDispatcher:V,ReactCurrentCache:W,ReactCurrentBatchConfig:X,ReactCurrentOwner:N,ContextRegistry:{}},Z=Y.ContextRegistry;
exports.Children={map:U,forEach:function(a,b,d){U(a,function(){b.apply(this,arguments)},d)},count:function(a){var b=0;U(a,function(){b++});return b},toArray:function(a){return U(a,function(a){return a})||[]},only:function(a){if(!Q(a))throw Error("React.Children.only expected to receive a single React element child.");return a}};exports.Component=H;exports.Fragment=p;exports.Profiler=r;exports.PureComponent=J;exports.StrictMode=q;exports.Suspense=x;exports.SuspenseList=y;
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y;
exports.cloneElement=function(a,b,d){if(null===a||void 0===a)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+a+".");var c=F({},a.props),e=a.key,l=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(l=b.ref,h=N.current);void 0!==b.key&&(e=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)M.call(b,f)&&!O.hasOwnProperty(f)&&(c[f]=void 0===b[f]&&void 0!==g?g[f]:b[f])}var f=arguments.length-2;if(1===f)c.children=d;else if(1<f){g=Array(f);
for(var m=0;m<f;m++)g[m]=arguments[m+2];c.children=g}return{$$typeof:k,type:a.type,key:e,ref:l,props:c,_owner:h}};exports.createContext=function(a){a={$$typeof:u,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};a.Provider={$$typeof:t,_context:a};return a.Consumer=a};exports.createElement=P;exports.createFactory=function(a){var b=P.bind(null,a);b.type=a;return b};exports.createRef=function(){return{current:null}};
exports.createServerContext=function(a,b){var d=!0;if(!Z[a]){d=!1;var c={$$typeof:v,_currentValue:b,_currentValue2:b,_defaultValue:b,_threadCount:0,Provider:null,Consumer:null,_globalName:a};c.Provider={$$typeof:t,_context:c};Z[a]=c}c=Z[a];if(c._defaultValue===C)c._defaultValue=b,c._currentValue===C&&(c._currentValue=b),c._currentValue2===C&&(c._currentValue2=b);else if(d)throw Error("ServerContext: "+a+" already defined");return c};exports.experimental_use=function(a){return V.current.use(a)};
exports.experimental_useEvent=function(a){return V.current.useEvent(a)};exports.forwardRef=function(a){return{$$typeof:w,render:a}};exports.isValidElement=Q;exports.lazy=function(a){return{$$typeof:A,_payload:{_status:-1,_result:a},_init:ea}};exports.memo=function(a,b){return{$$typeof:z,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_Cache=ba;exports.unstable_DebugTracingMode=B;
exports.unstable_Offscreen=aa;exports.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.");};exports.unstable_getCacheForType=function(a){var b=W.current;return b?b.getCacheForType(a):a()};exports.unstable_getCacheSignal=function(){var a=W.current;return a?a.getCacheSignal():(a=new AbortController,a.abort(Error("This CacheSignal was requested outside React which means that it is immediately aborted.")),a.signal)};exports.unstable_useCacheRefresh=function(){return V.current.useCacheRefresh()};
exports.unstable_useMemoCache=function(a){return V.current.useMemoCache(a)};exports.useCallback=function(a,b){return V.current.useCallback(a,b)};exports.useContext=function(a){return V.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return V.current.useDeferredValue(a)};exports.useEffect=function(a,b){return V.current.useEffect(a,b)};exports.useId=function(){return V.current.useId()};
exports.useImperativeHandle=function(a,b,d){return V.current.useImperativeHandle(a,b,d)};exports.useInsertionEffect=function(a,b){return V.current.useInsertionEffect(a,b)};exports.useLayoutEffect=function(a,b){return V.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return V.current.useMemo(a,b)};exports.useReducer=function(a,b,d){return V.current.useReducer(a,b,d)};exports.useRef=function(a){return V.current.useRef(a)};exports.useState=function(a){return V.current.useState(a)};
exports.useSyncExternalStore=function(a,b,d){return V.current.useSyncExternalStore(a,b,d)};exports.useTransition=function(){return V.current.useTransition()};exports.version="18.3.0-experimental-9cdf8a99e-20221018";
/**
* @license React
* react.shared-subset.production.min.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';var m=Symbol.for("react.element"),n=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),t=Symbol.for("react.provider"),u=Symbol.for("react.server_context"),v=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),y=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),A=Symbol.for("react.debug_trace_mode"),B=Symbol.for("react.default_value"),C=Symbol.iterator;
function D(a){if(null===a||"object"!==typeof a)return null;a=C&&a[C]||a["@@iterator"];return"function"===typeof a?a:null}function E(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,e=1;e<arguments.length;e++)b+="&args[]="+encodeURIComponent(arguments[e]);return"Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
var F={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},G=Object.assign,H={};function I(a,b,e){this.props=a;this.context=b;this.refs=H;this.updater=e||F}I.prototype.isReactComponent={};I.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(E(85));this.updater.enqueueSetState(this,a,b,"setState")};I.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};
function J(){}J.prototype=I.prototype;function K(a,b,e){this.props=a;this.context=b;this.refs=H;this.updater=e||F}var L=K.prototype=new J;L.constructor=K;G(L,I.prototype);L.isPureReactComponent=!0;var M=Array.isArray,N=Object.prototype.hasOwnProperty,O={current:null},P={key:!0,ref:!0,__self:!0,__source:!0};function aa(a,b){return{$$typeof:m,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function Q(a){return"object"===typeof a&&null!==a&&a.$$typeof===m}
function escape(a){var b={"=":"=0",":":"=2"};return"$"+a.replace(/[=:]/g,function(a){return b[a]})}var R=/\/+/g;function S(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
function T(a,b,e,c,d){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case m:case n:h=!0}}if(h)return h=a,d=d(h),a=""===c?"."+S(h,0):c,M(d)?(e="",null!=a&&(e=a.replace(R,"$&/")+"/"),T(d,b,e,"",function(a){return a})):null!=d&&(Q(d)&&(d=aa(d,e+(!d.key||h&&h.key===d.key?"":(""+d.key).replace(R,"$&/")+"/")+a)),b.push(d)),1;h=0;c=""===c?".":c+":";if(M(a))for(var g=0;g<a.length;g++){k=
a[g];var f=c+S(k,g);h+=T(k,b,e,f,d)}else if(f=D(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=c+S(k,g++),h+=T(k,b,e,f,d);else if("object"===k)throw b=String(a),Error(E(31,"[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b));return h}function U(a,b,e){if(null==a)return a;var c=[],d=0;T(a,c,"","",function(a){return b.call(e,a,d++)});return c}
function ba(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b});-1===a._status&&(a._status=0,a._result=b)}if(1===a._status)return a._result.default;throw a._result;}var V={current:null},W={current:null},X={transition:null},Y={ReactCurrentDispatcher:V,ReactCurrentCache:W,ReactCurrentBatchConfig:X,ReactCurrentOwner:O,ContextRegistry:{}},Z=Y.ContextRegistry;
exports.Children={map:U,forEach:function(a,b,e){U(a,function(){b.apply(this,arguments)},e)},count:function(a){var b=0;U(a,function(){b++});return b},toArray:function(a){return U(a,function(a){return a})||[]},only:function(a){if(!Q(a))throw Error(E(143));return a}};exports.Fragment=p;exports.Profiler=r;exports.StrictMode=q;exports.Suspense=w;exports.SuspenseList=x;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y;
exports.cloneElement=function(a,b,e){if(null===a||void 0===a)throw Error(E(267,a));var c=G({},a.props),d=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=O.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)N.call(b,f)&&!P.hasOwnProperty(f)&&(c[f]=void 0===b[f]&&void 0!==g?g[f]:b[f])}var f=arguments.length-2;if(1===f)c.children=e;else if(1<f){g=Array(f);for(var l=0;l<f;l++)g[l]=arguments[l+2];c.children=g}return{$$typeof:m,type:a.type,
key:d,ref:k,props:c,_owner:h}};exports.createElement=function(a,b,e){var c,d={},k=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)N.call(b,c)&&!P.hasOwnProperty(c)&&(d[c]=b[c]);var g=arguments.length-2;if(1===g)d.children=e;else if(1<g){for(var f=Array(g),l=0;l<g;l++)f[l]=arguments[l+2];d.children=f}if(a&&a.defaultProps)for(c in g=a.defaultProps,g)void 0===d[c]&&(d[c]=g[c]);return{$$typeof:m,type:a,key:k,ref:h,props:d,_owner:O.current}};exports.createRef=function(){return{current:null}};
exports.createServerContext=function(a,b){var e=!0;if(!Z[a]){e=!1;var c={$$typeof:u,_currentValue:b,_currentValue2:b,_defaultValue:b,_threadCount:0,Provider:null,Consumer:null,_globalName:a};c.Provider={$$typeof:t,_context:c};Z[a]=c}c=Z[a];if(c._defaultValue===B)c._defaultValue=b,c._currentValue===B&&(c._currentValue=b),c._currentValue2===B&&(c._currentValue2=b);else if(e)throw Error(E(429,a));return c};exports.experimental_use=function(a){return V.current.use(a)};
exports.forwardRef=function(a){return{$$typeof:v,render:a}};exports.isValidElement=Q;exports.lazy=function(a){return{$$typeof:z,_payload:{_status:-1,_result:a},_init:ba}};exports.memo=function(a,b){return{$$typeof:y,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=X.transition;X.transition={};try{a()}finally{X.transition=b}};exports.unstable_DebugTracingMode=A;exports.unstable_getCacheForType=function(a){var b=W.current;return b?b.getCacheForType(a):a()};
exports.unstable_getCacheSignal=function(){var a=W.current;if(!a){a=new AbortController;var b=Error(E(455));a.abort(b);return a.signal}return a.getCacheSignal()};exports.useCallback=function(a,b){return V.current.useCallback(a,b)};exports.useContext=function(a){return V.current.useContext(a)};exports.useDebugValue=function(){};exports.useId=function(){return V.current.useId()};exports.useMemo=function(a,b){return V.current.useMemo(a,b)};exports.version="18.3.0-experimental-9cdf8a99e-20221018";
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-jsx-dev-runtime.production.min.js');
} else {
module.exports = require('./cjs/react-jsx-dev-runtime.development.js');
}
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react-jsx-runtime.production.min.js');
} else {
module.exports = require('./cjs/react-jsx-runtime.development.js');
}
{
"name": "react",
"description": "React is a JavaScript library for building user interfaces.",
"keywords": [
"react"
],
"version": "0.0.0-experimental-9cdf8a99e-20221018",
"homepage": "https://reactjs.org/",
"bugs": "https://github.com/facebook/react/issues",
"license": "MIT",
"files": [
"LICENSE",
"README.md",
"index.js",
"cjs/",
"umd/",
"jsx-runtime.js",
"jsx-dev-runtime.js",
"react.shared-subset.js"
],
"main": "index.js",
"exports": {
".": {
"react-server": "./react.shared-subset.js",
"default": "./index.js"
},
"./package.json": "./package.json",
"./jsx-runtime": "./jsx-runtime.js",
"./jsx-dev-runtime": "./jsx-dev-runtime.js"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/react.git",
"directory": "packages/react"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"loose-envify": "^1.1.0"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}
\ No newline at end of file
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.shared-subset.production.min.js');
} else {
module.exports = require('./cjs/react.shared-subset.development.js');
}
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
{"name":"scheduler","main":"index.js","license":"MIT"}
import chalk from 'next/dist/compiled/chalk'
import {
hasNecessaryDependencies,
MissingDependency,
NecessaryDependencies,
} from './has-necessary-dependencies'
import { installDependencies } from './install-dependencies'
import { isCI } from '../telemetry/ci-info'
import { FatalError } from './fatal-error'
import { getPkgManager } from './helpers/get-pkg-manager'
import { getOxfordCommaList } from './oxford-comma-list'
const requiredReactVersion = process.env.REQUIRED_APP_REACT_VERSION || ''
const removalMsg =
'\n\n' +
chalk.bold(
'If you are not trying to use the `app` directory, please disable the ' +
chalk.cyan('experimental.appDir') +
' config in your `next.config.js`.'
)
const requiredPackages = [
{
file: 'react/index.js',
pkg: 'react',
exportsRestrict: true,
},
{
file: 'react-dom/index.js',
pkg: 'react-dom',
exportsRestrict: true,
},
]
async function missingDepsError(
dir: string,
missingPackages: MissingDependency[]
) {
const packagesHuman = getOxfordCommaList(missingPackages.map((p) => p.pkg))
const packagesCli = missingPackages
.map((p) => `${p.pkg}@${requiredReactVersion}`)
.join(' ')
const packageManager = getPkgManager(dir)
throw new FatalError(
chalk.bold.red(
`It looks like you're trying to use the \`app\` directory but do not have the required react version installed.`
) +
'\n\n' +
chalk.bold(`Please install ${chalk.bold(packagesHuman)} by running:`) +
'\n\n' +
`\t${chalk.bold.cyan(
(packageManager === 'yarn'
? 'yarn add --dev'
: packageManager === 'pnpm'
? 'pnpm install --save-dev'
: 'npm install --save-dev') +
' ' +
packagesCli
)}` +
removalMsg +
'\n'
)
}
export async function verifyAppReactVersion({
dir,
}: {
dir: string
}): Promise<void> {
if (process.env.NEXT_SKIP_APP_REACT_INSTALL) {
return
}
// Ensure TypeScript and necessary `@types/*` are installed:
let deps: NecessaryDependencies = await hasNecessaryDependencies(
dir,
requiredPackages
)
const resolvedReact = deps.resolved.get('react')
const installedVersion =
resolvedReact &&
require(deps.resolved.get('react') || '')
.version?.split('-experimental')
.pop()
if (
deps.missing?.length ||
installedVersion !== requiredReactVersion.split('-experimental').pop()
) {
const neededDeps = requiredPackages.map((dep) => {
dep.pkg = `${dep.pkg}@${requiredReactVersion}`
return dep
})
if (isCI) {
// we don't attempt auto install in CI to avoid side-effects
// and instead log the error for installing needed packages
await missingDepsError(dir, neededDeps)
}
console.log(
chalk.bold.yellow(
`It looks like you're trying to use \`app\` directory but do not have the required react version installed.`
) +
'\n' +
removalMsg +
'\n'
)
await installDependencies(dir, neededDeps, true).catch((err) => {
if (err && typeof err === 'object' && 'command' in err) {
console.error(
`\nFailed to install required react versions, please install them manually to continue:\n` +
(err as any).command +
'\n'
)
}
process.exit(1)
})
}
}
...@@ -8,11 +8,11 @@ import type { FontLoaderManifest } from '../build/webpack/plugins/font-loader-ma ...@@ -8,11 +8,11 @@ import type { FontLoaderManifest } from '../build/webpack/plugins/font-loader-ma
import React, { import React, {
// @ts-ignore // @ts-ignore
experimental_use as use, experimental_use as use,
} from 'react' } from 'next/dist/compiled/react'
// this needs to be required lazily so that `next-server` can set // this needs to be required lazily so that `next-server` can set
// the env before we require // the env before we require
import ReactDOMServer from 'react-dom/server.browser' import ReactDOMServer from 'next/dist/compiled/react-dom/server.browser'
import { ParsedUrlQuery } from 'querystring' import { ParsedUrlQuery } from 'querystring'
import { NextParsedUrlQuery } from './request-meta' import { NextParsedUrlQuery } from './request-meta'
......
...@@ -76,7 +76,6 @@ import { ...@@ -76,7 +76,6 @@ import {
} from '../../build/utils' } from '../../build/utils'
import { getDefineEnv } from '../../build/webpack-config' import { getDefineEnv } from '../../build/webpack-config'
import loadJsConfig from '../../build/load-jsconfig' import loadJsConfig from '../../build/load-jsconfig'
import { verifyAppReactVersion } from '../../lib/verifyAppReactVersion'
// Load ReactDevOverlay only when needed // Load ReactDevOverlay only when needed
let ReactDevOverlayImpl: FunctionComponent let ReactDevOverlayImpl: FunctionComponent
...@@ -659,10 +658,6 @@ export default class DevServer extends Server { ...@@ -659,10 +658,6 @@ export default class DevServer extends Server {
setGlobal('distDir', this.distDir) setGlobal('distDir', this.distDir)
setGlobal('phase', PHASE_DEVELOPMENT_SERVER) setGlobal('phase', PHASE_DEVELOPMENT_SERVER)
if (this.hasAppDir) {
await verifyAppReactVersion({ dir: this.dir })
}
await this.verifyTypeScript() await this.verifyTypeScript()
this.customRoutes = await loadCustomRoutes(this.nextConfig) this.customRoutes = await loadCustomRoutes(this.nextConfig)
......
...@@ -149,7 +149,6 @@ export class NextServer { ...@@ -149,7 +149,6 @@ export class NextServer {
} }
private async getServer() { private async getServer() {
setTimeout(getServerImpl, 10)
if (!this.serverPromise) { if (!this.serverPromise) {
this.serverPromise = this.loadConfig().then(async (conf) => { this.serverPromise = this.loadConfig().then(async (conf) => {
if (conf.experimental.appDir) { if (conf.experimental.appDir) {
......
...@@ -2067,7 +2067,7 @@ export async function ncc(task, opts) { ...@@ -2067,7 +2067,7 @@ export async function ncc(task, opts) {
'copy_regenerator_runtime', 'copy_regenerator_runtime',
'copy_babel_runtime', 'copy_babel_runtime',
'copy_constants_browserify', 'copy_constants_browserify',
// 'ncc_react', 'ncc_react',
'ncc_react_server_dom_webpack', 'ncc_react_server_dom_webpack',
'copy_react_is', 'copy_react_is',
'ncc_sass_loader', 'ncc_sass_loader',
......
...@@ -3,7 +3,7 @@ declare module 'next/dist/compiled/babel/plugin-transform-modules-commonjs' ...@@ -3,7 +3,7 @@ declare module 'next/dist/compiled/babel/plugin-transform-modules-commonjs'
declare module 'next/dist/compiled/babel/plugin-syntax-jsx' declare module 'next/dist/compiled/babel/plugin-syntax-jsx'
declare module 'next/dist/compiled/react-server-dom-webpack/client' declare module 'next/dist/compiled/react-server-dom-webpack/client'
declare module 'next/dist/compiled/react-server-dom-webpack/server.browser' declare module 'next/dist/compiled/react-server-dom-webpack/server.browser'
// declare module 'next/dist/compiled/react-dom/server.browser' declare module 'next/dist/compiled/react-dom/server.browser'
declare module 'next/dist/compiled/browserslist' declare module 'next/dist/compiled/browserslist'
declare module 'react-dom/server.browser' declare module 'react-dom/server.browser'
...@@ -341,14 +341,14 @@ declare module 'next/dist/compiled/@segment/ajv-human-errors' { ...@@ -341,14 +341,14 @@ declare module 'next/dist/compiled/@segment/ajv-human-errors' {
export = m export = m
} }
// declare module 'next/dist/compiled/react' { declare module 'next/dist/compiled/react' {
// import * as m from 'react' import * as m from 'react'
// export = m export = m
// } }
// declare module 'next/dist/compiled/react-dom' { declare module 'next/dist/compiled/react-dom' {
// import * as m from 'react-dom' import * as m from 'react-dom'
// export = m export = m
// } }
declare module 'next/dist/compiled/stacktrace-parser' { declare module 'next/dist/compiled/stacktrace-parser' {
import * as m from 'stacktrace-parser' import * as m from 'stacktrace-parser'
......
This diff is collapsed.
...@@ -15,8 +15,8 @@ describe('app-dir alias handling', () => { ...@@ -15,8 +15,8 @@ describe('app-dir alias handling', () => {
next = await createNext({ next = await createNext({
files: new FileRef(path.join(__dirname, 'app-alias')), files: new FileRef(path.join(__dirname, 'app-alias')),
dependencies: { dependencies: {
react: '0.0.0-experimental-9cdf8a99e-20221018', react: 'latest',
'react-dom': '0.0.0-experimental-9cdf8a99e-20221018', 'react-dom': 'latest',
typescript: 'latest', typescript: 'latest',
'@types/react': 'latest', '@types/react': 'latest',
'@types/node': 'latest', '@types/node': 'latest',
......
...@@ -17,8 +17,13 @@ ...@@ -17,8 +17,13 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/ui/*": ["ui/*"] "@/ui/*": ["ui/*"]
} },
"plugins": [
{
"name": "next"
}
]
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }
...@@ -15,8 +15,8 @@ describe('app-dir edge SSR', () => { ...@@ -15,8 +15,8 @@ describe('app-dir edge SSR', () => {
next = await createNext({ next = await createNext({
files: new FileRef(path.join(__dirname, 'app-edge')), files: new FileRef(path.join(__dirname, 'app-edge')),
dependencies: { dependencies: {
react: '0.0.0-experimental-9cdf8a99e-20221018', react: 'latest',
'react-dom': '0.0.0-experimental-9cdf8a99e-20221018', 'react-dom': 'latest',
typescript: 'latest', typescript: 'latest',
'@types/react': 'latest', '@types/react': 'latest',
'@types/node': 'latest', '@types/node': 'latest',
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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