Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change ReactVersion from CJS to ES module #18181

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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