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

Added more information and with more minimal changes
  • Loading branch information
pat841 committed Jun 26, 2018
1 parent 2743730 commit 1263657
Show file tree
Hide file tree
Showing 3 changed files with 432 additions and 84 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: 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
Loading

0 comments on commit 1263657

Please sign in to comment.