New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-system-import-transformer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-system-import-transformer - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

48

index.js

@@ -38,12 +38,42 @@ module.exports = function (babel) {

}
this.globalIdentifier = t.identifier('global');
var name = 'system-import-transformer-global-identifier';
var ref = t.conditionalExpression(
t.binaryExpression('!==',
t.unaryExpression('typeof', t.identifier('window')),
t.literal('undefined')
),
t.identifier('window'),
t.identifier('self')
);
this.globalIdentifier = this.getOrCreateHelper(name, ref);
return this.globalIdentifier;
};
SystemImportExpressionTransformer.prototype.getGlobalVarDeclaration = function () {
if (this.globalVarDeclaration) {
return this.globalVarDeclaration;
SystemImportExpressionTransformer.prototype.getOrCreateHelper = function (name, ref) {
var declar = this.file.declarations[name];
if (declar) {
return declar;
}
this.globalVarDeclaration = t.variableDeclaration('var', [t.variableDeclarator(this.getGlobalIdentifier(), t.identifier('window'))]);
return this.globalVarDeclaration;
var uid = this.file.declarations[name] = this.file.scope.generateUidIdentifier(name);
this.file.usedHelpers[name] = true;
if (t.isFunctionExpression(ref) && !ref.id) {
ref.body._compact = true;
ref._generated = true;
ref.id = uid;
ref.type = "FunctionDeclaration";
this.file.attachAuxiliaryComment(ref);
this.file.path.unshiftContainer("body", ref);
} else {
ref._compact = true;
this.file.scope.push({
id: uid,
init: ref,
unique: true
});
}
return uid;
};

@@ -179,4 +209,2 @@

SystemImportExpressionTransformer.prototype.createTransformedExpression = function () {
var globalVarDeclaration = this.getGlobalVarDeclaration();
var amdTest = this.getAmdTest();

@@ -198,3 +226,3 @@

if (this.file.opts.modules === 'amd') {
moduleImportExpressions = [globalVarDeclaration, amdRequire];
moduleImportExpressions = [amdRequire];
} else if (this.file.opts.modules === 'common') {

@@ -210,3 +238,3 @@ moduleImportExpressions = [commonJSRequire];

);
moduleImportExpressions = [globalVarDeclaration, umdRequire];
moduleImportExpressions = [umdRequire];
}

@@ -213,0 +241,0 @@

{
"name": "babel-plugin-system-import-transformer",
"version": "1.1.3",
"version": "1.1.4",
"description": "Babel plugin that replaces System.import with the equivalent UMD pattern",

@@ -5,0 +5,0 @@ "main": "index.js",

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