Skip to content

ng build -aot error 'entry.split is not a function' on lazy loaded modules #3204

Closed
@ctrl-brk

Description

@ctrl-brk

OS?

Windows 10

Versions.

1.0.0-beta.20-4

The log given by the failure.

C:\Projects\Cli>ng build -prod -aot
10% building modules 2/2 modules 0 active entry.split is not a function
TypeError: entry.split is not a function
at Function.ModuleRoute.fromString (C:\Projects\Cli\node_modules@ngtools\webpack\src\plugin.js:24:27)
at C:\Projects\Cli\node_modules@ngtools\webpack\src\plugin.js:244:34
at Array.map (native)
at AotPlugin._processNgModule (C:\Projects\Cli\node_modules@ngtools\webpack\src\plugin.js:243:14)
at C:\Projects\Cli\node_modules@ngtools\webpack\src\plugin.js:217:39
at process._tickCallback (internal/process/next_tick.js:103:7)

Mention any other details that might be useful.

I understand that this feature is still under development but FYI...
Line 24 of node_modules/@ngtools/webpack\src\plugin.js
var split = entry.split('#');
Looks like it expects SystemJs module path like my.module#MyModule
But this format doesn't work with webpack. In order to lazy load modules I use es6-promise-loader and it looks like this:

export function loadMyModule() {
  return require('es6-promise!./my.module')('MyModule');
}
export const appRoutes: Routes = [
    {path: 'my', loadChildren: loadMyModule},
]

So, the entry parameter of ModuleRoute.fromString (line 23) is not a string but rather something like this:

activeStaticSymbol {
  filePath: 'C:/Projects/Cli/src/app/app.routing.ts',
  name: 'loadMyModule',
  members: undefined }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions