Skip to content

Commit

Permalink
Update babel-plugin-dynamic-import-node
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jun 18, 2019
1 parent 6ca099a commit ab64e93
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion packages/babel-plugin-transform-modules-amd/package.json
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-plugin-transform-modules-amd/src/index.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}
)
Expand Down
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions packages/babel-plugin-transform-modules-commonjs/src/index.js
Expand Up @@ -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,
Expand Down
Expand Up @@ -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"
Expand Down
@@ -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) {
Expand Down Expand Up @@ -189,7 +190,7 @@ export default declare((api, options) => {
t.identifier(state.contextIdent),
t.identifier("import"),
),
path.node.arguments,
[getImportSource(t, path.node)],
),
);
}
Expand Down

0 comments on commit ab64e93

Please sign in to comment.