Skip to content

Commit

Permalink
fix(webpack-plugin): Windows specific paths fix
Browse files Browse the repository at this point in the history
fix an issue where paths weren't correctly normalized, causing the resulting bundle to contain moduleId's as integers instead of their names
  • Loading branch information
marktaling committed Feb 15, 2017
1 parent 0559df5 commit f5624a3
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 143 deletions.
80 changes: 41 additions & 39 deletions dist/build-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);

var processAll = exports.processAll = function () {
var ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(options) {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(options) {
var dependencies, nodeModules, packageJson;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
Expand Down Expand Up @@ -84,14 +84,15 @@ var processAll = exports.processAll = function () {
}
}, _callee, this);
}));

return function processAll(_x2) {
return ref.apply(this, arguments);
return _ref.apply(this, arguments);
};
}();

var autoresolveTemplates = function () {
var ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(resources, packagePath, srcPath) {
var templates, srcRelativeToRoot, _iterator6, _isArray6, _i6, _ref6, htmlFilePath, templateResources, _iterator7, _isArray7, _i7, _ref7, resource;
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(resources, packagePath, srcPath) {
var templates, srcRelativeToRoot, _iterator6, _isArray6, _i6, _ref8, htmlFilePath, templateResources, _iterator7, _isArray7, _i7, _ref9, resource;

return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
Expand Down Expand Up @@ -119,7 +120,7 @@ var autoresolveTemplates = function () {
return _context2.abrupt('break', 34);

case 8:
_ref6 = _iterator6[_i6++];
_ref8 = _iterator6[_i6++];
_context2.next = 15;
break;

Expand All @@ -134,10 +135,10 @@ var autoresolveTemplates = function () {
return _context2.abrupt('break', 34);

case 14:
_ref6 = _i6.value;
_ref8 = _i6.value;

case 15:
htmlFilePath = _ref6;
htmlFilePath = _ref8;
templateResources = resolveTemplateResources(htmlFilePath, srcPath);
_iterator7 = templateResources, _isArray7 = Array.isArray(_iterator7), _i7 = 0, _iterator7 = _isArray7 ? _iterator7 : (0, _getIterator3.default)(_iterator7);

Expand All @@ -155,7 +156,7 @@ var autoresolveTemplates = function () {
return _context2.abrupt('break', 32);

case 21:
_ref7 = _iterator7[_i7++];
_ref9 = _iterator7[_i7++];
_context2.next = 28;
break;

Expand All @@ -170,10 +171,10 @@ var autoresolveTemplates = function () {
return _context2.abrupt('break', 32);

case 27:
_ref7 = _i7.value;
_ref9 = _i7.value;

case 28:
resource = _ref7;
resource = _ref9;

processFromPath(resources, resource.path, resource, packagePath, srcRelativeToRoot);

Expand All @@ -192,8 +193,9 @@ var autoresolveTemplates = function () {
}
}, _callee2, this);
}));

return function autoresolveTemplates(_x8, _x9, _x10) {
return ref.apply(this, arguments);
return _ref7.apply(this, arguments);
};
}();

Expand All @@ -217,7 +219,7 @@ var modulePaths = [];
var moduleNames = [];

function installedRootModulePaths(moduleDir) {
var ensurePackageJson = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var ensurePackageJson = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

var rootModules = fileSystem.readdirSync(moduleDir).filter(function (dir) {
return !/^\./.test(dir);
Expand Down Expand Up @@ -435,18 +437,18 @@ function processFromPath(resources, fromPath, resource, packagePath, relativeToD
if (realPath) {
var htmlResources = resolveTemplateResources(realPath.source, localSrcPath, realPath.moduleName);
for (var _iterator = htmlResources, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
var _ref;
var _ref2;

if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
_ref2 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
_ref2 = _i.value;
}

var htmlResource = _ref;
var htmlResource = _ref2;

processFromPath(resources, htmlResource.path, htmlResource, packagePath, localRelativeToDir, overrideBlock || extractBundleResourceData(htmlResource));
}
Expand All @@ -473,16 +475,16 @@ function processFromPath(resources, fromPath, resource, packagePath, relativeToD
resources[fromPathCss] = (0, _assign2.default)({}, resource, realPath, overrideBlock || {});
}
} else {
console.error('Unable to resolve', fromPath);
}
console.error('Unable to resolve', fromPath);
}
}

function getResourcesOfPackage() {
var resources = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var packagePath = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
var relativeToDir = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var overrideBlock = arguments.length <= 3 || arguments[3] === undefined ? undefined : arguments[3];
var externalModule = arguments.length <= 4 || arguments[4] === undefined ? undefined : arguments[4];
var resources = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var packagePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
var relativeToDir = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var overrideBlock = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
var externalModule = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : undefined;

if (modulesProcessed.indexOf(packagePath) !== -1) {
return;
Expand All @@ -499,34 +501,34 @@ function getResourcesOfPackage() {
if (packageJson) {
if (packageJson.aurelia && packageJson.aurelia.build && packageJson.aurelia.build.resources) {
for (var _iterator2 = packageJson.aurelia.build.resources, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {
var _ref2;
var _ref3;

if (_isArray2) {
if (_i2 >= _iterator2.length) break;
_ref2 = _iterator2[_i2++];
_ref3 = _iterator2[_i2++];
} else {
_i2 = _iterator2.next();
if (_i2.done) break;
_ref2 = _i2.value;
_ref3 = _i2.value;
}

var resource = _ref2;
var resource = _ref3;

resource = resource instanceof Object && !Array.isArray(resource) ? resource : { path: resource };
var fromPaths = Array.isArray(resource.path) ? resource.path : [resource.path];
for (var _iterator3 = fromPaths, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) {
var _ref3;
var _ref4;

if (_isArray3) {
if (_i3 >= _iterator3.length) break;
_ref3 = _iterator3[_i3++];
_ref4 = _iterator3[_i3++];
} else {
_i3 = _iterator3.next();
if (_i3.done) break;
_ref3 = _i3.value;
_ref4 = _i3.value;
}

var fromPath = _ref3;
var fromPath = _ref4;

debug('<' + (externalModule || path.basename(packagePath)) + '> [resolving] \'' + fromPath + '\'');

Expand All @@ -542,18 +544,18 @@ function getResourcesOfPackage() {
if (packageJson.dependencies) {
var depNames = filterDepNames((0, _getOwnPropertyNames2.default)(packageJson.dependencies), getPackageAureliaIncludeDependencies(packageJson));
for (var _iterator4 = depNames, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) {
var _ref4;
var _ref5;

if (_isArray4) {
if (_i4 >= _iterator4.length) break;
_ref4 = _iterator4[_i4++];
_ref5 = _iterator4[_i4++];
} else {
_i4 = _iterator4.next();
if (_i4.done) break;
_ref4 = _i4.value;
_ref5 = _i4.value;
}

var _moduleName = _ref4;
var _moduleName = _ref5;

var _modulePathIndex = moduleNames.indexOf(_moduleName);
if (_modulePathIndex !== -1) {
Expand All @@ -564,18 +566,18 @@ function getResourcesOfPackage() {

if (!externalModule) {
for (var _iterator5 = depNames, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) {
var _ref5;
var _ref6;

if (_isArray5) {
if (_i5 >= _iterator5.length) break;
_ref5 = _iterator5[_i5++];
_ref6 = _iterator5[_i5++];
} else {
_i5 = _iterator5.next();
if (_i5.done) break;
_ref5 = _i5.value;
_ref6 = _i5.value;
}

var moduleName = _ref5;
var moduleName = _ref6;

var modulePathIndex = moduleNames.indexOf(moduleName);
if (modulePathIndex !== -1) {
Expand Down
Loading

0 comments on commit f5624a3

Please sign in to comment.