Repository navigation
@ngtools/webpack - Limited number of AotPlugin instances #5072
Description
Activity
- addedP5The team acknowledges the request but does not plan to address it, it remains open for discussionThe team acknowledges the request but does not plan to address it, it remains open for discussion
on Mar 14, 2017 In my opinion, webpack's multi-entries is essential feature; In typical large-scale enterprise system, Application must be devided into multiple SPA to supress memory usage in web-browser.
( Another solution, using single-SPA with lazy loading, is effective only in first-time loading, but in total memory usage.)
But this issue is labeled 'nice to have', not 'required'.
Is there alternative way to AOT-compile multiple SPA with webpack ?( Using ngc cli directly before webpacking ? But we no longer use @ngtools/webpack in that case...)
Any idea ?
Reacted by Tomasz Robaczewski, gjdev, Bartosz, Dan Tavelli, Robin Regmi, atluri64, Nathan Ryan, Dino Bettini, vidalsasoon, Ruslan Arkhipau and 4 more@ytkj @filipesilva yea i agree. we went ahead with an adoption of ng2+ at our company with assumption this bug would be resolved by the time we got close to moving to production, now i'm getting a bit nervous! Are there any hacks or workarounds we can use until official support lands?
@tavelli workaround I can come up with is quite primitive:
- run ngc command as many times as the number of spa.
- Then webpacking to the generated *.ngFactory intermediate codes.
To automate build process, step 1 should be done by a task-runner such as npm-script or Gulp.
Reacted by Aziz Abbas@tavelli have you found a hack or workaround?
- Nope :( I've been using JIT compiler. With tree shaking and minification bundle isn't quite as huge as I thought it would be but I believe execution time still suffers vs AOT so its far from ideal.…On Jul 5, 2017, at 9:37 AM, Nathan ***@***.***> wrote: @tavelli have you found a hack or workaround? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.Reacted by Nathan Lafferty and Peng Xiao
For a while I did this:
package.json snippet
... "prebuild:client-aot": "ngc -p public/src/prep-tsconfig.aot.json", "build:client-aot": "ngc -p public/src/tsconfig.aot.json && rollup -c rollup-config.js", ...My
prep-tsconfig.aot.jsonpoints to aprepare-ngc.main.ts, which imports all my main modules, just so the compiler can generate the right files, while mytsconfig.aot.jsonmatches all my main page files with a regex in theincludeoption of the tsconfig (pattern is"*-aot.ts").In this way Webpack can be used in development with JIT, while pure ngc+rollup can be used for AOT building. Not the most ideal imo, since I'd rather just use one tool (webpack) and not have to jump into ngc directly - but it is a valid approach.
I'm investigating migrating to webpack, but perhaps I'll still need to do this if I have multiple entry point :
Are y'all getting this by using the angular cli? Or using webpack directly akin to what this guy is doing?related to #7954
- addedfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesand removed
on Jan 24, 2018 5 remaining items
- added 7 commits that reference this issue
on Apr 6, 2021 - linked a pull request that will close this issueUpgrade tooling to use Webpack 5 #20466
on Apr 8, 2021 - added 2 commits that reference this issue
on Apr 8, 2021 - added a commit that references this issue
on Apr 8, 2021 angular-automatic-lock-bot commented
on May 9, 2021 More actionsThis 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.
- locked and limited conversation to collaborators
on May 9, 2021 - added a commit that references this issue
on Mar 26, 2024
Hello there. I might be wrong, but it seems that, at the moment, @ngtools/webpack doesn' support multiple entry points. The way it was possible to have multiple Angular client apps built by the same webpack instance was, e.g. using awesome-webpack-loader, something like this:
As you can see, this config enables it to build two different angular apps (that are package dependencies of the main one that runs webpack), each containing its own tsconfig, typings etc., by scoping each loader instance using 'include' to its own directory.
However, @ngtools/webpack provides the AOT functionality through the AotPlugin, which throws the
An @ngtools/webpack plugin already exist for this compilation.exception if you try creating more than one instance.So my question is, why is the number of AotPlugin instances restricted? Is there another way to support multiple entry points? If not, are there to plans to support it, or an issue where it can be tracked (since all issues concerning the webpack loader are in the angular-cli repository, which makes it really hard to track)?