Skip to content

Commit

Permalink
[core] Use React 18's JSX runtime for v5.x UMD builds (#44815)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai authored Dec 24, 2024
1 parent b8fbcf5 commit a37b3d4
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 105 deletions.
4 changes: 2 additions & 2 deletions examples/material-ui-via-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<title>My page</title>
<meta name="viewport" content="initial-scale=1, width=device-width" />
<script
src="https://unpkg.com/react@^18.0.0/umd/react.development.js"
src="https://unpkg.com/react@^18.3.1/umd/react.development.js"
crossorigin="anonymous"
></script>
<script src="https://unpkg.com/react-dom@^18.0.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/react-dom@^18.3.1/umd/react-dom.development.js"></script>
<script
src="https://unpkg.com/@mui/material@5/umd/material-ui.development.js"
crossorigin="anonymous"
Expand Down
5 changes: 3 additions & 2 deletions packages/mui-material/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"devDependencies": {
"@mui-internal/test-utils": "workspace:^",
"@mui/internal-babel-macros": "workspace:^",
"@rollup/plugin-commonjs": "^28.0.2",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-replace": "^5.0.5",
"@testing-library/dom": "^10.3.1",
"@testing-library/user-event": "^14.5.2",
Expand All @@ -76,11 +78,10 @@
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^6.21.3",
"react18": "npm:react@^18.3.1",
"rollup": "^3.29.4",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^15.2.0"
},
Expand Down
28 changes: 7 additions & 21 deletions packages/mui-material/scripts/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import * as url from 'url';
import path from 'path';
import zlib from 'zlib';
import { promisify } from 'util';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from 'rollup-plugin-babel';
import replace from '@rollup/plugin-replace';
import nodeGlobals from 'rollup-plugin-node-globals';
import { terser } from 'rollup-plugin-terser';
import { createRequire } from 'module';

const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));

Expand Down Expand Up @@ -117,6 +118,10 @@ const nestedFolder = {
return resolveNestedImport('mui-system', importee);
}

if (importee.indexOf('react/jsx-runtime') === 0) {
return createRequire(import.meta.url).resolve('react18/jsx-runtime');
}

return undefined;
},
};
Expand All @@ -136,25 +141,6 @@ const babelOptions = {
const commonjsOptions = {
ignoreGlobal: true,
include: /node_modules/,
namedExports: {
'node_modules/prop-types/index.js': [
'elementType',
'bool',
'func',
'object',
'oneOfType',
'element',
],
'node_modules/react/jsx-runtime.js': ['jsx', 'jsxs'],
'node_modules/react-is/index.js': [
'ForwardRef',
'isFragment',
'isLazy',
'isMemo',
'Memo',
'isValidElementType',
],
},
};
const nodeOptions = {
extensions: ['.js', '.tsx', '.ts'],
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/test/umd/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function createApp() {
'utf8',
);
index = index.replace(
'https://unpkg.com/@mui/material@latest/umd/material-ui.development.js',
'https://unpkg.com/@mui/material@5/umd/material-ui.development.js',
umdPath,
);
index = index.replace(
Expand Down
Loading

0 comments on commit a37b3d4

Please sign in to comment.