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

@babel/plugin-transform-modules-umd

Package Overview
Dependencies
Maintainers
4
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/plugin-transform-modules-umd - npm Package Compare versions

Comparing version 7.21.4-esm to 7.21.4-esm.1

77

lib/index.js

@@ -1,15 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _path = require("path");
var _helperModuleTransforms = require("@babel/helper-module-transforms");
var _core = require("@babel/core");
const buildPrerequisiteAssignment = (0, _core.template)(`
import { declare } from "@babel/helper-plugin-utils";
import { basename, extname } from "path";
import { isModule, rewriteModuleStatementsAndPrepareHeader, hasExports, isSideEffectImport, buildNamespaceInitStatements, ensureStatementsHoisted, wrapInterop, getModuleName } from "@babel/helper-module-transforms";
import { types as t, template } from "@babel/core";
const buildPrerequisiteAssignment = template(`
GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}
`);
const buildWrapper = (0, _core.template)(`
const buildWrapper = template(`
(function (global, factory) {

@@ -33,3 +27,3 @@ if (typeof define === "function" && define.amd) {

`);
var _default = (0, _helperPluginUtils.declare)((api, options) => {
export default declare((api, options) => {
var _api$assumption, _api$assumption2;

@@ -49,4 +43,4 @@ api.assertVersion(7);

function buildBrowserInit(browserGlobals, exactGlobals, filename, moduleName) {
const moduleNameOrBasename = moduleName ? moduleName.value : (0, _path.basename)(filename, (0, _path.extname)(filename));
let globalToAssign = _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(_core.types.toIdentifier(moduleNameOrBasename)));
const moduleNameOrBasename = moduleName ? moduleName.value : basename(filename, extname(filename));
let globalToAssign = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(moduleNameOrBasename)));
let initAssignments = [];

@@ -60,9 +54,9 @@ if (exactGlobals) {

initAssignments.push(buildPrerequisiteAssignment({
GLOBAL_REFERENCE: _core.types.cloneNode(accum)
GLOBAL_REFERENCE: t.cloneNode(accum)
}));
return _core.types.memberExpression(accum, _core.types.identifier(curr));
}, _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(members[0])));
return t.memberExpression(accum, t.identifier(curr));
}, t.memberExpression(t.identifier("global"), t.identifier(members[0])));
}
}
initAssignments.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", globalToAssign, _core.types.memberExpression(_core.types.identifier("mod"), _core.types.identifier("exports")))));
initAssignments.push(t.expressionStatement(t.assignmentExpression("=", globalToAssign, t.memberExpression(t.identifier("mod"), t.identifier("exports")))));
return initAssignments;

@@ -75,10 +69,10 @@ }

if (globalRef) {
memberExpression = globalRef.split(".").reduce((accum, curr) => _core.types.memberExpression(accum, _core.types.identifier(curr)), _core.types.identifier("global"));
memberExpression = globalRef.split(".").reduce((accum, curr) => t.memberExpression(accum, t.identifier(curr)), t.identifier("global"));
} else {
memberExpression = _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(_core.types.toIdentifier(source)));
memberExpression = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(source)));
}
} else {
const requireName = (0, _path.basename)(source, (0, _path.extname)(source));
const requireName = basename(source, extname(source));
const globalName = browserGlobals[requireName] || requireName;
memberExpression = _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(_core.types.toIdentifier(globalName)));
memberExpression = t.memberExpression(t.identifier("global"), t.identifier(t.toIdentifier(globalName)));
}

@@ -92,11 +86,11 @@ return memberExpression;

