Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-modules-umd

Package Overview
Dependencies
Maintainers
4
Versions
77
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.22.5 to 8.0.0-alpha.0

82

lib/index.js

@@ -1,15 +0,10 @@

"use strict";
import { declare } from '@babel/helper-plugin-utils';
import { basename, extname } from 'path';
import { isModule, getModuleName, rewriteModuleStatementsAndPrepareHeader, hasExports, isSideEffectImport, wrapInterop, buildNamespaceInitStatements, ensureStatementsHoisted } from '@babel/helper-module-transforms';
import { template, types } from '@babel/core';
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)(`
const buildPrerequisiteAssignment = template(`
GLOBAL_REFERENCE = GLOBAL_REFERENCE || {}
`);
const buildWrapper = (0, _core.template)(`
const buildWrapper = template(`
(function (global, factory) {

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

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

@@ -46,7 +40,7 @@ const {

} = options;
const constantReexports = (_api$assumption = api.assumption("constantReexports")) != null ? _api$assumption : options.loose;
const enumerableModuleMeta = (_api$assumption2 = api.assumption("enumerableModuleMeta")) != null ? _api$assumption2 : options.loose;
const constantReexports = api.assumption("constantReexports") ?? options.loose;
const enumerableModuleMeta = api.assumption("enumerableModuleMeta") ?? options.loose;
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 = types.memberExpression(types.identifier("global"), types.identifier(types.toIdentifier(moduleNameOrBasename)));
let initAssignments = [];

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

initAssignments.push(buildPrerequisiteAssignment({
GLOBAL_REFERENCE: _core.types.cloneNode(accum)
GLOBAL_REFERENCE: types.cloneNode(accum)
}));
return _core.types.memberExpression(accum, _core.types.identifier(curr));
}, _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(members[0])));
return types.memberExpression(accum, types.identifier(curr));
}, types.memberExpression(types.identifier("global"), types.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(types.expressionStatement(types.assignmentExpression("=", globalToAssign, types.memberExpression(types.identifier("mod"), types.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) => types.memberExpression(accum, types.identifier(curr)), types.identifier("global"));
} else {
memberExpression = _core.types.memberExpression(_core.types.identifier("global"), _core.types.identifier(_core.types.toIdentifier(source)));
memberExpression = types.memberExpression(types.identifier("global"), types.identifier(types.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 = types.memberExpression(types.identifier("global"), types.identifier(types.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 = types.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(types.stringLiteral("exports"));
commonjsArgs.push(types.identifier("exports"));
browserArgs.push(types.memberExpression(types.identifier("mod"), types.identifier("exports")));
importNames.push(types.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(types.stringLiteral(source));
commonjsArgs.push(types.callExpression(types.identifier("require"), [types.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(types.identifier(metadata.name));
if (!isSideEffectImport(metadata)) {
const interop = wrapInterop(path, types.identifier(metadata.name), metadata.interop);
if (interop) {
const header = _core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(metadata.name), interop));
const header = types.expressionStatement(types.assignmentExpression("=", types.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: types.arrayExpression(amdArgs),
COMMONJS_ARGUMENTS: commonjsArgs,

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

});
exports.default = _default;
export { index as default };
//# sourceMappingURL=index.js.map
{
"name": "@babel/plugin-transform-modules-umd",
"version": "7.22.5",
"version": "8.0.0-alpha.0",
"description": "This plugin transforms ES2015 modules to UMD",

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

"dependencies": {
"@babel/helper-module-transforms": "^7.22.5",
"@babel/helper-plugin-utils": "^7.22.5"
"@babel/helper-module-transforms": "^8.0.0-alpha.0",
"@babel/helper-plugin-utils": "^8.0.0-alpha.0"
},

@@ -25,14 +25,18 @@ "keywords": [

"peerDependencies": {
"@babel/core": "^7.0.0-0"
"@babel/core": "^8.0.0-alpha.0"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/helper-plugin-test-runner": "^7.22.5",
"@babel/plugin-external-helpers": "^7.22.5"
"@babel/core": "^8.0.0-alpha.0",
"@babel/helper-plugin-test-runner": "^8.0.0-alpha.0",
"@babel/plugin-external-helpers": "^8.0.0-alpha.0"
},
"engines": {
"node": ">=6.9.0"
"node": "^16.20.0 || ^18.16.0 || >=20.0.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"type": "module"
}

@@ -5,3 +5,3 @@ # @babel/plugin-transform-modules-umd

See our website [@babel/plugin-transform-modules-umd](https://babeljs.io/docs/en/babel-plugin-transform-modules-umd) for more information.
See our website [@babel/plugin-transform-modules-umd](https://babeljs.io/docs/babel-plugin-transform-modules-umd) for more information.

@@ -8,0 +8,0 @@ ## Install

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