From b206d2ee55bd3a766bb94a5facfa290e84aa5748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bazyli=20Brzo=CC=81ska?= Date: Thu, 23 Jun 2016 01:12:22 +0200 Subject: [PATCH] fix(build-resources): allow local paths in module build resources --- src/build-resources.js | 10 ++++++++-- test/build-resources.js | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/build-resources.js b/src/build-resources.js index a6afb09..59734b0 100644 --- a/src/build-resources.js +++ b/src/build-resources.js @@ -267,8 +267,14 @@ function getResourcesOfPackage(resources = {}, packagePath = undefined, relative let fromPaths = Array.isArray(resource.path) ? resource.path : [resource.path]; for (let fromPath of fromPaths) { debug(`<${externalModule || path.basename(packagePath)}> [resolving] '${fromPath}'`); - if (externalModule && fromPath.indexOf('.') !== 0) - fromPath = fixRelativeFromPath(fromPath, undefined, undefined, externalModule); + + if (externalModule) { + if (fromPath.indexOf('.') !== 0) // origin unsure, could be external // + fromPath = fixRelativeFromPath(fromPath, undefined, undefined, externalModule); + else // we know it will be local from within the module + fromPath = path.join(externalModule, fromPath); + } + processFromPath(resources, fromPath, resource, packagePath, relativeToDir, overrideBlock); } } diff --git a/test/build-resources.js b/test/build-resources.js index 3595851..d796382 100644 --- a/test/build-resources.js +++ b/test/build-resources.js @@ -39,6 +39,7 @@ var filesExpectedToLoad = [ 'node_modules/external-3/dist/commonjs/sub/resource-4.js', 'node_modules/external-3/dist/commonjs/sub/resource-5.html', 'node_modules/external-3/dist/commonjs/sub/resource-6.js', + 'aurelia-framework', 'node_modules/aurelia-templating-resources/dist/commonjs/compose.js', 'node_modules/aurelia-templating-resources/dist/commonjs/compose.html', 'node_modules/aurelia-templating-resources/dist/commonjs/compose.js', @@ -87,6 +88,7 @@ var expectedRequireStrings = [ 'external-3/sub/resource-4.js', 'external-3/sub/resource-5.html', 'external-3/dist/commonjs/sub/resource-6.js', + 'aurelia-framework', 'aurelia-templating-resources/compose', 'aurelia-templating-resources/compose.html', 'aurelia-templating-resources/compose.js', @@ -126,8 +128,8 @@ describe('Dependency resolution', function () { filesLoaded.push(resolved[key].source.replace(__dirname + path.sep, '')); } - // console.log(requireStrings) - // console.log(filesLoaded) + console.log(requireStrings) + console.log(filesLoaded) assert.sameMembers(requireStrings, expectedRequireStrings); assert.sameMembers(filesLoaded, filesExpectedToLoad);