Skip to content

Commit

Permalink
Node modules compatibility: add ".js" extension to imported polyfills
Browse files Browse the repository at this point in the history
  • Loading branch information
shimataro authored and nicolo-ribaudo committed Oct 19, 2019
1 parent fe258de commit 071d622
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/babel-plugin-transform-runtime/src/index.js
Expand Up @@ -254,7 +254,7 @@ export default declare((api, options, dirname) => {
if (cached) {
cached = t.cloneNode(cached);
} else {
cached = addDefault(file.path, source, {
cached = addDefault(file.path, `${source}.js`, {
importedInterop: "uncompiled",
nameHint,
blockHoist,
Expand All @@ -275,7 +275,7 @@ export default declare((api, options, dirname) => {
if (name === "regeneratorRuntime" && useRuntimeRegenerator) {
path.replaceWith(
this.addDefaultImport(
`${modulePath}/regenerator`,
`${modulePath}/regenerator/index`,
"regeneratorRuntime",
),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-preset-env/src/utils.js
Expand Up @@ -152,11 +152,11 @@ export function isPolyfillSource(source: ?string): boolean {
}

const modulePathMap = {
"regenerator-runtime": "regenerator-runtime/runtime",
"regenerator-runtime": "regenerator-runtime/runtime.js",
};

export function getModulePath(mod: string): string {
return modulePathMap[mod] || `core-js/modules/${mod}`;
return modulePathMap[mod] || `core-js/modules/${mod}.js`;
}

export function createImport(path: NodePath, mod: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
@@ -1,5 +1,5 @@
import _Array$from from "../../core-js/array/from";
import _isIterable from "../../core-js/is-iterable";
import _Array$from from "../../core-js/array/from.js";
import _isIterable from "../../core-js/is-iterable.js";
export default function _iterableToArray(iter) {
if (_isIterable(Object(iter)) || Object.prototype.toString.call(iter) === "[object Arguments]") return _Array$from(iter);
}
4 changes: 2 additions & 2 deletions packages/babel-runtime-corejs2/helpers/iterableToArray.js
@@ -1,6 +1,6 @@
var _Array$from = require("../core-js/array/from");
var _Array$from = require("../core-js/array/from.js");

var _isIterable = require("../core-js/is-iterable");
var _isIterable = require("../core-js/is-iterable.js");

function _iterableToArray(iter) {
if (_isIterable(Object(iter)) || Object.prototype.toString.call(iter) === "[object Arguments]") return _Array$from(iter);
Expand Down

0 comments on commit 071d622

Please sign in to comment.