Skip to content

Commit

Permalink
Remove public export for unstable-shared-subset.js (#23261)
Browse files Browse the repository at this point in the history
The unstable-shared-subset.js file is not a public module — it's a
private module that the "react" package maps to when it's accessed from
the "react-server" package.

We originally added it because it was required to make our Rollup
configuration work, because at the time only "public" modules could act
as the entry point for a build artifact — that's why it's prefixed with
"unstable". We've since updated our Rollup config to support private
entry points, so we can remove the extra indirection.
  • Loading branch information
acdlite authored Feb 23, 2022
1 parent 4de99b3 commit 552c067
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
7 changes: 7 additions & 0 deletions packages/react/npm/react.shared-subset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'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');
}
7 changes: 0 additions & 7 deletions packages/react/npm/unstable-shared-subset.js

This file was deleted.

7 changes: 3 additions & 4 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@
"umd/",
"jsx-runtime.js",
"jsx-dev-runtime.js",
"unstable-shared-subset.js"
"react.shared-subset.js"
],
"main": "index.js",
"exports": {
".": {
"react-server": "./unstable-shared-subset.js",
"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",
"./unstable-shared-subset": "./unstable-shared-subset.js"

"./src/*": "./src/*"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ export {
useMutableSource as unstable_useMutableSource,
useTransition,
version,
} from './src/React';
} from './React';
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ const bundles = [
{
bundleTypes: [NODE_DEV, NODE_PROD],
moduleType: ISOMORPHIC,
entry: 'react/unstable-shared-subset',
entry: 'react/src/ReactSharedSubset.js',
name: 'react.shared-subset',
global: 'React',
minifyWithProdErrorCodes: true,
wrapWithModuleBoundaries: false,
Expand Down
4 changes: 2 additions & 2 deletions scripts/rollup/forks.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const forks = Object.freeze({
// happens. Other bundles just require('object-assign') anyway.
return null;
}
if (entry === 'react' || entry === 'react/unstable-shared-subset') {
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
// Use the forked version that uses ES modules instead of CommonJS.
return './packages/shared/forks/object-assign.inline-umd.js';
}
Expand All @@ -82,7 +82,7 @@ const forks = Object.freeze({
entry,
dependencies
) => {
if (entry === 'react' || entry === 'react/unstable-shared-subset') {
if (entry === 'react' || entry === 'react/src/ReactSharedSubset.js') {
return './packages/react/src/ReactSharedInternals.js';
}
if (!entry.startsWith('react/') && dependencies.indexOf('react') === -1) {
Expand Down

0 comments on commit 552c067

Please sign in to comment.