Socket
Socket
Sign inDemoInstall

@babel/helper-module-imports

Package Overview
Dependencies
Maintainers
6
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/helper-module-imports - npm Package Compare versions

Comparing version 7.14.5 to 7.15.4

49

lib/import-builder.js

@@ -10,4 +10,19 @@ "use strict";

var t = require("@babel/types");
var _t = require("@babel/types");
const {
callExpression,
cloneNode,
expressionStatement,
identifier,
importDeclaration,
importDefaultSpecifier,
importNamespaceSpecifier,
importSpecifier,
memberExpression,
stringLiteral,
variableDeclaration,
variableDeclarator
} = _t;
class ImportBuilder {

@@ -33,3 +48,3 @@ constructor(importedSource, scope, hub) {

import() {
this._statements.push(t.importDeclaration([], t.stringLiteral(this._importedSource)));
this._statements.push(importDeclaration([], stringLiteral(this._importedSource)));

@@ -40,3 +55,3 @@ return this;

require() {
this._statements.push(t.expressionStatement(t.callExpression(t.identifier("require"), [t.stringLiteral(this._importedSource)])));
this._statements.push(expressionStatement(callExpression(identifier("require"), [stringLiteral(this._importedSource)])));

@@ -55,4 +70,4 @@ return this;

statement.specifiers = [t.importNamespaceSpecifier(local)];
this._resultName = t.cloneNode(local);
statement.specifiers = [importNamespaceSpecifier(local)];
this._resultName = cloneNode(local);
return this;

@@ -69,4 +84,4 @@ }

statement.specifiers = [t.importDefaultSpecifier(name)];
this._resultName = t.cloneNode(name);
statement.specifiers = [importDefaultSpecifier(name)];
this._resultName = cloneNode(name);
return this;

@@ -84,4 +99,4 @@ }

statement.specifiers = [t.importSpecifier(name, t.identifier(importName))];
this._resultName = t.cloneNode(name);
statement.specifiers = [importSpecifier(name, identifier(importName))];
this._resultName = cloneNode(name);
return this;

@@ -97,3 +112,3 @@ }

statement = t.expressionStatement(this._resultName);
statement = expressionStatement(this._resultName);

@@ -103,4 +118,4 @@ this._statements.push(statement);

this._statements[this._statements.length - 1] = t.variableDeclaration("var", [t.variableDeclarator(name, statement.expression)]);
this._resultName = t.cloneNode(name);
this._statements[this._statements.length - 1] = variableDeclaration("var", [variableDeclarator(name, statement.expression)]);
this._resultName = cloneNode(name);
return this;

@@ -121,7 +136,7 @@ }

if (statement.type === "ExpressionStatement") {
statement.expression = t.callExpression(callee, [statement.expression]);
statement.expression = callExpression(callee, [statement.expression]);
} else if (statement.type === "VariableDeclaration") {
_assert(statement.declarations.length === 1);
statement.declarations[0].init = t.callExpression(callee, [statement.declarations[0].init]);
statement.declarations[0].init = callExpression(callee, [statement.declarations[0].init]);
} else {

@@ -138,7 +153,7 @@ _assert.fail("Unexpected type.");

if (statement.type === "ExpressionStatement") {
statement.expression = t.memberExpression(statement.expression, t.identifier(name));
statement.expression = memberExpression(statement.expression, identifier(name));
} else if (statement.type === "VariableDeclaration") {
_assert(statement.declarations.length === 1);
statement.declarations[0].init = t.memberExpression(statement.declarations[0].init, t.identifier(name));
statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name));
} else {

@@ -152,3 +167,3 @@ _assert.fail("Unexpected type:" + statement.type);

read(name) {
this._resultName = t.memberExpression(this._resultName, t.identifier(name));
this._resultName = memberExpression(this._resultName, identifier(name));
}

@@ -155,0 +170,0 @@

@@ -10,3 +10,3 @@ "use strict";

var t = require("@babel/types");
var _t = require("@babel/types");

@@ -17,2 +17,7 @@ var _importBuilder = require("./import-builder");

const {
numericLiteral,
sequenceExpression
} = _t;
class ImportInjector {

@@ -251,3 +256,3 @@ constructor(path, importedSource, opts) {

if ((isDefault || isNamed) && ensureNoContext && resultName.type !== "Identifier") {
return t.sequenceExpression([t.numericLiteral(0), resultName]);
return sequenceExpression([numericLiteral(0), resultName]);
}

@@ -254,0 +259,0 @@

{
"name": "@babel/helper-module-imports",
"version": "7.14.5",
"version": "7.15.4",
"description": "Babel helper functions for inserting module loads",

@@ -18,7 +18,7 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/types": "^7.14.5"
"@babel/types": "^7.15.4"
},
"devDependencies": {
"@babel/core": "7.14.5",
"@babel/traverse": "7.14.5"
"@babel/core": "7.15.4",
"@babel/traverse": "7.15.4"
},

@@ -25,0 +25,0 @@ "engines": {

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