Skip to content

Commit

Permalink
Change ReactVersion from CJS to ES module (#18181)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored Feb 28, 2020
1 parent 58eedbb commit 4469700
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions packages/shared/ReactVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
* LICENSE file in the root directory of this source tree.
*/

'use strict';

// TODO: this is special because it gets imported during build.
module.exports = '16.13.0';
export default '16.13.0';
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const run = async ({cwd, packages, skipPackages, tags}) => {
const sourceReactVersion = readFileSync(
sourceReactVersionPath,
'utf8'
).replace(/module\.exports = '[^']+';/, `module.exports = '${version}';`);
).replace(/export default '[^']+';/, `export default '${version}';`);
writeFileSync(sourceReactVersionPath, sourceReactVersion);
}
};
Expand Down
5 changes: 1 addition & 4 deletions scripts/release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,7 @@ const updateVersionsForNext = async (cwd, reactVersion, version) => {
const sourceReactVersion = readFileSync(
sourceReactVersionPath,
'utf8'
).replace(
/module\.exports = '[^']+';/,
`module.exports = '${reactVersion}';`
);
).replace(/export default '[^']+';/, `export default '${reactVersion}';`);
writeFileSync(sourceReactVersionPath, sourceReactVersion);

// Update the root package.json.
Expand Down
9 changes: 7 additions & 2 deletions scripts/tasks/version-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@

'use strict';

const reactVersion = require('../../package.json').version;
const fs = require('fs');
const ReactVersionSrc = fs.readFileSync(
require.resolve('../../packages/shared/ReactVersion')
);
const reactVersion = /export default '([^']+)';/.exec(ReactVersionSrc)[1];

const versions = {
'packages/react/package.json': require('../../packages/react/package.json')
.version,
'packages/react-dom/package.json': require('../../packages/react-dom/package.json')
.version,
'packages/react-test-renderer/package.json': require('../../packages/react-test-renderer/package.json')
.version,
'packages/shared/ReactVersion.js': require('../../packages/shared/ReactVersion'),
'packages/shared/ReactVersion.js': reactVersion,
};

let allVersionsMatch = true;
Expand Down

0 comments on commit 4469700

Please sign in to comment.