From 4050e33f039c984be6d0a6edccb8f5d2fbcbadbd Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 12 Oct 2021 18:01:56 +0200 Subject: [PATCH] cli: remove old jest ESM transform Signed-off-by: Patrik Oldsberg --- .changeset/wise-camels-run.md | 2 ++ packages/cli/config/jestEsmTransform.js | 36 ------------------------- packages/cli/package.json | 3 --- yarn.lock | 4 +-- 4 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 packages/cli/config/jestEsmTransform.js diff --git a/.changeset/wise-camels-run.md b/.changeset/wise-camels-run.md index 1e81e2f9ac..4438032b77 100644 --- a/.changeset/wise-camels-run.md +++ b/.changeset/wise-camels-run.md @@ -11,3 +11,5 @@ To counteract the slowdown of the additional transforms that have been introduce Another change that will speed up test execution is that the transformer for `.esm.js` files has been switched. It used to be an ESM transformer based on Babel, but it is also done by sucrase now since it is significantly faster. The changes above are not strictly breaking as all tests should still work. It may however cause excessive slowdowns in projects that have configured custom transforms in the `jest` field within `package.json` files. In this case it is either best to consider removing the custom transforms, or overriding the `transformIgnorePatterns` to instead use Jest's default `'/node_modules/'` pattern. + +This change also removes the `@backstage/cli/config/jestEsmTransform.js` transform, which can be replaced by using the `@backstage/cli/config/sucraseEsmTransform.js` transform instead. diff --git a/packages/cli/config/jestEsmTransform.js b/packages/cli/config/jestEsmTransform.js deleted file mode 100644 index 742822274d..0000000000 --- a/packages/cli/config/jestEsmTransform.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const babel = require('@babel/core'); - -// We build .esm.js files with plugin:build, so to be able to load these in tests they need to be transformed -// TODO: jest is working on module support, it's possible that we can remove this in the future -module.exports = { - process(src) { - const result = babel.transform(src, { - babelrc: false, - compact: false, - plugins: [ - // This transforms the regular ESM syntax, import and export statements - require.resolve('@babel/plugin-transform-modules-commonjs'), - // This transforms dynamic `import()`, which is not supported yet in the Node.js VM API - require.resolve('babel-plugin-dynamic-import-node'), - ], - }); - - return result.code; - }, -}; diff --git a/packages/cli/package.json b/packages/cli/package.json index 53c1b06e76..426c4fd1ac 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,8 +28,6 @@ "backstage-cli": "bin/backstage-cli" }, "dependencies": { - "@babel/core": "^7.4.4", - "@babel/plugin-transform-modules-commonjs": "^7.4.4", "@backstage/cli-common": "^0.1.4", "@backstage/config": "^0.1.10", "@backstage/config-loader": "^0.6.10", @@ -54,7 +52,6 @@ "@typescript-eslint/eslint-plugin": "^v4.30.0", "@typescript-eslint/parser": "^v4.28.3", "@yarnpkg/lockfile": "^1.1.0", - "babel-plugin-dynamic-import-node": "^2.3.3", "bfj": "^7.0.2", "buffer": "^6.0.3", "chalk": "^4.0.0", diff --git a/yarn.lock b/yarn.lock index 1a0caad7e9..521628b019 100644 --- a/yarn.lock +++ b/yarn.lock @@ -375,7 +375,7 @@ semver "^5.4.1" source-map "^0.5.0" -"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.12.10", "@babel/core@^7.12.3", "@babel/core@^7.13.16", "@babel/core@^7.4.4", "@babel/core@^7.7.5": +"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.12.10", "@babel/core@^7.12.3", "@babel/core@^7.13.16", "@babel/core@^7.7.5": version "7.14.8" resolved "https://registry.npmjs.org/@babel/core/-/core-7.14.8.tgz#20cdf7c84b5d86d83fac8710a8bc605a7ba3f010" integrity sha512-/AtaeEhT6ErpDhInbXmjHcUQXH0L0TEgscfcxk1qbOvLuKCa5aZT0SOOtDKFY96/CLROwbLSKyFor6idgNaU4Q== @@ -1536,7 +1536,7 @@ "@babel/helper-plugin-utils" "^7.14.5" babel-plugin-dynamic-import-node "^2.3.3" -"@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.13.8", "@babel/plugin-transform-modules-commonjs@^7.14.0", "@babel/plugin-transform-modules-commonjs@^7.14.5", "@babel/plugin-transform-modules-commonjs@^7.4.4": +"@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.13.8", "@babel/plugin-transform-modules-commonjs@^7.14.0", "@babel/plugin-transform-modules-commonjs@^7.14.5": version "7.14.5" resolved "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.14.5.tgz#7aaee0ea98283de94da98b28f8c35701429dad97" integrity sha512-en8GfBtgnydoao2PS+87mKyw62k02k7kJ9ltbKe0fXTHrQmG6QZZflYuGI1VVG7sVpx4E1n7KBpNlPb8m78J+A==