From ab64e9347b3ca4379e2e82be1d02f39f41f8be98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 19 Jun 2019 01:18:35 +0200 Subject: [PATCH] Update babel-plugin-dynamic-import-node --- packages/babel-plugin-transform-modules-amd/package.json | 3 ++- packages/babel-plugin-transform-modules-amd/src/index.js | 3 ++- .../babel-plugin-transform-modules-commonjs/package.json | 2 +- .../babel-plugin-transform-modules-commonjs/src/index.js | 7 ++----- .../babel-plugin-transform-modules-systemjs/package.json | 3 ++- .../babel-plugin-transform-modules-systemjs/src/index.js | 3 ++- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/babel-plugin-transform-modules-amd/package.json b/packages/babel-plugin-transform-modules-amd/package.json index f8392ea5f190..5db075a58920 100644 --- a/packages/babel-plugin-transform-modules-amd/package.json +++ b/packages/babel-plugin-transform-modules-amd/package.json @@ -10,7 +10,8 @@ "main": "lib/index.js", "dependencies": { "@babel/helper-module-transforms": "^7.1.0", - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" }, "keywords": [ "babel-plugin" diff --git a/packages/babel-plugin-transform-modules-amd/src/index.js b/packages/babel-plugin-transform-modules-amd/src/index.js index f69a8ee8d621..5ad9cd9861a3 100644 --- a/packages/babel-plugin-transform-modules-amd/src/index.js +++ b/packages/babel-plugin-transform-modules-amd/src/index.js @@ -9,6 +9,7 @@ import { wrapInterop, } from "@babel/helper-module-transforms"; import { template, types as t } from "@babel/core"; +import { getImportSource } from "babel-plugin-dynamic-import-node/utils"; const buildWrapper = template(` define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) { @@ -68,7 +69,7 @@ export default declare((api, options) => { template.expression.ast` new Promise((${resolveId}, ${rejectId}) => ${requireId}( - [${path.node.arguments[0]}], + [${getImportSource(t, path.node)}], imported => ${resolveId}(${result}), ${rejectId} ) diff --git a/packages/babel-plugin-transform-modules-commonjs/package.json b/packages/babel-plugin-transform-modules-commonjs/package.json index a29d9578f35d..93541da0cbf9 100644 --- a/packages/babel-plugin-transform-modules-commonjs/package.json +++ b/packages/babel-plugin-transform-modules-commonjs/package.json @@ -12,7 +12,7 @@ "@babel/helper-module-transforms": "^7.4.4", "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-simple-access": "^7.1.0", - "babel-plugin-dynamic-import-node": "^2.2.0" + "babel-plugin-dynamic-import-node": "^2.3.0" }, "keywords": [ "babel-plugin" diff --git a/packages/babel-plugin-transform-modules-commonjs/src/index.js b/packages/babel-plugin-transform-modules-commonjs/src/index.js index 52e6ca613aa2..11d4617f4398 100644 --- a/packages/babel-plugin-transform-modules-commonjs/src/index.js +++ b/packages/babel-plugin-transform-modules-commonjs/src/index.js @@ -10,15 +10,12 @@ import { import simplifyAccess from "@babel/helper-simple-access"; import { template, types as t } from "@babel/core"; -import babelPluginDynamicImportNode from "babel-plugin-dynamic-import-node"; +import { createDynamicImportTransform } from "babel-plugin-dynamic-import-node/utils"; export default declare((api, options) => { api.assertVersion(7); - // TODO: expose a better interface - const transformImportCall = Function.call.bind( - babelPluginDynamicImportNode(api).visitor.Import, - ); + const transformImportCall = createDynamicImportTransform(api); const { loose, diff --git a/packages/babel-plugin-transform-modules-systemjs/package.json b/packages/babel-plugin-transform-modules-systemjs/package.json index d6b9c30c2d61..fac20c289979 100644 --- a/packages/babel-plugin-transform-modules-systemjs/package.json +++ b/packages/babel-plugin-transform-modules-systemjs/package.json @@ -10,7 +10,8 @@ "main": "lib/index.js", "dependencies": { "@babel/helper-hoist-variables": "^7.4.4", - "@babel/helper-plugin-utils": "^7.0.0" + "@babel/helper-plugin-utils": "^7.0.0", + "babel-plugin-dynamic-import-node": "^2.3.0" }, "keywords": [ "babel-plugin" diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.js b/packages/babel-plugin-transform-modules-systemjs/src/index.js index 2f4d3059937d..779b76170cdc 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.js +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.js @@ -1,6 +1,7 @@ import { declare } from "@babel/helper-plugin-utils"; import hoistVariables from "@babel/helper-hoist-variables"; import { template, types as t } from "@babel/core"; +import { getImportSource } from "babel-plugin-dynamic-import-node/utils"; const buildTemplate = template(` SYSTEM_REGISTER(MODULE_NAME, SOURCES, function (EXPORT_IDENTIFIER, CONTEXT_IDENTIFIER) { @@ -189,7 +190,7 @@ export default declare((api, options) => { t.identifier(state.contextIdent), t.identifier("import"), ), - path.node.arguments, + [getImportSource(t, path.node)], ), ); }