mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Export captureOwnerStacks() only in DEV "react" builds (#29923)
Only with the enableOwnerStacks flag (which is not on in www). This is a new DEV-only API to be able to implement what we do for console.error in user space. This API does not actually include the current stack that you'd get from `new Error().stack`. That you'd have to add yourself. This adds the ability to have conditional development exports because we plan on eventually having separate ESM builds that use the "development" or "production" export conditions. NOTE: This removes the export of `act` from `react` in prod (as opposed to a function that throws) - inline with what we do with other conditional exports.
This commit is contained in:
committed by
GitHub
parent
e684ca66ab
commit
6b4646cbd0
@@ -12,6 +12,8 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
// .stable.js
|
||||
// .experimental.js
|
||||
// .js
|
||||
// or any of those plus .development.js
|
||||
|
||||
if (isFBBundle) {
|
||||
// FB builds for react-dom need to alias both react-dom and react-dom/client to the same
|
||||
// entrypoint since there is only a single build for them.
|
||||
@@ -41,6 +43,10 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
}
|
||||
|
||||
resolvedEntry = nodePath.join(resolvedEntry, '..', entrypoint);
|
||||
const developmentEntry = resolvedEntry.replace('.js', '.development.js');
|
||||
if (fs.existsSync(developmentEntry)) {
|
||||
return developmentEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedEntry)) {
|
||||
return resolvedEntry;
|
||||
}
|
||||
@@ -53,6 +59,10 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
'.js',
|
||||
__EXPERIMENTAL__ ? '.modern.fb.js' : '.classic.fb.js'
|
||||
);
|
||||
const devFBEntry = resolvedFBEntry.replace('.js', '.development.js');
|
||||
if (fs.existsSync(devFBEntry)) {
|
||||
return devFBEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedFBEntry)) {
|
||||
return resolvedFBEntry;
|
||||
}
|
||||
@@ -66,9 +76,17 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
'.js',
|
||||
__EXPERIMENTAL__ ? '.experimental.js' : '.stable.js'
|
||||
);
|
||||
const devForkedEntry = resolvedForkedEntry.replace('.js', '.development.js');
|
||||
if (fs.existsSync(devForkedEntry)) {
|
||||
return devForkedEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedForkedEntry)) {
|
||||
return resolvedForkedEntry;
|
||||
}
|
||||
const plainDevEntry = resolvedEntry.replace('.js', '.development.js');
|
||||
if (fs.existsSync(plainDevEntry)) {
|
||||
return plainDevEntry;
|
||||
}
|
||||
// Just use the plain .js one.
|
||||
return resolvedEntry;
|
||||
}
|
||||
@@ -77,7 +95,8 @@ function mockReact() {
|
||||
jest.mock('react', () => {
|
||||
const resolvedEntryPoint = resolveEntryFork(
|
||||
require.resolve('react'),
|
||||
global.__WWW__ || global.__XPLAT__
|
||||
global.__WWW__ || global.__XPLAT__,
|
||||
global.__DEV__
|
||||
);
|
||||
return jest.requireActual(resolvedEntryPoint);
|
||||
});
|
||||
@@ -100,7 +119,8 @@ jest.mock('react/react.react-server', () => {
|
||||
});
|
||||
const resolvedEntryPoint = resolveEntryFork(
|
||||
require.resolve('react/src/ReactServer'),
|
||||
global.__WWW__ || global.__XPLAT__
|
||||
global.__WWW__ || global.__XPLAT__,
|
||||
global.__DEV__
|
||||
);
|
||||
return jest.requireActual(resolvedEntryPoint);
|
||||
});
|
||||
@@ -198,7 +218,8 @@ inlinedHostConfigs.forEach(rendererInfo => {
|
||||
mockAllConfigs(rendererInfo);
|
||||
const resolvedEntryPoint = resolveEntryFork(
|
||||
require.resolve(entryPoint),
|
||||
global.__WWW__ || global.__XPLAT__
|
||||
global.__WWW__ || global.__XPLAT__,
|
||||
global.__DEV__
|
||||
);
|
||||
return jest.requireActual(resolvedEntryPoint);
|
||||
});
|
||||
|
||||
@@ -567,16 +567,31 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
// .stable.js
|
||||
// .experimental.js
|
||||
// .js
|
||||
// or any of those plus .development.js
|
||||
|
||||
if (isFBBundle) {
|
||||
const resolvedFBEntry = resolvedEntry.replace(
|
||||
'.js',
|
||||
__EXPERIMENTAL__ ? '.modern.fb.js' : '.classic.fb.js'
|
||||
);
|
||||
const developmentFBEntry = resolvedFBEntry.replace(
|
||||
'.js',
|
||||
'.development.js'
|
||||
);
|
||||
if (fs.existsSync(developmentFBEntry)) {
|
||||
return developmentFBEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedFBEntry)) {
|
||||
return resolvedFBEntry;
|
||||
}
|
||||
const resolvedGenericFBEntry = resolvedEntry.replace('.js', '.fb.js');
|
||||
const developmentGenericFBEntry = resolvedGenericFBEntry.replace(
|
||||
'.js',
|
||||
'.development.js'
|
||||
);
|
||||
if (fs.existsSync(developmentGenericFBEntry)) {
|
||||
return developmentGenericFBEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedGenericFBEntry)) {
|
||||
return resolvedGenericFBEntry;
|
||||
}
|
||||
@@ -586,6 +601,10 @@ function resolveEntryFork(resolvedEntry, isFBBundle) {
|
||||
'.js',
|
||||
__EXPERIMENTAL__ ? '.experimental.js' : '.stable.js'
|
||||
);
|
||||
const devForkedEntry = resolvedForkedEntry.replace('.js', '.development.js');
|
||||
if (fs.existsSync(devForkedEntry)) {
|
||||
return devForkedEntry;
|
||||
}
|
||||
if (fs.existsSync(resolvedForkedEntry)) {
|
||||
return resolvedForkedEntry;
|
||||
}
|
||||
@@ -604,7 +623,8 @@ async function createBundle(bundle, bundleType) {
|
||||
|
||||
let resolvedEntry = resolveEntryFork(
|
||||
require.resolve(bundle.entry),
|
||||
isFBWWWBundle || isFBRNBundle
|
||||
isFBWWWBundle || isFBRNBundle,
|
||||
!isProductionBundleType(bundleType)
|
||||
);
|
||||
|
||||
const peerGlobals = Modules.getPeerGlobals(bundle.externals, bundleType);
|
||||
|
||||
Reference in New Issue
Block a user