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 12, 2017
1 parent 5177bb3 commit 965222f
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 131 deletions.
9 changes: 8 additions & 1 deletion src/AureliaDependenciesPlugin.ts
@@ -1,5 +1,6 @@
import { IncludeDependency } from "./IncludeDependency";
import BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
import { preserveModuleName } from "./PreserveModuleNamePlugin";

class AureliaDependency extends IncludeDependency {
constructor(request: string,
Expand All @@ -11,7 +12,13 @@ class AureliaDependency extends IncludeDependency {

class Template {
apply(dep: AureliaDependency, source: Webpack.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: string = dep.request;
if (dep.module && typeof dep.module[preserveModuleName] === 'string') {
moduleId = dep.module[preserveModuleName];
}

source.replace(dep.range[0], dep.range[1] - 1, "'" + moduleId.replace(/^async(?:\?[^!]*)?!/, "") + "'");
};
}

Expand Down

0 comments on commit 965222f

Please sign in to comment.