@umijs/babel-plugin-import-to-await-require
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -19,6 +19,6 @@ "use strict"; | ||
function _utils() { | ||
const data = require("@umijs/utils"); | ||
function t() { | ||
const data = _interopRequireWildcard(require("@babel/types")); | ||
_utils = function _utils() { | ||
t = function t() { | ||
return data; | ||
@@ -30,2 +30,6 @@ }; | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -35,12 +39,12 @@ | ||
return specifiers.reduce((memo, s) => { | ||
if (_utils().t.isImportDefaultSpecifier(s)) { | ||
memo.properties.push(_utils().t.objectProperty(_utils().t.identifier('default'), s.local)); | ||
} else if (_utils().t.isExportDefaultSpecifier(s)) { | ||
memo.properties.push(_utils().t.objectProperty(_utils().t.identifier('default'), s.exported)); | ||
} else if (_utils().t.isExportSpecifier(s)) { | ||
memo.properties.push(_utils().t.objectProperty(s.local, s.exported)); | ||
} else if (_utils().t.isImportNamespaceSpecifier(s)) { | ||
if (t().isImportDefaultSpecifier(s)) { | ||
memo.properties.push(t().objectProperty(t().identifier('default'), s.local)); | ||
} else if (t().isExportDefaultSpecifier(s)) { | ||
memo.properties.push(t().objectProperty(t().identifier('default'), s.exported)); | ||
} else if (t().isExportSpecifier(s)) { | ||
memo.properties.push(t().objectProperty(s.local, s.exported)); | ||
} else if (t().isImportNamespaceSpecifier(s)) { | ||
memo.namespaceIdentifier = s.local; | ||
} else { | ||
memo.properties.push(_utils().t.objectProperty(s.imported, s.local)); | ||
memo.properties.push(t().objectProperty(s.imported, s.local)); | ||
} | ||
@@ -92,3 +96,3 @@ | ||
if (_utils().t.isImportDeclaration(d)) { | ||
if (t().isImportDeclaration(d)) { | ||
var _opts$onTransformDeps; | ||
@@ -108,14 +112,13 @@ | ||
const id = _utils().t.objectPattern(properties); | ||
const id = t().objectPattern(properties); | ||
const init = t().awaitExpression(t().callExpression(t().import(), [t().stringLiteral(`${opts.remoteName}/${getPath(d.source.value, opts.alias || {})}`)])); | ||
const init = _utils().t.awaitExpression(_utils().t.callExpression(_utils().t.import(), [_utils().t.stringLiteral(`${opts.remoteName}/${getPath(d.source.value, opts.alias || {})}`)])); | ||
if (namespaceIdentifier) { | ||
if (properties.length) { | ||
variableDeclarations.unshift(_utils().t.variableDeclaration('const', [_utils().t.variableDeclarator(id, namespaceIdentifier)])); | ||
variableDeclarations.unshift(t().variableDeclaration('const', [t().variableDeclarator(id, namespaceIdentifier)])); | ||
} | ||
variableDeclarations.unshift(_utils().t.variableDeclaration('const', [_utils().t.variableDeclarator(namespaceIdentifier, init)])); | ||
variableDeclarations.unshift(t().variableDeclaration('const', [t().variableDeclarator(namespaceIdentifier, init)])); | ||
} else { | ||
variableDeclarations.unshift(_utils().t.variableDeclaration('const', [_utils().t.variableDeclarator(id, init)])); | ||
variableDeclarations.unshift(t().variableDeclaration('const', [t().variableDeclarator(id, init)])); | ||
} | ||
@@ -127,3 +130,3 @@ | ||
if (_utils().t.isExportAllDeclaration(d) && d.source) { | ||
if (t().isExportAllDeclaration(d) && d.source) { | ||
var _opts$onTransformDeps2; | ||
@@ -140,3 +143,3 @@ | ||
if (_utils().t.isExportNamedDeclaration(d) && d.source) { | ||
if (t().isExportNamedDeclaration(d) && d.source) { | ||
var _opts$onTransformDeps3; | ||
@@ -155,7 +158,5 @@ | ||
const id = _utils().t.objectPattern(properties); | ||
const init = _utils().t.awaitExpression(_utils().t.callExpression(_utils().t.import(), [_utils().t.stringLiteral(`${opts.remoteName}/${getPath(d.source.value, opts.alias || {})}`)])); | ||
variableDeclarations.unshift(_utils().t.variableDeclaration('const', [_utils().t.variableDeclarator(id, init)])); | ||
const id = t().objectPattern(properties); | ||
const init = t().awaitExpression(t().callExpression(t().import(), [t().stringLiteral(`${opts.remoteName}/${getPath(d.source.value, opts.alias || {})}`)])); | ||
variableDeclarations.unshift(t().variableDeclaration('const', [t().variableDeclarator(id, init)])); | ||
d.source = null; | ||
@@ -162,0 +163,0 @@ } |
{ | ||
"name": "@umijs/babel-plugin-import-to-await-require", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "@umijs/babel-plugin-import-to-await-require", | ||
@@ -28,5 +28,10 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@babel/traverse": "7.12.5", | ||
"@umijs/utils": "3.3.0" | ||
"@babel/types": "7.12.6" | ||
}, | ||
"devDependencies": { | ||
"@babel/traverse": "7.12.5" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.12.3" | ||
} | ||
} |
@@ -1,3 +0,3 @@ | ||
import { t } from '@umijs/utils'; | ||
import * as traverse from '@babel/traverse'; | ||
import * as t from '@babel/types'; | ||
import type { Visitor, NodePath } from '@babel/traverse'; | ||
@@ -65,3 +65,3 @@ type TLibs = (RegExp | string)[]; | ||
Program: { | ||
exit(path: traverse.NodePath<t.Program>, { opts }: { opts: IOpts }) { | ||
exit(path: NodePath<t.Program>, { opts }: { opts: IOpts }) { | ||
const variableDeclarations = []; | ||
@@ -173,4 +173,4 @@ let index = path.node.body.length - 1; | ||
}, | ||
} as traverse.Visitor, | ||
} as Visitor, | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15614
457
1
+ Added@babel/types@7.12.6
- Removed@babel/traverse@7.12.5
- Removed@umijs/utils@3.3.0
- Removed@babel/helper-function-name@7.24.7(transitive)
- Removed@babel/helper-split-export-declaration@7.24.7(transitive)
- Removed@babel/parser@7.12.5(transitive)
- Removed@babel/register@7.12.1(transitive)
- Removed@babel/traverse@7.12.5(transitive)
- Removed@sindresorhus/is@0.14.0(transitive)
- Removed@szmarczak/http-timer@1.1.2(transitive)
- Removed@types/cheerio@0.22.21(transitive)
- Removed@types/color@3.0.1(transitive)
- Removed@types/color-convert@2.0.4(transitive)
- Removed@types/color-name@1.1.5(transitive)
- Removed@types/cross-spawn@6.0.2(transitive)
- Removed@types/debug@4.1.5(transitive)
- Removed@types/glob@7.1.3(transitive)
- Removed@types/got@9.6.11(transitive)
- Removed@types/lodash@4.14.161(transitive)
- Removed@types/minimatch@5.1.2(transitive)
- Removed@types/mkdirp@1.0.1(transitive)
- Removed@types/mustache@4.0.1(transitive)
- Removed@types/node@22.9.0(transitive)
- Removed@types/resolve@1.17.1(transitive)
- Removed@types/rimraf@3.0.0(transitive)
- Removed@types/semver@7.3.3(transitive)
- Removed@types/signale@1.4.1(transitive)
- Removed@types/tough-cookie@4.0.5(transitive)
- Removed@types/yargs@15.0.5(transitive)
- Removed@types/yargs-parser@15.0.0(transitive)
- Removed@umijs/utils@3.3.0(transitive)
- Removedaddress@1.1.2(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@3.2.14.3.0(transitive)
- Removedanymatch@3.1.3(transitive)
- Removedarch@2.2.0(transitive)
- Removedasync@2.6.4(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbinary-extensions@2.3.0(transitive)
- Removedboolbase@1.0.0(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@3.0.3(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcacheable-request@6.1.0(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedchalk@2.4.24.1.0(transitive)
- Removedcheerio@1.0.0-rc.3(transitive)
- Removedchokidar@3.4.2(transitive)
- Removedclipboardy@2.3.0(transitive)
- Removedcliui@6.0.0(transitive)
- Removedclone-response@1.0.3(transitive)
- Removedcolor@3.1.2(transitive)
- Removedcolor-convert@1.9.32.0.1(transitive)
- Removedcolor-name@1.1.31.1.4(transitive)
- Removedcolor-string@1.9.1(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcommondir@1.0.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcrequire@1.8.1(transitive)
- Removedcross-spawn@6.0.57.0.3(transitive)
- Removedcss-select@1.2.0(transitive)
- Removedcss-what@2.1.3(transitive)
- Removeddebug@3.2.74.1.1(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removeddeepmerge@4.2.2(transitive)
- Removeddefer-to-connect@1.1.3(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removeddom-serializer@0.1.1(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.4.2(transitive)
- Removeddomutils@1.5.1(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedentities@1.1.2(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexeca@1.0.04.0.3(transitive)
- Removedfigures@2.0.0(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfind-cache-dir@2.1.0(transitive)
- Removedfind-up@2.1.03.0.04.1.0(transitive)
- Removedform-data@2.5.2(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfsevents@2.1.3(transitive)
- Removedget-caller-file@2.0.5(transitive)
- Removedget-stream@4.1.05.2.0(transitive)
- Removedglob@7.1.6(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedgot@9.6.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-flag@3.0.04.0.0(transitive)
- Removedhtmlparser2@3.10.1(transitive)
- Removedhttp-cache-semantics@4.1.1(transitive)
- Removedhuman-signals@1.1.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arrayish@0.2.10.3.2(transitive)
- Removedis-binary-path@2.1.0(transitive)
- Removedis-docker@2.2.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedis-stream@1.1.02.0.1(transitive)
- Removedis-wsl@2.2.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjson-buffer@3.0.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedkeyv@3.1.0(transitive)
- Removedload-json-file@4.0.0(transitive)
- Removedlocate-path@2.0.03.0.05.0.0(transitive)
- Removedlodash@4.17.20(transitive)
- Removedlowercase-keys@1.0.12.0.0(transitive)
- Removedmake-dir@2.1.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.61.0.4(transitive)
- Removedmustache@4.0.1(transitive)
- Removednice-try@1.0.5(transitive)
- Removednormalize-path@3.0.0(transitive)
- Removednormalize-url@4.5.1(transitive)
- Removednpm-run-path@2.0.24.0.1(transitive)
- Removednth-check@1.0.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedonetime@5.1.2(transitive)
- Removedp-cancelable@1.1.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-limit@1.3.02.3.0(transitive)
- Removedp-locate@2.0.03.0.04.1.0(transitive)
- Removedp-try@1.0.02.2.0(transitive)
- Removedparse-json@4.0.0(transitive)
- Removedparse5@3.0.3(transitive)
- Removedpath-exists@3.0.04.0.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-key@2.0.13.1.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedpify@3.0.04.0.1(transitive)
- Removedpirates@4.0.6(transitive)
- Removedpkg-conf@2.1.0(transitive)
- Removedpkg-dir@3.0.0(transitive)
- Removedpkg-up@3.1.0(transitive)
- Removedportfinder@1.0.28(transitive)
- Removedprepend-http@2.0.0(transitive)
- Removedpump@3.0.2(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedreaddirp@3.4.0(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@2.0.0(transitive)
- Removedresolve@1.17.0(transitive)
- Removedresponselike@1.0.2(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.27.3.2(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedshebang-command@1.2.02.0.0(transitive)
- Removedshebang-regex@1.0.03.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedsignale@1.4.0(transitive)
- Removedsimple-swizzle@0.2.2(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-support@0.5.21(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedstrip-final-newline@2.0.0(transitive)
- Removedsupports-color@5.5.07.2.0(transitive)
- Removedto-readable-stream@1.0.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedurl-parse-lax@3.0.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwhich@1.3.12.0.2(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwrap-ansi@6.2.0(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedy18n@4.0.3(transitive)
- Removedyargs@15.4.1(transitive)
- Removedyargs-parser@18.1.3(transitive)