diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1766798..ae10a8b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8780,4 +8780,4 @@ packages: /yocto-queue/0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - dev: true + dev: true \ No newline at end of file diff --git a/rollup.config.js b/rollup.config.js index ea39f30..ff999d0 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,59 +9,132 @@ const ProdReact = require("react/cjs/react.production.min.js"); function createDevConfig(format) { const dir = format === "module" ? "esm" : format; - return { - input: `src/development.js`, - output: { - format, - file: `${dir}/react.development.js`, - sourcemap: true, - banner: `/* react@${DevReact.version} development version */`, - exports: "named", + return [ + { + input: `src/development.js`, + output: { + format, + file: `${dir}/react@${DevReact.version}.development.js`, + sourcemap: true, + banner: `/* react@${DevReact.version} development version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"development"', + }, + }), + ], + }, + { + input: `src/jsx-dev-runtime.development.js`, + output: { + format, + file: `${dir}/react/jsx-dev-runtime@${DevReact.version}.development.js`, + sourcemap: true, + banner: `/* react/jsx-dev-runtime@${DevReact.version} development version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"development"', + }, + }), + ], + }, + { + input: `src/jsx-runtime.development.js`, + output: { + format, + file: `${dir}/react/jsx-runtime@${DevReact.version}.development.js`, + sourcemap: true, + banner: `/* react/jsx-runtime@${DevReact.version} development version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"development"', + }, + }), + ], }, - plugins: [ - commonjs(), - resolve(), - replace({ - values: { - "process.env.NODE_ENV": '"development"', - }, - }), - ], - }; + ]; } function createProdConfig(format) { - return { - input: `src/production.js`, - output: { - format, - file: `${format}/react.production.min.js`, - sourcemap: true, - banner: `/* react@${ProdReact.version} production version */`, - exports: "named", + return [ + { + input: `src/production.js`, + output: { + format, + file: `${format}/react@${ProdReact.version}.production.min.js`, + sourcemap: true, + banner: `/* react@${ProdReact.version} production version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"production"', + }, + }), + ], + }, + { + input: `src/jsx-dev-runtime.production.js`, + output: { + format, + file: `${format}/react/jsx-dev-runtime@${DevReact.version}.production.js`, + sourcemap: true, + banner: `/* react/jsx-dev-runtime@${DevReact.version} production version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"production"', + }, + }), + ], }, - plugins: [ - commonjs(), - resolve(), - replace({ - values: { - "process.env.NODE_ENV": '"production"', - }, - }), - terser({ - output: { - comments(node, comment) { - return comment.value.trim().startsWith("react@"); + { + input: `src/jsx-runtime.production.js`, + output: { + format, + file: `${format}/react/jsx-runtime@${DevReact.version}.production.js`, + sourcemap: true, + banner: `/* react/jsx-runtime@${DevReact.version} production version */`, + exports: "named", + }, + plugins: [ + commonjs(), + resolve(), + replace({ + values: { + "process.env.NODE_ENV": '"production"', }, - }, - }), - ], - }; + }), + ], + }, + ]; } export default [ - createDevConfig("esm"), - createDevConfig("system"), - createProdConfig("esm"), - createProdConfig("system"), + ...createDevConfig("esm"), + ...createDevConfig("system"), + ...createProdConfig("esm"), + ...createProdConfig("system"), ]; diff --git a/src/jsx-dev-runtime.development.js b/src/jsx-dev-runtime.development.js new file mode 100644 index 0000000..57e3fe7 --- /dev/null +++ b/src/jsx-dev-runtime.development.js @@ -0,0 +1,11 @@ +import ReactJSXDev from "react/cjs/react-jsx-dev-runtime.development.js"; +import ReactJSX from "react/cjs/react-jsx-runtime.development.js"; + +export default ReactJSXDev; + +if(!ReactJSXDev.jsx) ReactJSXDev.jsx = ReactJSX.jsx; +if(!ReactJSXDev.jsxs) ReactJSXDev.jsxs = ReactJSX.jsxs; + +export const __esmModule = true; + +export const { Fragment, jsxDEV, jsx, jsxs } = ReactJSXDev; diff --git a/src/jsx-dev-runtime.production.js b/src/jsx-dev-runtime.production.js new file mode 100644 index 0000000..4cf3ed2 --- /dev/null +++ b/src/jsx-dev-runtime.production.js @@ -0,0 +1,11 @@ +import ReactJSXDev from "react/cjs/react-jsx-dev-runtime.production.min.js"; +import ReactJSX from "react/cjs/react-jsx-runtime.production.min.js"; + +export default ReactJSXDev; + +export const __esmModule = true; + +if(!ReactJSXDev.jsx) ReactJSXDev.jsx = ReactJSX.jsx; +if(!ReactJSXDev.jsxs) ReactJSXDev.jsxs = ReactJSX.jsxs; + +export const { Fragment, jsxDEV, jsx, jsxs } = ReactJSXDev; \ No newline at end of file diff --git a/src/jsx-runtime.development.js b/src/jsx-runtime.development.js new file mode 100644 index 0000000..2b56fb5 --- /dev/null +++ b/src/jsx-runtime.development.js @@ -0,0 +1,6 @@ +import ReactJSX from "react/cjs/react-jsx-runtime.development.js"; + +export default ReactJSX; +export const __esmModule = true; + +export const { Fragment, jsx, jsxs } = ReactJSX; diff --git a/src/jsx-runtime.production.js b/src/jsx-runtime.production.js new file mode 100644 index 0000000..768c20c --- /dev/null +++ b/src/jsx-runtime.production.js @@ -0,0 +1,6 @@ +import ReactJSX from "react/cjs/react-jsx-runtime.production.min.js"; + +export default ReactJSX; +export const __esmModule = true; + +export const { Fragment, jsx, jsxs } = ReactJSX;