Exclude react-dom/unstable_testing entry point from stable releases (#23258)

* Use consistent naming for unstable_testing entry point

* Exclude the testing build from non-experimental builds except at FB

* FB builds shouldn't contribute to whether we include the npm files

* Exclude exports fields if we delete the files entry

* Move test to no longer be internal so we can test against the build

* Update the bundle artifact names since they've now changed

* Gate import since it doesn't exist
This commit is contained in:
Sebastian Markbåge 2022-02-08 23:12:31 -05:00 committed by GitHub
parent 5690932765
commit a3bde7974c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 24 deletions

View File

@ -32,7 +32,7 @@ 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-testing.production.min.js');
module.exports = require('./cjs/react-dom-unstable_testing.production.min.js');
} else {
module.exports = require('./cjs/react-dom-testing.development.js');
module.exports = require('./cjs/react-dom-unstable_testing.development.js');
}

View File

@ -31,9 +31,10 @@ describe('ReactDOMTestSelectors', () => {
jest.resetModules();
React = require('react');
const ReactDOM = require('react-dom/testing');
act = React.unstable_act;
if (__EXPERIMENTAL__ || global.__WWW__) {
const ReactDOM = require('react-dom/unstable_testing');
createComponentSelector = ReactDOM.createComponentSelector;
createHasPseudoClassSelector = ReactDOM.createHasPseudoClassSelector;
createRoleSelector = ReactDOM.createRoleSelector;
@ -46,6 +47,7 @@ describe('ReactDOMTestSelectors', () => {
ReactDOM.getFindAllNodesFailureDescription;
observeVisibleRects = ReactDOM.observeVisibleRects;
render = ReactDOM.render;
}
container = document.createElement('div');
document.body.appendChild(container);

View File

@ -245,12 +245,13 @@ const bundles = [
externals: ['react', 'react-dom'],
},
// TODO: We don't use this bundle anymore
/******* React DOM - www - Testing *******/
{
moduleType: RENDERER,
bundleTypes: [FB_WWW_DEV, FB_WWW_PROD, NODE_DEV, NODE_PROD],
entry: 'react-dom/testing',
bundleTypes: __EXPERIMENTAL__
? [FB_WWW_DEV, FB_WWW_PROD, NODE_DEV, NODE_PROD]
: [FB_WWW_DEV, FB_WWW_PROD],
entry: 'react-dom/unstable_testing',
global: 'ReactDOMTesting',
minifyWithProdErrorCodes: true,
wrapWithModuleBoundaries: false,

View File

@ -129,7 +129,7 @@ const forks = Object.freeze({
return 'shared/forks/ReactFeatureFlags.test-renderer.www.js';
}
return 'shared/forks/ReactFeatureFlags.test-renderer.js';
case 'react-dom/testing':
case 'react-dom/unstable_testing':
switch (bundleType) {
case FB_WWW_DEV:
case FB_WWW_PROD:

View File

@ -139,7 +139,11 @@ let entryPointsToHasBundle = new Map();
for (const bundle of Bundles.bundles) {
let hasBundle = entryPointsToHasBundle.get(bundle.entry);
if (!hasBundle) {
entryPointsToHasBundle.set(bundle.entry, bundle.bundleTypes.length > 0);
const hasNonFBBundleTypes = bundle.bundleTypes.some(
type =>
type !== FB_WWW_DEV && type !== FB_WWW_PROD && type !== FB_WWW_PROFILING
);
entryPointsToHasBundle.set(bundle.entry, hasNonFBBundleTypes);
}
}
@ -176,6 +180,15 @@ function filterOutEntrypoints(name) {
i--;
unlinkSync(`build/node_modules/${name}/${filename}`);
changed = true;
// Remove it from the exports field too if it exists.
const exportsJSON = packageJSON.exports;
if (exportsJSON) {
if (filename === 'index.js') {
delete exportsJSON['.'];
} else {
delete exportsJSON['./' + filename.replace(/\.js$/, '')];
}
}
}
}
if (changed) {

View File

@ -11,7 +11,7 @@ module.exports = [
shortName: 'dom',
entryPoints: [
'react-dom',
'react-dom/testing',
'react-dom/unstable_testing',
'react-dom/src/server/ReactDOMFizzServerNode',
'react-server-dom-webpack/writer.node.server',
'react-server-dom-webpack',
@ -33,14 +33,14 @@ module.exports = [
shortName: 'dom-browser',
entryPoints: [
'react-dom',
'react-dom/testing',
'react-dom/unstable_testing',
'react-dom/src/server/ReactDOMFizzServerBrowser',
'react-server-dom-webpack/writer.browser.server',
'react-server-dom-webpack',
],
paths: [
'react-dom',
'react-dom/testing',
'react-dom/unstable_testing',
'react-dom/src/server/ReactDOMFizzServerBrowser.js', // react-dom/server.browser
'react-server-dom-webpack',
'react-server-dom-webpack/writer.browser.server',