Skip to content

Commit

Permalink
fix(webpack): Module ids are now generated based on the resource rath…
Browse files Browse the repository at this point in the history
…er than its request.

Before, module ids were generated based on the module request and not its resource location. Since each module id is now generated based on its resource, PLATFORM.moduleName() now has no issue resolving relative, absolute, or aliased paths.
  • Loading branch information
Pat Herlihy committed Sep 7, 2017
1 parent 5177bb3 commit 6c9a940
Show file tree
Hide file tree
Showing 5 changed files with 759 additions and 251 deletions.
8 changes: 7 additions & 1 deletion dist/AureliaDependenciesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
const IncludeDependency_1 = require("./IncludeDependency");
const BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
const PreserveModuleNamePlugin_1 = require("./PreserveModuleNamePlugin");
class AureliaDependency extends IncludeDependency_1.IncludeDependency {
constructor(request, range, options) {
super(request, options);
Expand All @@ -10,7 +11,12 @@ class AureliaDependency extends IncludeDependency_1.IncludeDependency {
}
class Template {
apply(dep, source) {
source.replace(dep.range[0], dep.range[1] - 1, "'" + dep.request.replace(/^async(?:\?[^!]*)?!/, "") + "'");
// Get the module id, fallback to using the module request
let moduleId = dep.request;
if (dep.module && typeof dep.module[PreserveModuleNamePlugin_1.preserveModuleName] === 'string') {
moduleId = dep.module[PreserveModuleNamePlugin_1.preserveModuleName];
}
source.replace(dep.range[0], dep.range[1] - 1, "'" + moduleId.replace(/^async(?:\?[^!]*)?!/, "") + "'");
}
;
}
Expand Down
Loading

0 comments on commit 6c9a940

Please sign in to comment.