Skip to content

loading ModuleFactory issue #9420

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

Closed
WagnerMoreira opened this issue Jan 29, 2018 · 4 comments
Closed

loading ModuleFactory issue #9420

WagnerMoreira opened this issue Jan 29, 2018 · 4 comments

Comments

@WagnerMoreira
Copy link

WagnerMoreira commented Jan 29, 2018

I am submitting this issue here only because I've already tried stackoverflow and reddit, I believe the people more attached to Angular/cli will understand that better

Versions

ngular CLI: 1.6.6
Node: 8.9.1
OS: darwin x64
Angular: 5.2.2
... common, compiler, compiler-cli, core, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.6
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.4.2
webpack: 3.10.0

Repro steps

My purpose: create a library that provides a modal, so I could just pass a component to load inside a modal in my app

I combined this tutorial (how to dynamically load components) and this tutorial (how to build and publish an angular module)
and with that I am trying to create a library to load components inside a modal, here's my repo

When my app tries to load the ModuleFactory, it's returning this error:
enter image description here

As I am passing the #ModalModule it should be loading the component factory correctly:
// This array defines which "componentId" maps to which lazy-loaded module.
const manifests: DynamicComponentManifest[] = [
{
componentId: 'modal',
path: 'dynamic-modal', // some globally-unique identifier, used internally by the router
loadChildren: './dynamic-modules/modal/modal.module.ts#ModalModule',
},
];

this behavior can be seen in the dynamically loading components with ng cli tutorial's demo project
In the tutorial's demo project webpack is producing a js bundle for that module, and that's not happening in my repoenter image description here

I believe it has to do with ng cli, or I could be doing something wrong here, can anyone tell?

Observed behavior

it's all in the above description

Desired behavior

to load a ModuleFactory properly

@filipesilva
Copy link
Contributor

Heya, you're trying to mix a couple of different approaches that do not mix so well. Specifically, Angular CLI only supports code splitting via the router. We do have a discussion issue for this in #9343, which has more context and a bunch of other related issues linked.

@WagnerMoreira
Copy link
Author

right, I've read the issues thank you, there is any way to achieve my goals with the existing Angular state? I believe many users would benefit of my library since modals are being used in tons of projects

@filipesilva
Copy link
Contributor

No, such support is not currently in Angular CLI. There is a workaround as described in that issue at

This has as a consequence that people have to use a fake route if they want to split at the NgModule boundary; e.g. AIO here. Although this work, it's a bad pattern that users shouldn't have to do.

But I wouldn't recommend doing that.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants