René's URL Explorer Experiment


Title: @ngtools/webpack feature request: support code splitting by third parties · Issue #4541 · angular/angular-cli · GitHub

Open Graph Title: @ngtools/webpack feature request: support code splitting by third parties · Issue #4541 · angular/angular-cli

X Title: @ngtools/webpack feature request: support code splitting by third parties · Issue #4541 · angular/angular-cli

Description: This is a feature request. I'd like to start discussion around @ngtools/webpack supporting code splitting by third party libs (including ui-router-ng2). Currently the code splitting support in @ngtools/webpack has a soft dependency on @a...

Open Graph Description: This is a feature request. I'd like to start discussion around @ngtools/webpack supporting code splitting by third party libs (including ui-router-ng2). Currently the code splitting support in @ngt...

X Description: This is a feature request. I'd like to start discussion around @ngtools/webpack supporting code splitting by third party libs (including ui-router-ng2). Currently the code splitting support in ...

Opengraph URL: https://github.com/angular/angular-cli/issues/4541

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@ngtools/webpack feature request: support code splitting by third parties","articleBody":"This is a feature request.  \r\n\r\nI'd like to start discussion around `@ngtools/webpack` supporting code splitting by third party libs (including `ui-router-ng2`).  \r\n\r\n\r\nCurrently the code splitting support in `@ngtools/webpack` has a [soft dependency on `@angular/router`](https://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L18-L21).\r\n\r\nMy understanding is that:\r\n\r\n- `@ngtools/webpack` loader [invokes `__NGTOOLS_PRIVATE_API_2.listLazyRoutes()`](https://github.com/angular/angular-cli/blob/f2f02a6c8122430ec2375610a5ecdb9c1383e02a/packages/%40ngtools/webpack/src/plugin.ts#L401-L408)\r\n- `listLazyRoutes` finds lazy routes:\r\n  - [References the DI token `ROUTES`](https://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L65) found in `@angular/router`\r\n  - statically analyzes the application.\r\n  - [checks each `NgModule` for provided `ROUTES`](https://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L136-L141)\r\n  - [Checks each route for `loadChildren`](https://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L195-L210) and adds to the list of lazy routes.\r\n  - returns lazy routes\r\n- [processes lazy routes](https://github.com/angular/angular-cli/blob/f2f02a6c8122430ec2375610a5ecdb9c1383e02a/packages/%40ngtools/webpack/src/plugin.ts#L410-L426), redirecting imports to `.ngfactory.ts` and doing webpack magic\r\n\r\n\r\n# Goal\r\n\r\nI think the goal should be to eliminate the dependency on `@angular/router` and provide a router agnostic mechanism for third parties to supply code splitting information.\r\n\r\nToday, UI-Router supports code splitting using `@ngtools/webpack` by importing the `ROUTES` token from `@angular/router`, [then providing the ui-router states as that DI token](https://github.com/ui-router/ng2/blob/3c043dd2c38189488cf3748b1c46fc19bf5f5603/src/uiRouterNgModule.ts#L23), i.e.,  `{ provide: ROUTES, useValue: module.states, multi: true }`.  However, this forces ui-router to have a dependency on `@angular/router`.  It also forces ui-router to emulate the structure of `@angular/router` by adding a `loadChildren` property.\r\n\r\n# Proposal 1\r\n\r\nMake the DI token configurable by `@ngtools/webpack`.  \r\n\r\nDo not reference the token from `@angular/router` in `ngtools-impl.ts`, but pass the token in.  UI-Router users could configure this somehow to use the `STATES` token, for example.\r\n  \r\nThis proposal is rather limited in its usefulness.  Only one library could support lazy loading + code splitting in a given app.\r\n\r\n# Proposal 2\r\n\r\nMove and/or rename the DI token out of `@angular/router`\r\n\r\nPerhaps the DI token could be moved to  `@angular/compiler-cli`, `@angular/common`,  or `@angular/core`.  This eliminates the need to depend on `@angular/router`.  Additionally, move the token to its own ES6 module.  Today, importing the `ROUTES` token from `@angular/router` brings in unrelated symbols  from `@angular/router` into the ui-router bundle even using rollup.\r\n\r\nThis proposal still conceptually ties lazy loading to the `@angular/router`.   All terminology and code analysis assumes that lazy loading code processes `@angular/router` routes.  Third parties have to emulate the router's structure.\r\n\r\n# Proposal 3\r\n\r\nIntroduce a routing-agnostic token such as `ANALYZE_FOR_LAZY_LOAD`.   \r\n\r\nEither `@angular/router` or third parties should provide lazy load and code splitting information using this token.  I propose instead of providing an array of specifically structured objects such as `ROUTES` or `STATES`, that only the lazy load information need be provided, i.e.:\r\n\r\n```js\r\n{ \r\n  provide: ANALYZE_FOR_LAZY_LOAD,\r\n   useValue: [ \r\n    './child1/child1.module#Child1Module', \r\n    './child2/child2.module#Child2Module' \r\n  ]\r\n}\r\n```\r\n\r\nThe `@angular/router` would then provide the module's lazy load information by doing something like:\r\n\r\n```js\r\nconst lazyRoutes = ROUTES.map(x => x.loadChildren).filter(identity);\r\nconst provider = { provide: ANALYZE_FOR_LAZY_LOAD, useValue: lazyRoutes, multi: true };\r\n```\r\n\r\nThe knowledge about the lazy load declaration object (i.e., what the `loadChildren` property means on a route) is moved from `@angular/compiler-cli` to the library that owns that structure (i.e., the `@angular/router`).\r\n\r\nOf these three proposals, this one is my favorite as it separates concerns nicely and provides a clear mechanism for lib authors to use.  \r\n\r\n\r\n","author":{"url":"https://github.com/christopherthielen","@type":"Person","name":"christopherthielen"},"datePublished":"2017-02-08T22:17:44Z","url":"https://github.com/angular/angular-cli/issues/4541"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2b131c72-abbe-81ae-d03f-3b48cf300e11
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8168:A99C2:C391D2:FC75D1:6B00EC0B
html-safe-noncee40a27fe88c5035808006ff01d51a2c903b6cd27a54f0a20ecae3263ce73fa97
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTY4OkE5OUMyOkMzOTFEMjpGQzc1RDE6NkIwMEVDMEIiLCJ2aXNpdG9yX2lkIjoiODg5Mjk5NDkwMzYwOTUwMjczMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacaaa93bd438d022258fafee10d9a7966a052dac15138ae9b740d8c818e4092a6d
hovercard-subject-tagissue:206342447
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/4541/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7b6ea87e229deb3f24a884dd863d925818b3e0c235394ab079b99a0f23f091e1/angular/angular-cli/issues/4541
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7b6ea87e229deb3f24a884dd863d925818b3e0c235394ab079b99a0f23f091e1/angular/angular-cli/issues/4541
og:image:altThis is a feature request. I'd like to start discussion around @ngtools/webpack supporting code splitting by third party libs (including ui-router-ng2). Currently the code splitting support in @ngt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamechristopherthielen
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
turbo-cache-controlno-preview
go-importgithub.com/angular/angular-cli git https://github.com/angular/angular-cli.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id36891867
octolytics-dimension-repository_nwoangular/angular-cli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id36891867
octolytics-dimension-repository_network_root_nwoangular/angular-cli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular-cli/issues/4541#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F4541
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular-cli%2Fissues%2F4541
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular-cli
Reloadhttps://github.com/angular/angular-cli/issues/4541
Reloadhttps://github.com/angular/angular-cli/issues/4541
Reloadhttps://github.com/angular/angular-cli/issues/4541
angularhttps://github.com/angular
angular-clihttps://github.com/angular/angular-cli
Codehttps://github.com/angular/angular-cli
Issues198 (198)https://github.com/angular/angular-cli/issues
Pull requests23 (23)https://github.com/angular/angular-cli/pulls
Actionshttps://github.com/angular/angular-cli/actions
Security and quality8 (8)https://github.com/angular/angular-cli/security
Insightshttps://github.com/angular/angular-cli/insights
https://github.com/angular/angular-cli
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/4541
New issuehttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/4541
@ngtools/webpack feature request: support code splitting by third partieshttps://github.com/angular/angular-cli/issues/4541#top
https://github.com/hansl
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22P3%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22feature%22
type: faqhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20faq%22
https://github.com/christopherthielen
christopherthielenhttps://github.com/christopherthielen
on Feb 8, 2017https://github.com/angular/angular-cli/issues/4541#issue-206342447
soft dependency on @angular/routerhttps://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L18-L21
invokes __NGTOOLS_PRIVATE_API_2.listLazyRoutes()https://github.com/angular/angular-cli/blob/f2f02a6c8122430ec2375610a5ecdb9c1383e02a/packages/%40ngtools/webpack/src/plugin.ts#L401-L408
References the DI token ROUTEShttps://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L65
checks each NgModule for provided ROUTEShttps://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L136-L141
Checks each route for loadChildrenhttps://github.com/angular/angular/blob/7a4c25535d79db6a2ecc49972594bc041791c142/modules/%40angular/compiler-cli/src/ngtools_impl.ts#L195-L210
processes lazy routeshttps://github.com/angular/angular-cli/blob/f2f02a6c8122430ec2375610a5ecdb9c1383e02a/packages/%40ngtools/webpack/src/plugin.ts#L410-L426
then providing the ui-router states as that DI tokenhttps://github.com/ui-router/ng2/blob/3c043dd2c38189488cf3748b1c46fc19bf5f5603/src/uiRouterNgModule.ts#L23
https://github.com/filipesilva
filipesilvahttps://github.com/filipesilva
on Mar 9, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-285337948
@christopherthielenhttps://github.com/christopherthielen
@hanslhttps://github.com/hansl
@robwormaldhttps://github.com/robwormald
@IgorMinarhttps://github.com/IgorMinar
filipesilvahttps://github.com/filipesilva
hanslhttps://github.com/hansl
on Mar 9, 2017https://github.com/angular/angular-cli/issues/4541#event-993034558
filipesilvahttps://github.com/filipesilva
type: discussionhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20discussion%22
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22P3%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22feature%22
on Mar 9, 2017https://github.com/angular/angular-cli/issues/4541#event-993034652
https://github.com/fulls1z3
fulls1z3https://github.com/fulls1z3
on Mar 20, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-287784979
https://github.com/hansl
hanslhttps://github.com/hansl
on Mar 27, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-289548017
angular/angular#15334https://github.com/angular/angular/pull/15334
https://github.com/christopherthielen
christopherthielenhttps://github.com/christopherthielen
on Apr 24, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-296505536
@hanslhttps://github.com/hansl
@robwormaldhttps://github.com/robwormald
@IgorMinarhttps://github.com/IgorMinar
https://github.com/filipesilva
filipesilvahttps://github.com/filipesilva
on May 5, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-299437352
#5981https://github.com/angular/angular-cli/issues/5981
https://github.com/oparisy
oparisyhttps://github.com/oparisy
on May 5, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-299483113
#5981https://github.com/angular/angular-cli/issues/5981
https://github.com/wardbell
wardbellhttps://github.com/wardbell
on May 6, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-299672952
@christopherthielenhttps://github.com/christopherthielen
#3https://github.com/angular/angular-cli/issues/3
https://github.com/oparisy
oparisyhttps://github.com/oparisy
on May 8, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-299851733
externalshttps://webpack.js.org/configuration/externals/
#1656https://github.com/angular/angular-cli/issues/1656
https://github.com/christopherthielen
christopherthielenhttps://github.com/christopherthielen
on May 9, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-300313754
@wardbellhttps://github.com/wardbell
lazy load the sources (System.import('./lazymodule'))https://github.com/ui-router/angular/blob/f6c552d35b8b05822df4de4b060eb10d635e92ee/test/ngModule/lazyModule.spec.ts#L9-L13
For JIT, get the NgModule and compile ithttps://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/lazyLoad/lazyLoadNgModule.ts#L108-L117
For AoT, get the NgModuleFactoryhttps://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/lazyLoad/lazyLoadNgModule.ts#L108-L117
Pass the parent injector when creatinghttps://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/lazyLoad/lazyLoadNgModule.ts#L78-L79
use the child injector from the NgModulehttps://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/directives/uiView.ts#L247
use the child injector to access the lazy module's ComponentFactoryhttps://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/directives/uiView.ts#L220-L222
Provide an array of objects using the ROUTES token (from @angular/router)https://github.com/ui-router/angular/blob/76dac280ca994c646fbdaa8f61251766c1e416dd/src/uiRouterNgModule.ts#L31
return a promise for the NgModule or NgModuleFactoryhttps://github.com/ui-router/angular/blob/f6c552d35b8b05822df4de4b060eb10d635e92ee/test/ngModule/lazyModule.spec.ts#L12
filipesilvahttps://github.com/filipesilva
type: faqhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20faq%22
on May 22, 2017https://github.com/angular/angular-cli/issues/4541#event-1092088557
https://github.com/filipesilva
filipesilvahttps://github.com/filipesilva
on Aug 1, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-319308480
angular/angular#18093https://github.com/angular/angular/issues/18093
https://github.com/Dunos
Dunoshttps://github.com/Dunos
on Oct 20, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-338147437
https://github.com/filipesilva
filipesilvahttps://github.com/filipesilva
on Nov 15, 2017https://github.com/angular/angular-cli/issues/4541#issuecomment-344722110
@gkalpakhttps://github.com/gkalpak
angular/angular#18428https://github.com/angular/angular/pull/18428
https://github.com/hansl
hanslhttps://github.com/hansl
on Jan 23, 2018https://github.com/angular/angular-cli/issues/4541#issuecomment-359919401
#9343https://github.com/angular/angular-cli/issues/9343
hanslhttps://github.com/hansl
completedhttps://github.com/angular/angular-cli/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jan 23, 2018https://github.com/angular/angular-cli/issues/4541#event-1438165230
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 9, 2019https://github.com/angular/angular-cli/issues/4541#issuecomment-529431872
automatic conversation locking policyhttps://github.com/angular/angular/blob/67d80f/docs/GITHUB_PROCESS.md#conversation-locking
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 9, 2019https://github.com/angular/angular-cli/issues/4541#event-2618360018
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular-cli/issues/4541
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular-cli/issues/4541
hanslhttps://github.com/hansl
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenthttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22P3%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22feature%22
type: faqhttps://github.com/angular/angular-cli/issues?q=state%3Aopen%20label%3A%22type%3A%20faq%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.