exit(path) {
if (!(0, _helperModuleTransforms.isModule)(path)) return;
if (!isModule(path)) return;
const browserGlobals = globals || {};
const moduleName = (0, _helperModuleTransforms.getModuleName)(this.file.opts, options);
const moduleName = getModuleName(this.file.opts, options);
let moduleNameLiteral;
if (moduleName) moduleNameLiteral = _core.types.stringLiteral(moduleName);
if (moduleName) moduleNameLiteral = t.stringLiteral(moduleName);
const {
meta,
headers
} = (0, _helperModuleTransforms.rewriteModuleStatementsAndPrepareHeader)(path, {
} = rewriteModuleStatementsAndPrepareHeader(path, {
constantReexports,

@@ -115,17 +109,17 @@ enumerableModuleMeta,

const importNames = [];
if ((0, _helperModuleTransforms.hasExports)(meta)) {
amdArgs.push(_core.types.stringLiteral("exports"));
commonjsArgs.push(_core.types.identifier("exports"));
browserArgs.push(_core.types.memberExpression(_core.types.identifier("mod"), _core.types.identifier("exports")));
importNames.push(_core.types.identifier(meta.exportName));
if (hasExports(meta)) {
amdArgs.push(t.stringLiteral("exports"));
commonjsArgs.push(t.identifier("exports"));
browserArgs.push(t.memberExpression(t.identifier("mod"), t.identifier("exports")));
importNames.push(t.identifier(meta.exportName));
}
for (const [source, metadata] of meta.source) {
amdArgs.push(_core.types.stringLiteral(source));
commonjsArgs.push(_core.types.callExpression(_core.types.identifier("require"), [_core.types.stringLiteral(source)]));
amdArgs.push(t.stringLiteral(source));
commonjsArgs.push(t.callExpression(t.identifier("require"), [t.stringLiteral(source)]));
browserArgs.push(buildBrowserArg(browserGlobals, exactGlobals, source));
importNames.push(_core.types.identifier(metadata.name));
if (!(0, _helperModuleTransforms.isSideEffectImport)(metadata)) {
const interop = (0, _helperModuleTransforms.wrapInterop)(path, _core.types.identifier(metadata.name), metadata.interop);
importNames.push(t.identifier(metadata.name));
if (!isSideEffectImport(metadata)) {
const interop = wrapInterop(path, t.identifier(metadata.name), metadata.interop);
if (interop) {
const header = _core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(metadata.name), interop));
const header = t.expressionStatement(t.assignmentExpression("=", t.identifier(metadata.name), interop));
header.loc = meta.loc;

@@ -135,5 +129,5 @@ headers.push(header);

}
headers.push(...(0, _helperModuleTransforms.buildNamespaceInitStatements)(meta, metadata, constantReexports));
headers.push(...buildNamespaceInitStatements(meta, metadata, constantReexports));
}
(0, _helperModuleTransforms.ensureStatementsHoisted)(headers);
ensureStatementsHoisted(headers);
path.unshiftContainer("body", headers);

@@ -148,3 +142,3 @@ const {

MODULE_NAME: moduleNameLiteral,
AMD_ARGUMENTS: _core.types.arrayExpression(amdArgs),
AMD_ARGUMENTS: t.arrayExpression(amdArgs),
COMMONJS_ARGUMENTS: commonjsArgs,

@@ -163,4 +157,3 @@ BROWSER_ARGUMENTS: browserArgs,

});
exports.default = _default;
//# sourceMappingURL=index.js.map
{
"name": "@babel/plugin-transform-modules-umd",
"version": "7.21.4-esm",
"version": "7.21.4-esm.1",
"description": "This plugin transforms ES2015 modules to UMD",

@@ -17,4 +17,4 @@ "repository": {

"dependencies": {
"@babel/helper-module-transforms": "^7.21.4-esm",
"@babel/helper-plugin-utils": "^7.21.4-esm"
"@babel/helper-module-transforms": "^7.21.4-esm.1",
"@babel/helper-plugin-utils": "^7.21.4-esm.1"
},

@@ -25,8 +25,8 @@ "keywords": [

"peerDependencies": {
"@babel/core": "^7.0.0-0 || 7.21.4-esm"
"@babel/core": "^7.0.0-0 || 7.21.4-esm.1"
},
"devDependencies": {
"@babel/core": "^7.21.4-esm",
"@babel/helper-plugin-test-runner": "^7.21.4-esm",
"@babel/plugin-external-helpers": "^7.21.4-esm"
"@babel/core": "^7.21.4-esm.1",
"@babel/helper-plugin-test-runner": "^7.21.4-esm.1",
"@babel/plugin-external-helpers": "^7.21.4-esm.1"
},

@@ -37,3 +37,3 @@ "engines": {

"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
"type": "module"
}

Sorry, the diff of this file is not supported yet

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