babel-plugin-globals
Advanced tools
Comparing version 2.0.1 to 3.0.0
25
index.js
@@ -166,13 +166,16 @@ 'use strict'; | ||
var replacements = []; | ||
nodePath.node.specifiers.forEach(function(specifier) { | ||
var expr = getGlobalExpression( | ||
state, | ||
removeExtensions(nodePath.node.source.value), | ||
specifier.imported ? specifier.imported.name : null, | ||
t.isImportNamespaceSpecifier(specifier) | ||
); | ||
replacements.push(t.variableDeclaration('var', [ | ||
t.variableDeclarator(specifier.local, expr) | ||
])); | ||
}); | ||
if ( nodePath.node.source.value.match(/^[\./]/) ) { | ||
nodePath.node.specifiers.forEach(function(specifier) { | ||
var expr = getGlobalExpression( | ||
state, | ||
removeExtensions(nodePath.node.source.value), | ||
specifier.imported ? specifier.imported.name : null, | ||
t.isImportNamespaceSpecifier(specifier) | ||
); | ||
replacements.push(t.variableDeclaration('var', [ | ||
t.variableDeclarator(specifier.local, expr) | ||
])); | ||
}); | ||
} | ||
nodePath.replaceWithMultiple(replacements); | ||
@@ -179,0 +182,0 @@ }, |
{ | ||
"name": "babel-plugin-globals", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "A babel plugin that exposes ES6 modules to global variables.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -21,2 +21,5 @@ babel-plugin-globals | ||
Import statements will be removed if the imported file is not a relative or absolute path. | ||
This allows for CDN hosted libraries to be explicitly imported in code whilst still retaining the globals import system. | ||
## API | ||
@@ -23,0 +26,0 @@ This plugin requires passing the following plugin/babel options (besides adding the plugin): |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12587
249
43