-
Notifications
You must be signed in to change notification settings - Fork 12k
@ngtools/webpack AoTPlugin multi app feature. #7954
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
Comments
Hi @mcgri, A few questions:
Thanks! |
Hi @hansl It took me a while to realise that I could just run "ngc" first and then bundle up the AOT files with webpack But with @ngtools/webpack AotPlugin there is no need to have duplicate "starters" files for JIT and AoT... Here is a sample project of my multi-app implementation with AOT https://github.com/mcgri/NgMultiApp All configs are there. So, as I already learned how to achieve AoT with webpack..only one question remains. Are there plans to allow AotPlugin to receive multiple apps(modules)? |
Here is another example of a setup with multiple apps: https://github.com/Independer/ind-angular-starter. And the use case for such setup is the following:
To give a very specific example of the use case, we have a large website that helps customers with various insurances. For each insurance type we have a separate Angular app (e.g. travel insurance, car insurance, etc.). Those apps share a lot of code and at this moment we have 11 such apps. If we had to build each of the separately (like with Angular CLI Hope this helps. BTW, does the new |
I needed this feature too, so I made a patch for AngularCompilerPlugin to allow for multiple entry points. (specified either via tsconfig->angularcompileroptions->entrymodule array or via multiple bootstrapModule calls in main.ts). I patched AngularCompilerPlugin only, but logic can be easily applied to AoTPlugin too. See miiihi@fb75650 Duplicate of #4624 |
@miiihi I tested your code and while it compiles perfectly I seem to be having the problem that only the first app is included in the generated code. I am using multiple entry points in a webpack config like so:
The output files for the different webpack entry points are exactly the same. What logic is being used to determine this? (I am using an array for I also opened a stack overflow question about this here: One way to solve the problem might be to allow passing a function to
Any thoughts? |
@sqwk can you show your complete webpack config? If you're constructing AngularCompilerPlugin and passing an entryModule option, you need to pass all modules there, as an array. This option has a precedence over entryModules specified in tsconfig. |
@miiihi how do I use your fork for example? I mean how to add it as a dependency. |
@miiihi I wasn't passing any entryModule, instead defining them as part of tsconfig. Moving them to the AngularCompilerPlugin declaration does not change anything. I posted my webpack config here: https://gist.github.com/sqwk/ac04e8d0ca834347656b11206e36f7e8 |
@johnbendi If you just wan't to test, simply apply the patch to the @sqwk Your config lgtm, mine is quite similar, so I'm not sure what's the problem. I don't think that AngularCompilerPlugin and/or entryModule are to blame... Are sure that your entry files (main.ts) are different? If they are, I have no explanation, how the output files can be exactly the same... |
@miiihi I checked the two files once more and they are definitely identical, with the exception of some webpack_imports(). One of the apps fails to load with the error message Could you show me your webpack config? Maybe I can work from that one, to see if both apps compile as they should? |
Because I didn't have the posibility to call ngc before webpack (no package.json update allowed) I simply used a master module. For specific sub app config I use webpack merge plugin in the global webpack config. |
@sqwk I ran into the same issue. In my case, the issue was both modules had the same name (AppMod). Changing one to App1Mod and the other to App2Mod solved the problem for me. @miiihi Any idea why that might be? I wasn't able to apply the patch as is to v1.6.6, so there's a branch here: |
While this get fixed, I published a npm package with some modifications to handle multiple entry modules: |
@artonge I looked at your codebase and couldn't see any pointers to the changes you made. Do you mind pointing to it? |
It's on the |
I need this functionality for my project too. Is there any plans to implement this or merge proposed changes? |
@pshurygin |
@artonge Could you update your repo/npm package to the latest upstream version? |
@Rush I won't do it for now has it is not a necessity for us. But feel free to make a pull request. |
@artonge Interesting, could you point me in the right direction on how to make multi entryModule to work with Angular 7? I am pretty sure I tried upgrading to all latest packages and multi entryModule was not working for me. |
I didn't get my hands on the latest angular version so I cannot guide you, sorry. |
@artonge I rebased your patch on top of angular/angular-cli@master Package published to: To use:
Available on Github Thanks for your original work! |
Looks like #12107 captures this card. If I'm missing something, please open a new issue and link to this one. Thanks! |
Hello, First of all, thank you for your work! I'm trying to use @artonge or @Rush package to have multiple entry points to have multiple angular apps but I'm not able to configure properly a global tsconfig for both projects. If I use the global tsconfig I get: Module not found: Error: Can't resolve './app/app.module.ngfactory' in 'C:\Repos\Personal\POC-split-dependencies\reference\src' Do you have any example of a global tsconfig to put at tsConfigPath? Thank you so much!! |
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. |
Bug Report or Feature Request (mark with an
x
)Versions.
@angular/cli: 1.4.4
node: 6.9.2
os: win32 x64
Desired functionality.
Allow Multiple apps to pass via AoTPlugin
Mention any other details that might be useful.
Hi Guys. Thank you for all tremendous work you do.
We have a large project which we started building when ng2 was in beta 17 :) Our system is .NET 4.6 based (still dreaming to migrate it to .core) and it has 8 ng2 applications, with a hundred of shared components. The navigation between those apps needs to be controlled by backend due to strict access rules.
Right now, the project is webpack based. Each app's bundle after minification&uglification is about 2mb. I am trying to bring the loading time of each app below 4 seconds (down from 11). I added AoT plugin to the webpack and passed 1 of the main modules....The AoT reduced the bundle size for this app by ~200 KB and reduced the loading times by 4-5 sec.. It just amazing.
Now, I am looking into how to apply such magic to all apps in the system.. I have done some googling for 2 days and The only way which I see to achieve it is to create some kind of master module...but that will require huge system restructure and spending time, which we don't have. Deadlines.
Finally the questions. Is there a way to pass multiple modules/apps through AotPlugin? If no, then are there plans to add such feature?
Will completely migrating from webpack to the angular-cli help to achieve my goal of enabling AoT for all modules without unifying 8 apps under 1 master app?
Thank you for your time :)
The text was updated successfully, but these errors were encountered: