Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@umijs/babel-plugin-import-to-await-require

Package Overview
Dependencies
Maintainers
14
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@umijs/babel-plugin-import-to-await-require - npm Package Compare versions

Comparing version 3.3.0 to 3.3.1

51

lib/index.js

@@ -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,
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc