Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-modules-amd

Package Overview
Dependencies
84
Maintainers
6
Versions
84
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0-beta.43 to 7.0.0-beta.44

96

lib/index.js

@@ -9,5 +9,5 @@ "use strict";

function _helperPluginUtils() {
const data = require("@babel/helper-plugin-utils");
var data = require("@babel/helper-plugin-utils");
_helperPluginUtils = function () {
_helperPluginUtils = function _helperPluginUtils() {
return data;

@@ -20,5 +20,5 @@ };

function _helperModuleTransforms() {
const data = require("@babel/helper-module-transforms");
var data = require("@babel/helper-module-transforms");
_helperModuleTransforms = function () {
_helperModuleTransforms = function _helperModuleTransforms() {
return data;

@@ -31,5 +31,5 @@ };

function _core() {
const data = require("@babel/core");
var data = require("@babel/core");
_core = function () {
_core = function _core() {
return data;

@@ -41,36 +41,32 @@ };

const buildWrapper = (0, _core().template)(`
define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) {
})
`);
var buildWrapper = (0, _core().template)("\n define(MODULE_NAME, AMD_ARGUMENTS, function(IMPORT_NAMES) {\n })\n");
var _default = (0, _helperPluginUtils().declare)((api, options) => {
var _default = (0, _helperPluginUtils().declare)(function (api, options) {
api.assertVersion(7);
const {
loose,
allowTopLevelThis,
strict,
strictMode,
noInterop
} = options;
var loose = options.loose,
allowTopLevelThis = options.allowTopLevelThis,
strict = options.strict,
strictMode = options.strictMode,
noInterop = options.noInterop;
return {
visitor: {
Program: {
exit(path) {
exit: function exit(path) {
if (!(0, _helperModuleTransforms().isModule)(path)) return;
let moduleName = this.getModuleName();
var moduleName = this.getModuleName();
if (moduleName) moduleName = _core().types.stringLiteral(moduleName);
const {
meta,
headers
} = (0, _helperModuleTransforms().rewriteModuleStatementsAndPrepareHeader)(path, {
loose,
strict,
strictMode,
allowTopLevelThis,
noInterop
});
const amdArgs = [];
const importNames = [];
var _rewriteModuleStateme = (0, _helperModuleTransforms().rewriteModuleStatementsAndPrepareHeader)(path, {
loose: loose,
strict: strict,
strictMode: strictMode,
allowTopLevelThis: allowTopLevelThis,
noInterop: noInterop
}),
meta = _rewriteModuleStateme.meta,
headers = _rewriteModuleStateme.headers;
var amdArgs = [];
var importNames = [];
if ((0, _helperModuleTransforms().hasExports)(meta)) {

@@ -81,3 +77,17 @@ amdArgs.push(_core().types.stringLiteral("exports"));

for (const [source, metadata] of meta.source) {
for (var _iterator = meta.source, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var _ref2 = _ref,
source = _ref2[0],
metadata = _ref2[1];
amdArgs.push(_core().types.stringLiteral(source));

@@ -87,6 +97,6 @@ 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);
var interop = (0, _helperModuleTransforms().wrapInterop)(path, _core().types.identifier(metadata.name), metadata.interop);
if (interop) {
const header = _core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.identifier(metadata.name), interop));
var header = _core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.identifier(metadata.name), interop));

@@ -98,3 +108,3 @@ header.loc = metadata.loc;

headers.push(...(0, _helperModuleTransforms().buildNamespaceInitStatements)(meta, metadata, loose));
headers.push.apply(headers, (0, _helperModuleTransforms().buildNamespaceInitStatements)(meta, metadata, loose));
}

@@ -104,9 +114,8 @@

path.unshiftContainer("body", headers);
const {
body,
directives
} = path.node;
var _path$node = path.node,
body = _path$node.body,
directives = _path$node.directives;
path.node.directives = [];
path.node.body = [];
const amdWrapper = path.pushContainer("body", [buildWrapper({
var amdWrapper = path.pushContainer("body", [buildWrapper({
MODULE_NAME: moduleName,

@@ -116,7 +125,8 @@ AMD_ARGUMENTS: _core().types.arrayExpression(amdArgs),

})])[0];
const amdFactory = amdWrapper.get("expression.arguments").filter(arg => arg.isFunctionExpression())[0].get("body");
var amdFactory = amdWrapper.get("expression.arguments").filter(function (arg) {
return arg.isFunctionExpression();
})[0].get("body");
amdFactory.pushContainer("directives", directives);
amdFactory.pushContainer("body", body);
}
}

@@ -123,0 +133,0 @@ }

{
"name": "@babel/plugin-transform-modules-amd",
"version": "7.0.0-beta.43",
"version": "7.0.0-beta.44",
"description": "This plugin transforms ES2015 modules to AMD",

@@ -9,4 +9,4 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-amd",

"dependencies": {
"@babel/helper-module-transforms": "7.0.0-beta.43",
"@babel/helper-plugin-utils": "7.0.0-beta.43"
"@babel/helper-module-transforms": "7.0.0-beta.44",
"@babel/helper-plugin-utils": "7.0.0-beta.44"
},

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

"peerDependencies": {
"@babel/core": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.43",
"@babel/helper-plugin-test-runner": "7.0.0-beta.43"
"@babel/core": "7.0.0-beta.44",
"@babel/helper-plugin-test-runner": "7.0.0-beta.44"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc