-
Notifications
You must be signed in to change notification settings - Fork 26.2k
fix(platform-browser-dynamic): provide a subclass of Compiler
#25012
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
Conversation
Providing the `Compiler` will interfere with the `offlineMode` check in `SystemJsNgModuleLoader.load`. Instead we should provide a subclass of Compiler so that - the `SystemJsNgModuleLoader` will, as expected, find correct factory on AOT builds - we can still use JitCompiler on lazy modules Related issue: angular#20639 (comment)
@JLHwung ... the line Btw ... what would be the sense of loading a non AOT lazy loaded module when the potential key of using of JitCompiler in AOT app is mainly to take any component template HTML code and compile it in run-time in a browser? |
@mlc-mlapis In most cases the However, in the situation demonstrated by the
No, I am revising the integration example to make sure the
I guess you mean the sense of loading AOT modules while keeping a JitCompiler reference in app. Correct me if wrong. My company uses angular on enterprise software with a plugin design. By plugin I mean the dynamic modules developed by third-party vendors. The host site is compiled without any knowledge of plugin, so we need a On the other hands, the system has many builtin business modules, so |
@JLHwung ... so your case is:
So that's why I was talking about a new syntax because I supposed still the ability to load either AOT or JIT lazy loaded modules in any time from the core AOT app and it was unimaginable that it wouldn't be possible. Because of your case and loading of plugin third parties JIT modules which have to be independent on your build core process ... wouldn't better to use UMD Angular packages (loaded on demand) and have the possibility to AOT compile even those third parties lazy modules? Because then you are able to load them in any time later and the only condition is that you and all third parties module authors have to use just the same Angular version. And this preposition shouldn't be a real complication for you because even today you can't mix Angular 2, 4, 5, 6 because of using some fixed Angular compiler version. |
The APF v6 does not meet our requirements. AFAIK the package need to compile with the main app so that the dependencies, i.e.
This is a cool idea. The main barrier would be how to leak these instructions to webpack compiler. The If you are interested at more granularity on module lazy loading, which is a great topic for sure, I suggest we discuss at this thread so this PR would not detour from the topic. 😊 /cc @ocombe for reviewing the revised example. Thanks. |
You can load them from any server you want so why should it be a problem on intranet? It would be the same server as you are using to serve your app.
Not necessarily. Especially when you use UMD Angular native packages because you have ALL Angular code ready in a browser so the lazy loaded module can be compiled independently ... using ngc compiler. |
I don't think we are going to introduce this kind of changes when we are already working on ivy which will change all of that, what do you think @vicb ? |
@mlc-mlapis Thanks very much for the replies.
You are right. The key point is actually on bundling. I just realize I mixed compiling and bundling in my previous comments. On the main site, the
I agree that the UMD packages would work given that every dependencies of dynamic modules have a UMD bundles. However the main site should still emit some stats to tell @ocombe The |
I meant it really as ... it's not necessary to bundle anything from Angular native packages to lazy or dynamic modules ... it is main point ... that any third party developers don't know anything about others and still are able to develop their part ... because they don't worry what to bundle or don't bundle into their module. Their module contains only their code and nothing from Angular native packages because all of that is guaranteed by loaded UMD Angular packages. |
Closed since ivy will change all of that. The technique show in this MR should be viewed more of a workaround instead of a must. Great thanks to @mlc-mlapis on inspiring discussion. |
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. |
Providing the
Compiler
will interfere with theofflineMode
check inSystemJsNgModuleLoader.load
. Instead we should provide a subclass of Compiler so thatSystemJsNgModuleLoader
will, as expected, find correct factory on AOT buildsRelated issue: #20639 (comment)
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Given
Compiler
provided in root module and building with--aot
, theloadChildren
route declaration will fail to find the correct module path.The culprit is the interference with
offlineMode
check inSystemJsNgModuleLoader
. (code is here) Since theofflineMode
is alwaysfalse
, the AOT compiled factories are never loaded, and the module loader loads the incorrect path on--aot
builds.Issue Number: #20639 (comment)
What is the new behavior?
The
loadChildren
works as expected on--aot
builds in case the user properly provides a subclass ofCompiler
.Does this PR introduce a breaking change?
Other information
I am not quite sure if it is a bug fix or a documentation change since the issue can be solved in user land only.
Shall we add
loadChildren
to thedynamic-compiler
example?