babel-plugin-name-amd-modules
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -23,4 +23,4 @@ 'use strict'; | ||
var insertName = false, | ||
unshiftName = true; | ||
var insertName = false; | ||
var unshiftName = true; | ||
@@ -77,4 +77,6 @@ switch (args.length) { | ||
var _liferayBuildToolsUtil = require('liferay-build-tools-util'); | ||
var _packages = require('liferay-npm-build-tools-common/lib/packages'); | ||
var pkgs = _interopRequireWildcard(_packages); | ||
var _path = require('path'); | ||
@@ -90,4 +92,36 @@ | ||
// TODO: check that module names are correct in Windoze | ||
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; } } | ||
/** | ||
* Normalize the srcPrefixes Babel option adding a trailing path separator when | ||
* it is not present. | ||
* @param {object} opts the Babel plugin options | ||
* @return {Array} the normalized srcPrefixes array | ||
*/ | ||
// TODO: check that module names work correctly in Windows | ||
function getSrcPrefixes(opts) { | ||
var srcPrefixes = opts.srcPrefixes || ['src/main/resources/META-INF/resources']; | ||
return srcPrefixes.map(function (srcPrefix) { | ||
return srcPrefix.endsWith(_path2.default.sep) ? srcPrefix : srcPrefix + _path2.default.sep; | ||
}); | ||
} | ||
/** | ||
* Resolve the package name of a JS module file. | ||
* @param {String} packageName a forced package name or '<package.json>' to get | ||
* the package name from the nearest ancestor package.json file | ||
* @param {String} filenameRelative the filenameRelative path as given by Babel | ||
* compiler | ||
* @return {String} the package name ending with '/' | ||
*/ | ||
/** | ||
* Valid babel plugin options are: | ||
* packageName: '<package.json>' | ||
* srcPrefixes: ['src/main/resources/META-INF/resources'] | ||
* @return {object} a babel visitor | ||
*/ | ||
function getPackageName(packageName, filenameRelative) { | ||
@@ -97,3 +131,3 @@ packageName = packageName || '<package.json>'; | ||
if (packageName === '<package.json>') { | ||
var pkgJsonPath = (0, _liferayBuildToolsUtil.getPackageJsonPath)(filenameRelative); | ||
var pkgJsonPath = pkgs.getPackageJsonPath(filenameRelative); | ||
var pkgJson = (0, _readJsonSync2.default)(pkgJsonPath); | ||
@@ -112,11 +146,14 @@ | ||
/** | ||
* options: | ||
* packageName: '<package.json>' | ||
* srcPrefixes: ['src/main/resources/META-INF/resources'] | ||
* Get the module name of a JS module file given its path. | ||
* @param {String} filenameRelative the filenameRelative path as given by Babel | ||
* compiler | ||
* @param {Array} srcPrefixes an array of source directories where JS module | ||
* files may live | ||
* @return {String} the module name that must be assigned to the file with the | ||
* syntax: | ||
* <package name>@<package version>/<relative path without trailing .js> | ||
*/ | ||
function getModuleName(filenameRelative, srcPrefixes) { | ||
var filenameAbsolute = _path2.default.resolve(filenameRelative); | ||
var pkgDir = (0, _liferayBuildToolsUtil.getPackageDir)(filenameRelative); | ||
var pkgDir = pkgs.getPackageDir(filenameRelative); | ||
@@ -140,10 +177,2 @@ var moduleName = filenameAbsolute.substring(pkgDir.length + 1); | ||
} | ||
function getSrcPrefixes(opts) { | ||
var srcPrefixes = opts.srcPrefixes || ['src/main/resources/META-INF/resources']; | ||
return srcPrefixes.map(function (srcPrefix) { | ||
return srcPrefix.endsWith(_path2.default.sep) ? srcPrefix : srcPrefix + _path2.default.sep; | ||
}); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "babel-plugin-name-amd-modules", | ||
"version": "0.5.0", | ||
"description": "A Babel plugin to give name to anonymous AMD modules based on their path.", | ||
"version": "0.6.0", | ||
"description": "A Babel plugin to give name to AMD modules based on their path and package.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel --source-maps -D -d lib src", | ||
"prepublish": "babel --source-maps -D -d lib src" | ||
"prepublish": "npm run build" | ||
}, | ||
@@ -15,5 +15,5 @@ "devDependencies": { | ||
"dependencies": { | ||
"liferay-build-tools-util": "^0.5.0", | ||
"liferay-npm-build-tools-common": "^0.6.0", | ||
"read-json-sync": "^1.1.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
84671
14
2458
0
74
1
+ Addedliferay-npm-build-tools-common@0.6.0(transitive)
- Removedliferay-build-tools-util@^0.5.0
- Removedliferay-build-tools-util@0.5.0(transitive)