Skip to content

Commit

Permalink
fix(webpack): Aliased module paths now properly map to the correct au…
Browse files Browse the repository at this point in the history
…relia-loader module id [SIMPLE]
  • Loading branch information
pat841 committed Nov 8, 2019
1 parent 9f6f798 commit 2299267
Show file tree
Hide file tree
Showing 3 changed files with 440 additions and 95 deletions.
9 changes: 8 additions & 1 deletion src/AureliaDependenciesPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IncludeDependency } from "./IncludeDependency";
import BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
import { preserveModuleName } from "./PreserveModuleNamePlugin";

const TAP_NAME = "Aurelia:Dependencies";

Expand All @@ -13,7 +14,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 = 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
Loading

0 comments on commit 2299267

Please sign in to comment.