liferay-npm-bundler-plugin-inject-imports-dependencies
Advanced tools
Comparing version 1.7.0-alpha.43ab330a to 1.7.0-alpha.cec3fa45
@@ -8,3 +8,4 @@ 'use strict'; | ||
exports.default = function (_ref, _ref2) { | ||
var globalConfig = _ref.globalConfig, | ||
var rootPkgJson = _ref.rootPkgJson, | ||
globalConfig = _ref.globalConfig, | ||
config = _ref.config, | ||
@@ -20,8 +21,14 @@ log = _ref.log; | ||
Object.keys(imports[namespace]).forEach(function (pkgName) { | ||
var version = imports[namespace][pkgName]; | ||
var name = namespace === '' ? pkgName : ns.addNamespace(pkgName, { name: namespace }); | ||
var localName = ns.addNamespace(pkgName, rootPkgJson); | ||
pkgJson.dependencies[name] = version; | ||
var importVersion = imports[namespace][pkgName]; | ||
var importName = namespace === '' ? pkgName : ns.addNamespace(pkgName, { name: namespace }); | ||
log.info('inject-imports-dependencies', 'Injected dependency', name + ' : ' + version); | ||
pkgJson.dependencies[importName] = importVersion; | ||
if (pkgJson.dependencies[localName] !== importVersion) { | ||
log.warn('inject-imports-dependencies', 'Injected dependency', importName + '@' + importVersion, 'which is not compatible package.json\'s constraints:', localName + '@' + pkgJson.dependencies[localName]); | ||
} else { | ||
log.info('inject-imports-dependencies', 'Injected dependency', importName + '@' + importVersion); | ||
} | ||
}); | ||
@@ -28,0 +35,0 @@ }); |
{ | ||
"name": "liferay-npm-bundler-plugin-inject-imports-dependencies", | ||
"version": "1.7.0-alpha.43ab330a", | ||
"version": "1.7.0-alpha.cec3fa45", | ||
"description": "A liferay-npm-bundler plugin to force injection of declared imports as dependencies.", | ||
@@ -15,4 +15,4 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"liferay-npm-build-tools-common": "1.7.0-alpha.43ab330a" | ||
"liferay-npm-build-tools-common": "1.7.0-alpha.cec3fa45" | ||
} | ||
} |
@@ -28,2 +28,2 @@ # liferay-npm-bundler-plugin-inject-imports-dependencies | ||
This plugin injects dependencies declared as imports inside the `.npmbundlerrc` | ||
file in the root `package.json` file. | ||
file in the `package.json` file. |
@@ -6,3 +6,6 @@ import * as ns from 'liferay-npm-build-tools-common/lib/namespace'; | ||
*/ | ||
export default function({globalConfig, config, log}, {pkgJson}) { | ||
export default function( | ||
{rootPkgJson, globalConfig, config, log}, | ||
{pkgJson} | ||
) { | ||
const imports = config.imports || globalConfig.imports || {}; | ||
@@ -14,4 +17,6 @@ | ||
Object.keys(imports[namespace]).forEach(pkgName => { | ||
const version = imports[namespace][pkgName]; | ||
const name = | ||
const localName = ns.addNamespace(pkgName, rootPkgJson); | ||
const importVersion = imports[namespace][pkgName]; | ||
const importName = | ||
namespace === '' | ||
@@ -21,11 +26,21 @@ ? pkgName | ||
pkgJson.dependencies[name] = version; | ||
pkgJson.dependencies[importName] = importVersion; | ||
log.info( | ||
'inject-imports-dependencies', | ||
'Injected dependency', | ||
`${name} : ${version}` | ||
); | ||
if (pkgJson.dependencies[localName] !== importVersion) { | ||
log.warn( | ||
'inject-imports-dependencies', | ||
'Injected dependency', | ||
`${importName}@${importVersion}`, | ||
'which is not compatible package.json\'s constraints:', | ||
`${localName}@${pkgJson.dependencies[localName]}` | ||
); | ||
} else { | ||
log.info( | ||
'inject-imports-dependencies', | ||
'Injected dependency', | ||
`${importName}@${importVersion}` | ||
); | ||
} | ||
}); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
11971
11
186
+ Addedliferay-npm-build-tools-common@1.7.0-alpha.cec3fa45(transitive)
- Removedliferay-npm-build-tools-common@1.7.0-alpha.43ab330a(transitive)