You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@babel/helper-module-imports

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.21.4-esm.2 to 7.21.4-esm.3

35

lib/import-builder.js

@@ -1,3 +0,9 @@

import assert from "assert";
import * as _t from "@babel/types";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _assert = require("assert");
var _t = require("@babel/types");
const {

@@ -17,3 +23,3 @@ callExpression,

} = _t;
export default class ImportBuilder {
class ImportBuilder {
constructor(importedSource, scope, hub) {

@@ -44,4 +50,4 @@ this._statements = [];

const statement = this._statements[this._statements.length - 1];
assert(statement.type === "ImportDeclaration");
assert(statement.specifiers.length === 0);
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importNamespaceSpecifier(local)];

@@ -54,4 +60,4 @@ this._resultName = cloneNode(local);

const statement = this._statements[this._statements.length - 1];
assert(statement.type === "ImportDeclaration");
assert(statement.specifiers.length === 0);
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importDefaultSpecifier(id)];

@@ -65,4 +71,4 @@ this._resultName = cloneNode(id);

const statement = this._statements[this._statements.length - 1];
assert(statement.type === "ImportDeclaration");
assert(statement.specifiers.length === 0);
_assert(statement.type === "ImportDeclaration");
_assert(statement.specifiers.length === 0);
statement.specifiers = [importSpecifier(id, identifier(importName))];

@@ -76,3 +82,3 @@ this._resultName = cloneNode(id);

if (statement.type !== "ExpressionStatement") {
assert(this._resultName);
_assert(this._resultName);
statement = expressionStatement(this._resultName);

@@ -96,6 +102,6 @@ this._statements.push(statement);

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

@@ -109,6 +115,6 @@ return this;

} else if (statement.type === "VariableDeclaration") {
assert(statement.declarations.length === 1);
_assert(statement.declarations.length === 1);
statement.declarations[0].init = memberExpression(statement.declarations[0].init, identifier(name));
} else {
assert.fail("Unexpected type:" + statement.type);
_assert.fail("Unexpected type:" + statement.type);
}

@@ -121,3 +127,4 @@ return this;

}
exports.default = ImportBuilder;
//# sourceMappingURL=import-builder.js.map

25

lib/import-injector.js

@@ -1,3 +0,11 @@

import assert from "assert";
import * as _t from "@babel/types";
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _assert = require("assert");
var _t = require("@babel/types");
var _importBuilder = require("./import-builder");
var _isModule = require("./is-module");
const {

@@ -7,5 +15,3 @@ numericLiteral,

} = _t;
import ImportBuilder from "./import-builder.js";
import isModule from "./is-module.js";
export default class ImportInjector {
class ImportInjector {
constructor(path, importedSource, opts) {

@@ -31,3 +37,3 @@ this._defaultOpts = {

addNamed(importName, importedSourceIn, opts) {
assert(typeof importName === "string");
_assert(typeof importName === "string");
return this._generateImport(this._applyDefaults(importedSourceIn, opts), importName);

@@ -48,3 +54,3 @@ }

} else {
assert(!opts, "Unexpected secondary arguments.");
_assert(!opts, "Unexpected secondary arguments.");
newOpts = Object.assign({}, this._defaultOpts, importedSource);

@@ -74,3 +80,3 @@ }

let name = nameHint || importName;
const isMod = isModule(this._programPath);
const isMod = (0, _isModule.default)(this._programPath);
const isModuleForNode = isMod && importingInterop === "node";

@@ -81,3 +87,3 @@ const isModuleForBabel = isMod && importingInterop === "babel";

}
const builder = new ImportBuilder(importedSource, this._programScope, this._hub);
const builder = new _importBuilder.default(importedSource, this._programScope, this._hub);
if (importedType === "es6") {

@@ -237,3 +243,4 @@ if (!isModuleForNode && !isModuleForBabel) {

}
exports.default = ImportInjector;
//# sourceMappingURL=import-injector.js.map

@@ -1,18 +0,37 @@

import ImportInjector from "./import-injector.js";
export { ImportInjector };
export { default as isModule } from "./is-module.js";
export function addDefault(path, importedSource, opts) {
return new ImportInjector(path).addDefault(importedSource, opts);
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ImportInjector", {
enumerable: true,
get: function () {
return _importInjector.default;
}
});
exports.addDefault = addDefault;
exports.addNamed = addNamed;
exports.addNamespace = addNamespace;
exports.addSideEffect = addSideEffect;
Object.defineProperty(exports, "isModule", {
enumerable: true,
get: function () {
return _isModule.default;
}
});
var _importInjector = require("./import-injector");
var _isModule = require("./is-module");
function addDefault(path, importedSource, opts) {
return new _importInjector.default(path).addDefault(importedSource, opts);
}
function addNamed(path, name, importedSource, opts) {
return new ImportInjector(path).addNamed(name, importedSource, opts);
return new _importInjector.default(path).addNamed(name, importedSource, opts);
}
export { addNamed };
export function addNamespace(path, importedSource, opts) {
return new ImportInjector(path).addNamespace(importedSource, opts);
function addNamespace(path, importedSource, opts) {
return new _importInjector.default(path).addNamespace(importedSource, opts);
}
export function addSideEffect(path, importedSource, opts) {
return new ImportInjector(path).addSideEffect(importedSource, opts);
function addSideEffect(path, importedSource, opts) {
return new _importInjector.default(path).addSideEffect(importedSource, opts);
}
//# sourceMappingURL=index.js.map

@@ -1,2 +0,8 @@

export default function isModule(path) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isModule;
function isModule(path) {
return path.node.sourceType === "module";

@@ -3,0 +9,0 @@ }

{
"name": "@babel/helper-module-imports",
"version": "7.21.4-esm.2",
"version": "7.21.4-esm.3",
"description": "Babel helper functions for inserting module loads",

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

"dependencies": {
"@babel/types": "7.21.4-esm.2"
"@babel/types": "7.21.4-esm.3"
},
"devDependencies": {
"@babel/core": "7.21.4-esm.2",
"@babel/traverse": "7.21.4-esm.2"
"@babel/core": "7.21.4-esm.3",
"@babel/traverse": "7.21.4-esm.3"
},

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc