-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Versions
node: v8.11.0
npm: 5.7.1
Windows 10
"@angular/animations": "5.2.9",
"@angular/cdk": "5.2.4",
"@angular/common": "5.2.9",
"@angular/compiler": "5.2.9",
"@angular/core": "5.2.9",
"@angular/forms": "5.2.9",
"@angular/http": "5.2.9",
"@angular/platform-browser": "5.2.9",
"@angular/platform-browser-dynamic": "5.2.9",
"@angular/router": "5.2.9",
"@angular/compiler-cli": "5.2.9",
"@ngtools/webpack": "1.10.2",
"typescript": "2.7.2",
"webpack": "3.11.0",
Repro steps
app-routing.module.ts
export const ROUTES: Routes = [
{
loadChildren: "./student/student.module#StudentModule",
path: "student",
},
];
student-routing.module.ts
export const ROUTES: Routes = [
{
loadChildren: "./question/question.module#QuestionModule",
path: "question",
},
{
loadChildren: "./settings/settings.module#SettingsModule",
path: "settings",
},
];
question-routing.module.ts
export const ROUTES: Routes = [
{
loadChildren: "./settings/settings.module#SettingsModule",
path: "settings",
},
];
Observed behavior
ERROR in NaNbut they point to different modules "(C:/Projects/Web/App/src/student/settings/settings.module.ts and "C:/Projects/Web/App/src/student/questions/settings/settings.module.ts"). Webpack cannot distinguish on context and would fail to load the proper one.
Desired behavior
We have a lot of modules with the same names (settings, instructions, etc.), but they are belong to different parents with different urls, they are not exported outside of the parent's scope. It works fine with awesome-typescript-loader, angular-router-loader and angular2-template-loader. We expected the same behavior with @ngtools/webpack.
Mention any other details that might be useful (optional)
I removed all other lazy modules from the project to check and this issue was still there.
Tried to use absolute paths as described here #8722 (comment), but had another issue
ERROR in Could not resolve module App/src/student/student.module relative to C:/Projects/Web/App/src/app-routing.module.ts
tsconfig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"skipLibCheck": true,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules"
]
}
webpack.config
const srcPath = path.resolve(__dirname, "App/src");
module.exports = {
entry: {
app: srcPath + "/main.ts",
polyfills: srcPath + "/polyfills.ts",
vendor: srcPath + "/vendor.ts",
},
resolve: {
extensions: [".ts", ".js"],
},
module: {
loaders: [
{
test: /(?:\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
loader: "@ngtools/webpack",
},
]
},
plugins: [
new AngularCompilerPlugin({
tsConfigPath: "./tsconfig.json",
entryModule: "./App/src/app.module#AppModule",
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new HardSourceWebpackPlugin(),
]
};
stehov, rockyromano, orestisioakeimidis, tobihagemann, kloener and 5 more