babel-plugin-namespace-amd-define
Advanced tools
Comparing version 2.13.2 to 2.13.3-alpha.6
183
lib/index.js
@@ -1,95 +0,90 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function () { | ||
var extraNamespaceCount = void 0; | ||
var firstDefineNamespaced = void 0; | ||
var namespaceVisitor = { | ||
Identifier: function Identifier(path) { | ||
if (path.node.name === 'define') { | ||
if (path.parent.type === 'MemberExpression' && path.parent.property === path.node) { | ||
return; | ||
} | ||
if (path.parent.type === 'ObjectProperty' && path.parent.key === path.node) { | ||
return; | ||
} | ||
var scope = void 0; | ||
// 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 (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 | ||
var namespace = this.opts.namespace || 'Liferay.Loader'; | ||
path.node.name = namespace + '.define'; | ||
firstDefineNamespaced = true; | ||
} else { | ||
// ...and appeared before, record a new extra appearance | ||
extraNamespaceCount++; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
return { | ||
visitor: { | ||
Program: { | ||
exit: function exit(path, state) { | ||
// We must traverse the AST again because the third party | ||
// transform-es2015-modules-amd emits its define() call after | ||
// Program exit :-( | ||
firstDefineNamespaced = false; | ||
extraNamespaceCount = 0; | ||
path.traverse(namespaceVisitor, { opts: state.opts }); | ||
if (extraNamespaceCount > 0) { | ||
var _babelIpc$get = babelIpc.get(state, function () { | ||
return { | ||
log: new _pluginLogger2.default() | ||
}; | ||
}), | ||
log = _babelIpc$get.log; | ||
if (firstDefineNamespaced) { | ||
log.info('namespace-amd-define', 'Namespaced first AMD define in file'); | ||
} | ||
if (extraNamespaceCount) { | ||
log.warn('namespace-amd-define', 'Found', extraNamespaceCount, 'define() calls inside the module definition', 'which have been ignored as they should never', 'be executed during runtime'); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
"use strict"; | ||
/** | ||
* © 2017 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var _babelIpc = require('liferay-npm-build-tools-common/lib/babel-ipc'); | ||
var babelIpc = _interopRequireWildcard(_babelIpc); | ||
var _pluginLogger = require('liferay-npm-build-tools-common/lib/plugin-logger'); | ||
var _pluginLogger2 = _interopRequireDefault(_pluginLogger); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
//# sourceMappingURL=index.js.map | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const babelIpc = __importStar(require("liferay-npm-build-tools-common/lib/babel-ipc")); | ||
const plugin_logger_1 = __importDefault(require("liferay-npm-build-tools-common/lib/plugin-logger")); | ||
/** | ||
* Valid babel plugin options are: | ||
* namespace: 'Liferay.Loader' | ||
* @return {object} a babel visitor | ||
*/ | ||
function default_1() { | ||
let extraNamespaceCount; | ||
let firstDefineNamespaced; | ||
const namespaceVisitor = { | ||
Identifier(path) { | ||
if (path.node.name === 'define') { | ||
if (path.parent.type === 'MemberExpression' && | ||
path.parent.property === path.node) { | ||
return; | ||
} | ||
if (path.parent.type === 'ObjectProperty' && | ||
path.parent.key === path.node) { | ||
return; | ||
} | ||
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 (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 | ||
const namespace = this.opts.namespace || 'Liferay.Loader'; | ||
path.node.name = `${namespace}.define`; | ||
firstDefineNamespaced = true; | ||
} | ||
else { | ||
// ...and appeared before, record a new extra appearance | ||
extraNamespaceCount++; | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
return { | ||
visitor: { | ||
Program: { | ||
exit(path, state) { | ||
// We must traverse the AST again because the third party | ||
// transform-es2015-modules-amd emits its define() call after | ||
// Program exit :-( | ||
firstDefineNamespaced = false; | ||
extraNamespaceCount = 0; | ||
path.traverse(namespaceVisitor, { opts: state.opts }); | ||
if (extraNamespaceCount > 0) { | ||
const { log } = babelIpc.get(state, () => ({ | ||
log: new plugin_logger_1.default(), | ||
})); | ||
if (firstDefineNamespaced) { | ||
log.info('namespace-amd-define', 'Namespaced first AMD define in file'); | ||
} | ||
if (extraNamespaceCount) { | ||
log.warn('namespace-amd-define', 'Found', extraNamespaceCount, 'define() calls inside the module definition', 'which have been ignored as they should never', 'be executed during runtime'); | ||
} | ||
} | ||
}, | ||
}, | ||
}, | ||
}; | ||
} | ||
exports.default = default_1; |
{ | ||
"name": "babel-plugin-namespace-amd-define", | ||
"version": "2.13.2", | ||
"version": "2.13.3-alpha.6+ae09044", | ||
"description": "A Babel plugin to namespace (prefix) AMD define() calls.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel --source-maps -D -d lib src --ignore '**/__tests__/**'", | ||
"prepublish": "npm run build" | ||
"copyfiles": "node ../../scripts/copyfiles.js", | ||
"build": "tsc && yarn copyfiles", | ||
"prepublish": "yarn build" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-preset-es2015": "^6.24.1" | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "2.13.3-alpha.6+ae09044" | ||
}, | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "2.13.2" | ||
} | ||
"gitHead": "ae09044beb216743cb2f1e2273aa6e055716ce64" | ||
} |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
18992
0
294
3
2
1
- Removed@mrmlnc/readdir-enhanced@2.2.1(transitive)
- Removed@nodelib/fs.stat@1.1.3(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.13.2.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedarrify@1.0.1(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-evaluate-path@0.5.0(transitive)
- Removedbabel-helper-mark-eval-scopes@0.4.3(transitive)
- Removedbabel-helper-remove-or-void@0.4.3(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-add-module-metadata@2.13.2(transitive)
- Removedbabel-plugin-minify-dead-code-elimination@0.5.0(transitive)
- Removedbabel-plugin-name-amd-modules@2.13.2(transitive)
- Removedbabel-plugin-namespace-modules@2.13.2(transitive)
- Removedbabel-plugin-normalize-requires@2.13.2(transitive)
- Removedbabel-plugin-transform-node-env-inline@0.2.0(transitive)
- Removedbabel-plugin-wrap-modules-amd@2.13.2(transitive)
- Removedbabel-preset-liferay-standard@2.13.2(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcall-me-maybe@1.0.2(transitive)
- Removedchalk@1.1.32.4.2(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddir-glob@2.0.0(transitive)
- Removeddot-prop@5.3.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesutils@2.0.3(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfast-glob@2.2.7(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfs-extra@7.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@3.1.0(transitive)
- Removedglob-to-regexp@0.3.0(transitive)
- Removedglobals@9.18.0(transitive)
- Removedglobby@8.0.2(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedignore@3.3.10(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@3.1.04.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-obj@2.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedliferay-npm-build-tools-common@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-exclude-imports@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-imports-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-peer-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-namespace-packages@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-replace-browser-modules@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-resolve-linked-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-preset-standard@2.13.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmerge@1.2.1(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-dirname@1.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedproperties@1.2.1(transitive)
- Removedread-json-sync@1.1.12.0.1(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-value@2.0.1(transitive)
- Removedslash@1.0.0(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.05.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedliferay-npm-build-tools-common@2.13.3-alpha.6+ae09044