Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why process commented line? #3

Closed
klihelp opened this issue Feb 1, 2017 · 5 comments
Closed

Why process commented line? #3

klihelp opened this issue Feb 1, 2017 · 5 comments

Comments

@klihelp
Copy link

klihelp commented Feb 1, 2017

export const ROUTES: Routes = [
  { path: '**',    component: NoContentComponent },
];

 // Comments
 //  { path: 'barrel', loadChildren: './+barrel#BarrelModule'},

On Build, Why processing commented line?

=====ng-router-loader ============
Importer:    /../app/app.routes.ts
Raw Request: loadChildren: './+barrel#BarrelModule'
Replacement: loadChildren: () => System.import('/.../app/+barrel/index')  
.then( (module: any) => module['BarrelModule'] 

@shlomiassaf
Copy link
Owner

shlomiassaf commented Feb 1, 2017 via email

@klihelp
Copy link
Author

klihelp commented Feb 1, 2017

Using latest version2+.

// Comments
//  { path: 'barrel', loadChildren: './+barrel#BarrelModule'},

On build:

ERROR in ./src/app/app.routes.ts 
Module build failed: Error: Can't resolve './+barrel' in
at onResolved (../node_modules/enhanced-resolve/lib/Resolver.js:66:16)

Similar issue in angular aot build: Cannot determine the module for class
angular/angular#13590

Potentially on ng-router-loader:
webpack/enhanced-resolve#73

@shlomiassaf
Copy link
Owner

@klihelp I don't know what you are doing, but commenting out the barrel line did not yield any error and did not activate ng-router-loader on that line, just checked it.

You are doing something wrong.

Anyway, this can't happen in version 2 since it uses AST to parse the code, so unless esprima is broken I don't see how it happens.

Make sure you put the loader after your TS loader (so the loader gets JS code, not TS)
Also make sure you are not running @ngtools/webpack, it won't work with ng-router-loader

@klihelp
Copy link
Author

klihelp commented Feb 1, 2017

Thanks for the info.
Actually I am using a webpack based starter project:
https://github.com/Websitescity/ng2-f6-starter

@shlomiassaf
Copy link
Owner

That project is a copy of AngularClass/angular2-webpack-starter

Make sure you put the loader after your TS loader (so the loader gets JS code, not TS)

The configuration in that project is not suitable for version 2.0
https://github.com/Websitescity/ng2-f6-starter/blob/master/config/webpack.common.js#L105-L117

ng-router-loader get typescript, not js so the AST won't work.

This is the right setup:
https://github.com/AngularClass/angular2-webpack-starter/blob/master/config/webpack.common.js#L119-L133

I really don't get the point of making a starter that is copy of another starter, how much knowledge is required in so many different fields to maintain that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants