Quramy / angular2-load-children-loader

A webpack loader for ng2 lazy loading
MIT License
23 stars 2 forks source link

webpack error #4

Open daniele-zurico opened 7 years ago

daniele-zurico commented 7 years ago

Hi I'm trying to use your loader but I receive in the console this kind of error: VM6476:48 EXCEPTION: Uncaught (in promise): TypeError: __webpack_require__(...) is not a function

my webpack.config is:

rules: [
      // Support for .ts files.
      {
        test: /\.ts$/,
        loaders: ['awesome-typescript-loader?'inlineSourceMap=true&sourceMap=false', 'angular2-load-children-loader', 'angular2-template-loader', '@angularclass/hmr-loader'],
        exclude: [isTest ? /\.(e2e)\.ts$/ : /\.(spec|e2e)\.ts$/, /node_modules\/(?!(ng2-.+))/]
      },

and I use in that way:

 imports: [
        BrowserModule,
        HttpModule,
        FormsModule,
        RouterModule.forRoot([
            {path: '', loadChildren: './home/home.module#HomeModule'},
            {path: 'about', loadChildren: './about/about.module#AboutModule'}
        ])],

Wbpack-version: "webpack": "^2.1.0-beta.25", what I did wrong?

puroboros commented 7 years ago

Same here, I think it's related to using also angular2-template-loader but can't confirm it right now.

glenjai commented 6 years ago

I get the same error. I am using Webpack 2.2.1, and Angular 5.2.

I think the problem is because the line substituted for the sub module is: {path: "sub", loadChildren: () => require("./sub.module")("SubModule") } If you put that straight into your app.routing.ts, you will get the same error in the browser console.

If you use this, then it works: {path: 'sub', loadChildren: () => require('./sub.module')['SubModule'] }

So I think the loader needs to be fixed to use square brackets [] around the sub module section, stead of () brackets.

Any chance of a fix @Quramy ?

Many thanks 👍