From bf6fcb81dbce4b5ccfde789a5dd79b65dd73c38f Mon Sep 17 00:00:00 2001 From: Charles Suh Date: Tue, 9 Nov 2021 17:16:14 -0800 Subject: [PATCH] fix: use file extension for absolute helper imports in `@babel/plugin-transform-runtime` --- packages/babel-plugin-transform-runtime/src/index.ts | 8 ++++---- .../test/fixtures/absoluteRuntime/relative/output.js | 2 +- .../test/fixtures/absoluteRuntime/true/output.js | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/babel-plugin-transform-runtime/src/index.ts b/packages/babel-plugin-transform-runtime/src/index.ts index f1c48fb588a4..98cbf9ebb635 100644 --- a/packages/babel-plugin-transform-runtime/src/index.ts +++ b/packages/babel-plugin-transform-runtime/src/index.ts @@ -165,7 +165,7 @@ export default declare((api, options, dirname) => { }; } - const corejsExt = absoluteRuntime ? ".js" : ""; + const ext = absoluteRuntime ? ".js" : ""; return { name: "transform-runtime", @@ -178,7 +178,7 @@ export default declare((api, options, dirname) => { [pluginsCompat]: { runtimeVersion, useBabelRuntime: modulePath, - ext: corejsExt, + ext, }, }, createRegeneratorPlugin({ @@ -193,7 +193,7 @@ export default declare((api, options, dirname) => { method: "usage-pure", version: 3, proposals, - [pluginsCompat]: { useBabelRuntime: modulePath, ext: corejsExt }, + [pluginsCompat]: { useBabelRuntime: modulePath, ext }, }, createRegeneratorPlugin({ method: "usage-pure", @@ -233,7 +233,7 @@ export default declare((api, options, dirname) => { : "helpers"; return addDefaultImport( - `${modulePath}/${helpersDir}/${name}`, + `${modulePath}/${helpersDir}/${name}${ext}`, name, blockHoist, true, diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/output.js index 4e7a5218225f..8b22aebeabe2 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/output.js @@ -1,4 +1,4 @@ -var _classCallCheck = require("/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/subfolder/node_modules/@babel/runtime/helpers/classCallCheck"); +var _classCallCheck = require("/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/relative/subfolder/node_modules/@babel/runtime/helpers/classCallCheck.js"); let Foo = function Foo() { "use strict"; diff --git a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/true/output.js b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/true/output.js index e1b6927ae714..171f958ee914 100644 --- a/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/true/output.js +++ b/packages/babel-plugin-transform-runtime/test/fixtures/absoluteRuntime/true/output.js @@ -1,4 +1,4 @@ -var _classCallCheck = require("/packages/babel-runtime/helpers/classCallCheck"); +var _classCallCheck = require("/packages/babel-runtime/helpers/classCallCheck.js"); let Foo = function Foo() { "use strict";