diff --git a/package.json b/package.json index 9fe6eac0..ff5f3582 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "ci-publish": "tsx scripts/publishCI.ts" }, "devDependencies": { - "@types/babel__core": "^7.20.1", "@types/fs-extra": "^11.0.1", "@types/node": "^18.17.3", "@typescript-eslint/eslint-plugin": "^5.62.0", diff --git a/packages/plugin-react/CHANGELOG.md b/packages/plugin-react/CHANGELOG.md index e342ef9d..2c828369 100644 --- a/packages/plugin-react/CHANGELOG.md +++ b/packages/plugin-react/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix [#211](https://github.com/vitejs/vite-plugin-react/issues/211): Add `@types/babel__cores` to dependencies + ## 4.0.4 (2023-07-31) - Fix [#198](https://github.com/vitejs/vite-plugin-react/discussions/198): Enable Babel if presets list is not empty diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index be09f45f..251467a5 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -42,6 +42,7 @@ "@babel/core": "^7.22.9", "@babel/plugin-transform-react-jsx-self": "^7.22.5", "@babel/plugin-transform-react-jsx-source": "^7.22.5", + "@types/babel__core": "^7.20.1", "react-refresh": "^0.14.0" }, "peerDependencies": { diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 154ee01a..7f46660f 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -145,6 +145,9 @@ export default function viteReact(opts: Options = {}): PluginOption[] { hooks.forEach((hook) => hook(babelOptions, context, config)) } } else if (typeof opts.babel !== 'function') { + // Because hooks and the callback option can mutate the Babel options + // we only create static option in this case and re-create them + // each time otherwise staticBabelOptions = createBabelOptions(opts.babel) } }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f06f3473..6147e988 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: false @@ -8,9 +8,6 @@ importers: .: devDependencies: - '@types/babel__core': - specifier: ^7.20.1 - version: 7.20.1 '@types/fs-extra': specifier: ^11.0.1 version: 11.0.1 @@ -92,6 +89,9 @@ importers: '@babel/plugin-transform-react-jsx-source': specifier: ^7.22.5 version: 7.22.5(@babel/core@7.22.9) + '@types/babel__core': + specifier: ^7.20.1 + version: 7.20.1 react-refresh: specifier: ^0.14.0 version: 0.14.0 @@ -393,14 +393,6 @@ packages: chalk: 2.4.2 js-tokens: 4.0.0 - /@babel/parser@7.22.4: - resolution: {integrity: sha512-VLLsx06XkEYqBtE5YGPwfSGwfrjnyPP5oiGty3S8pQLFDFLaS8VwWSIxkTXpcvr5zeYLE6+MBNl2npl/YnfofA==} - engines: {node: '>=6.0.0'} - hasBin: true - dependencies: - '@babel/types': 7.22.5 - dev: true - /@babel/parser@7.22.7: resolution: {integrity: sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q==} engines: {node: '>=6.0.0'} @@ -483,15 +475,6 @@ packages: transitivePeerDependencies: - supports-color - /@babel/types@7.22.4: - resolution: {integrity: sha512-Tx9x3UBHTTsMSW85WB2kphxYQVvrZ/t1FxD88IpSgIjiUJlCm9z+xWIDwyo1vffTwSqteqyznB8ZE9vYYk16zA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-string-parser': 7.22.5 - '@babel/helper-validator-identifier': 7.22.5 - to-fast-properties: 2.0.0 - dev: true - /@babel/types@7.22.5: resolution: {integrity: sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA==} engines: {node: '>=6.9.0'} @@ -1315,31 +1298,31 @@ packages: /@types/babel__core@7.20.1: resolution: {integrity: sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==} dependencies: - '@babel/parser': 7.22.4 - '@babel/types': 7.22.4 + '@babel/parser': 7.22.7 + '@babel/types': 7.22.5 '@types/babel__generator': 7.6.4 '@types/babel__template': 7.4.1 '@types/babel__traverse': 7.18.3 - dev: true + dev: false /@types/babel__generator@7.6.4: resolution: {integrity: sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==} dependencies: '@babel/types': 7.22.5 - dev: true + dev: false /@types/babel__template@7.4.1: resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==} dependencies: '@babel/parser': 7.22.7 '@babel/types': 7.22.5 - dev: true + dev: false /@types/babel__traverse@7.18.3: resolution: {integrity: sha512-1kbcJ40lLB7MHsj39U4Sh1uTd2E7rLEa79kmDpI6cy+XiXsteB3POdQomoq4FxszMrO3ZYchkhYJw7A2862b3w==} dependencies: '@babel/types': 7.22.5 - dev: true + dev: false /@types/chai-subset@1.3.3: resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} @@ -6125,5 +6108,4 @@ packages: file:playground/react/jsx-entry: resolution: {directory: playground/react/jsx-entry, type: directory} name: jsx-entry - version: 0.0.0 dev: false