babel-plugin-namespace-amd-define
Advanced tools
Comparing version 2.18.5 to 2.18.6
@@ -38,15 +38,7 @@ "use strict"; | ||
} | ||
let scope; | ||
// Find if 'define' is defined in any scope | ||
for (scope = path.scope; scope != null; scope = scope.parent) { | ||
if (scope.bindings.define || scope.globals.define) { | ||
break; | ||
} | ||
if (path.parent.type !== 'CallExpression') { | ||
return; | ||
} | ||
if (scope == null || | ||
(scope.parent == null && !scope.bindings.define)) { | ||
// If 'define' is not defined in any scope namespace or | ||
// defined in the root scope as global... | ||
if (!firstDefineNamespaced) { | ||
// ...and it's its first appearance, namespace it | ||
if (!firstDefineNamespaced) { | ||
if (path.scope.parent === null) { | ||
const namespace = this.opts.namespace || 'Liferay.Loader'; | ||
@@ -56,7 +48,6 @@ path.node.name = `${namespace}.define`; | ||
} | ||
else { | ||
// ...and appeared before, record a new extra appearance | ||
extraNamespaceCount++; | ||
} | ||
} | ||
else { | ||
extraNamespaceCount++; | ||
} | ||
} | ||
@@ -63,0 +54,0 @@ }, |
{ | ||
"name": "babel-plugin-namespace-amd-define", | ||
"version": "2.18.5", | ||
"version": "2.18.6", | ||
"description": "A Babel plugin to namespace (prefix) AMD define() calls.", | ||
@@ -12,5 +12,5 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "2.18.5" | ||
"liferay-npm-build-tools-common": "2.18.6" | ||
}, | ||
"gitHead": "42b661cdef42808ef63cb684b4b59185bfa0325c" | ||
"gitHead": "ceb4fedf4039b79ac776c6c70404ff5342c4baf9" | ||
} |
@@ -20,3 +20,3 @@ /** | ||
it('logs results correctly', () => { | ||
it('logs nothing when only one define appears', () => { | ||
const source = ` | ||
@@ -34,2 +34,17 @@ define([], function(){}) | ||
expect(logger.messages).toEqual([]); | ||
}); | ||
it('logs warnings when more than one global define appears', () => { | ||
const source = ` | ||
define([], function(){ | ||
define("something"); | ||
}) | ||
`; | ||
babel.transform(source, { | ||
filename: __filename, | ||
plugins: [plugin], | ||
}); | ||
expect(logger.messages).toMatchSnapshot(); | ||
@@ -36,0 +51,0 @@ }); |
@@ -35,19 +35,8 @@ /** | ||
let scope; | ||
// Find if 'define' is defined in any scope | ||
for (scope = path.scope; scope != null; scope = scope.parent) { | ||
if (scope.bindings.define || scope.globals.define) { | ||
break; | ||
} | ||
if (path.parent.type !== 'CallExpression') { | ||
return; | ||
} | ||
if ( | ||
scope == null || | ||
(scope.parent == null && !scope.bindings.define) | ||
) { | ||
// If 'define' is not defined in any scope namespace or | ||
// defined in the root scope as global... | ||
if (!firstDefineNamespaced) { | ||
// ...and it's its first appearance, namespace it | ||
if (!firstDefineNamespaced) { | ||
if (path.scope.parent === null) { | ||
const namespace = | ||
@@ -59,6 +48,5 @@ this.opts.namespace || 'Liferay.Loader'; | ||
firstDefineNamespaced = true; | ||
} else { | ||
// ...and appeared before, record a new extra appearance | ||
extraNamespaceCount++; | ||
} | ||
} else { | ||
extraNamespaceCount++; | ||
} | ||
@@ -65,0 +53,0 @@ } |
Sorry, the diff of this file is not supported yet
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
18276
283
+ Addedbabel-plugin-add-module-metadata@2.18.6(transitive)
+ Addedbabel-plugin-alias-modules@2.18.6(transitive)
+ Addedbabel-plugin-name-amd-modules@2.18.6(transitive)
+ Addedbabel-plugin-namespace-modules@2.18.6(transitive)
+ Addedbabel-plugin-normalize-requires@2.18.6(transitive)
+ Addedbabel-plugin-wrap-modules-amd@2.18.6(transitive)
+ Addedbabel-preset-liferay-standard@2.18.6(transitive)
+ Addedliferay-npm-build-tools-common@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-exclude-imports@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-inject-imports-dependencies@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-inject-peer-dependencies@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-namespace-packages@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-replace-browser-modules@2.18.6(transitive)
+ Addedliferay-npm-bundler-plugin-resolve-linked-dependencies@2.18.6(transitive)
+ Addedliferay-npm-bundler-preset-standard@2.18.6(transitive)
- Removedbabel-plugin-add-module-metadata@2.18.5(transitive)
- Removedbabel-plugin-alias-modules@2.18.5(transitive)
- Removedbabel-plugin-name-amd-modules@2.18.5(transitive)
- Removedbabel-plugin-namespace-modules@2.18.5(transitive)
- Removedbabel-plugin-normalize-requires@2.18.5(transitive)
- Removedbabel-plugin-wrap-modules-amd@2.18.5(transitive)
- Removedbabel-preset-liferay-standard@2.18.5(transitive)
- Removedliferay-npm-build-tools-common@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-exclude-imports@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-inject-imports-dependencies@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-inject-peer-dependencies@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-namespace-packages@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-replace-browser-modules@2.18.5(transitive)
- Removedliferay-npm-bundler-plugin-resolve-linked-dependencies@2.18.5(transitive)
- Removedliferay-npm-bundler-preset-standard@2.18.5(transitive)