Skip to content

Commit

Permalink
add babel runtime check
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Sep 4, 2024
1 parent 24943b0 commit 0cce960
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit 0cce960

Please # to comment.