-
Notifications
You must be signed in to change notification settings - Fork 12k
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
ng build -aot error 'entry.split is not a function' on lazy loaded modules #3204
Comments
The code you referenced is actually allowing the string format to work. |
You don't need to use the function to load modules. The CLI handles this for you if you just provide the string path to the module and its class name. |
@brandonroberts like this? |
@ctrl-brk You have to provide a relative path e.g. |
@brandonroberts Doesn't work for me no matter how I try. Same path works with SystemJs and doesn't with cli/webpack. Is there a way to see a full url it's trying to load the module from? |
Are you using the latest version of the CLI? See this commit 27a034d As far as I know there isn't a "debug" mode for module loading. |
Ok, I've got it working in "debug" (I meant non-AOT ;) ) mode. The key is that you HAVE to restart the server (kill ng serve and start it again) for this change to be picked up. Just recompiling on the fly doesn't help. I'll play more with AOT tomorrow. |
Well, it's kind of 'tomorrow' now )) |
Is there a workaround for the 'entry.split is not a function' error? After weeks of trials and errors and various fixes and updates to angular-cli, I still cannot get it to produce separate bundles for |
Same problem as @achimha. |
i have the same kind of issue with angular-cli beta-24 and angular 2.4.1 previously i had a errors like this here is what seems to be the source of the error : `
` |
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
@Meligy seems to working on a fix for this message in angular/angular#13676. You don't need to manually load lazy modules, webpack will pick it up correctly. See here for an example: |
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
@Rebolon right now I have exactly your configuration. I use @filipesilva why did you close the issue as it's not fixed yet ? |
@maxime1992 There is a pending PR in the main angular repo to address your |
@clydin I searched |
Sure. Both of the following have the fix (second is attempting to fix some other issues as well): |
@maxime1992 need to wait for angular/angular#13676 |
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
For those who use AOT, there's still an ongoing error. A fix has been proposed here angular/angular#13909 but it requires you to change some import(s) in your code. Another issue has been opened angular/angular#14005 to ask if this could be done at built time, without the need to do it by hand. |
Works clear with CLI if we declare full path to the module, include the name of the folder and the module inside + #Hash |
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…oad routes paths The change avoids the compiler CLI internal API from mismatching the following case as lazy loading ``` import { NonLazyLoadedModule } from './non-lazy-loaded/non-lazy-loaded.module'; export function getNonLazyLoadedModule() { return NonLazyLoadedModule; } export const routes = [ { path: '/some-path', loadChildren: getNonLazyLoadedModule } ]; ``` The output of the check is later passed to `RouteDef.fromString()`, so, it makes sense to be only a string. Fixes angular/angular-cli#3204
OS?
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:
So, the
entry
parameter ofModuleRoute.fromString
(line 23) is not a string but rather something like this:The text was updated successfully, but these errors were encountered: