Skip to content
New issue

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

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

Already on GitHub? # to your account

[code-infra] Add babel runtime version check #14483

Merged
merged 1 commit into from
Sep 4, 2024
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: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ module.exports = function getBabelConfig(api) {
'@babel/plugin-transform-runtime',
{
useESModules,
// any package needs to declare 7.4.4 as a runtime dependency. default is ^7.0.0
version: '^7.4.4',
// any package needs to declare 7.25.0 as a runtime dependency. default is ^7.0.0
version: process.env.MUI_BABEL_RUNTIME_VERSION || '^7.25.0',
},
],
[
Expand Down
12 changes: 12 additions & 0 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path';
import { promisify } from 'util';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import * as fs from 'fs/promises';
import { getWorkspaceRoot } from './utils.mjs';

const exec = promisify(childProcess.exec);
Expand All @@ -27,10 +28,21 @@ async function run(argv) {
);
}

const packageJsonPath = path.resolve('./package.json');
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, { encoding: 'utf8' }));

const babelRuntimeVersion = packageJson.dependencies['@babel/runtime'];
if (!babelRuntimeVersion) {
throw new Error(
'package.json needs to have a dependency on `@babel/runtime` when building with `@babel/plugin-transform-runtime`.',
);
}

const env = {
NODE_ENV: 'production',
BABEL_ENV: bundle,
MUI_BUILD_VERBOSE: verbose,
MUI_BABEL_RUNTIME_VERSION: babelRuntimeVersion,
};
const babelConfigPath = path.resolve(getWorkspaceRoot(), 'babel.config.js');
const srcDir = path.resolve('./src');
Expand Down
Loading