From 31d01acb6e2ea7b97460b0aea644b9f228d2b0a2 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Mon, 19 Jun 2023 09:34:15 +0100 Subject: [PATCH] Make Babel a dependency unless bundled --- package-lock.json | 39 ++++++++++++++++++- packages/govuk-frontend/package.json | 4 ++ packages/govuk-frontend/rollup.esm.config.mjs | 8 +++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6b96031a9a..0b63ad844a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1585,6 +1585,26 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-runtime": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.22.5.tgz", + "integrity": "sha512-bg4Wxd1FWeFx3daHFTWk1pkSWK/AyQuiyAoeZAOkAOUBjnZPH6KT7eMxouV47tQ6hl6ax2zyAWBdWZXbrvXlaw==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.22.5", + "@babel/helper-plugin-utils": "^7.22.5", + "babel-plugin-polyfill-corejs2": "^0.4.3", + "babel-plugin-polyfill-corejs3": "^0.8.1", + "babel-plugin-polyfill-regenerator": "^0.5.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, "node_modules/@babel/plugin-transform-shorthand-properties": { "version": "7.22.5", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.22.5.tgz", @@ -22032,8 +22052,7 @@ "node_modules/regenerator-runtime": { "version": "0.13.11", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true + "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" }, "node_modules/regenerator-transform": { "version": "0.15.1", @@ -27590,6 +27609,7 @@ "license": "MIT", "devDependencies": { "@babel/core": "^7.22.5", + "@babel/plugin-transform-runtime": "^7.22.5", "@babel/preset-env": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-replace": "^5.0.2", @@ -27619,6 +27639,9 @@ "govuk-frontend-helpers": "*", "govuk-frontend-lib": "*", "govuk-frontend-tasks": "*" + }, + "peerDependencies": { + "@babel/runtime": "^7.22.5" } }, "packages/govuk-frontend-review": { @@ -27665,6 +27688,18 @@ "npm": "^8.1.0 || ^9.1.0" } }, + "packages/govuk-frontend/node_modules/@babel/runtime": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.5.tgz", + "integrity": "sha512-ecjvYlnAaZ/KVneE/OdKYBYfgXV3Ptu6zQWmgEF7vwKhQnvVS6bjMD2XYgj+SNvQ1GfK/pjgokfPkC/2CO8CuA==", + "peer": true, + "dependencies": { + "regenerator-runtime": "^0.13.11" + }, + "engines": { + "node": ">=6.9.0" + } + }, "shared/config": { "name": "govuk-frontend-config", "license": "MIT", diff --git a/packages/govuk-frontend/package.json b/packages/govuk-frontend/package.json index f02692d3c8..7b4542eb58 100644 --- a/packages/govuk-frontend/package.json +++ b/packages/govuk-frontend/package.json @@ -53,6 +53,7 @@ }, "devDependencies": { "@babel/core": "^7.22.5", + "@babel/plugin-transform-runtime": "^7.22.5", "@babel/preset-env": "^7.22.5", "@rollup/plugin-babel": "^6.0.3", "@rollup/plugin-replace": "^5.0.2", @@ -79,5 +80,8 @@ "govuk-frontend-helpers": "*", "govuk-frontend-lib": "*", "govuk-frontend-tasks": "*" + }, + "peerDependencies": { + "@babel/runtime": "^7.22.5" } } diff --git a/packages/govuk-frontend/rollup.esm.config.mjs b/packages/govuk-frontend/rollup.esm.config.mjs index 565f51ba3c..343a964ca9 100644 --- a/packages/govuk-frontend/rollup.esm.config.mjs +++ b/packages/govuk-frontend/rollup.esm.config.mjs @@ -33,7 +33,11 @@ export default defineConfig(({ i: input }) => ({ development: pkg.version }), babel({ - babelHelpers: 'bundled' + babelHelpers: 'runtime', + plugins: ['@babel/plugin-transform-runtime'] }) - ] + ], + + // Keep Babel as a dependency + external: (id) => id.includes('@babel/runtime') }))