René's URL Explorer Experiment


Title: Apps cannot build with AOT if a dependent library was built with barrels · Issue #23713 · angular/angular · GitHub

Open Graph Title: Apps cannot build with AOT if a dependent library was built with barrels · Issue #23713 · angular/angular

X Title: Apps cannot build with AOT if a dependent library was built with barrels · Issue #23713 · angular/angular

Description: This issue describes mysterious build failures for apps that depend on an npm-installed library that was built with barrels. A barrel is an index.ts file that consolidates exported symbols of several nested files. The problem lies somewh...

Open Graph Description: This issue describes mysterious build failures for apps that depend on an npm-installed library that was built with barrels. A barrel is an index.ts file that consolidates exported symbols of sever...

X Description: This issue describes mysterious build failures for apps that depend on an npm-installed library that was built with barrels. A barrel is an index.ts file that consolidates exported symbols of sever...

Opengraph URL: https://github.com/angular/angular/issues/23713

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Apps cannot build with AOT if a dependent library was built with barrels","articleBody":"This issue describes mysterious build failures for apps that depend on an npm-installed library that was built with barrels.\r\n\r\n>A barrel is an `index.ts` file that consolidates exported symbols of several nested files.\r\n\r\nThe problem lies somewhere in the interaction among barrels, AOT, and `ngPackagr`.\r\n\r\n**Workaround: Do not use barrels in your library. Always and everywhere make direct references to the source files.**\r\n\r\n## I'm submitting a...\r\n\u003c!-- Check one of the following options with \"x\" -->\r\n\u003cpre>\u003ccode>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[x] Bug report  \u003c!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Performance issue\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n[ ] Other... Please describe:\r\n\u003c/code>\u003c/pre>\r\n\r\n## Current behavior\r\n\r\n`ng build --AOT` of an app fails with absurd errors concerning a library installed with npm.\r\n\r\nThat library was built with barrels. \r\n\r\nSpecifically, the top-level `index.ts` that tells `ngPackagr` which artifacts to include in the library's public API was built with barrels.\r\n\r\nThe library author (me) was able to build that library for production without any warnings or errors. \r\nWorse, it seemed to work when used in most applications that installed the library.\r\n\r\nBut occasionally you'd get weird errors when you `ng build --aot` the application, such as\r\n\r\n```\r\nERROR in ./src/client/app/test-users/test-users.module.ngfactory.js\r\nModule not found: Error: Can't resolve 'ngrx-data/selectors/index' in '/Users/Ward/_git/sp-x/src/client/app/test-users'\r\n```\r\nNote the reference in the error to `index` in  'ngrx-data/selectors/index'. That's a barrel file the wasn't directly exposed publicaly.\r\n```\r\nERROR in app/store/app-pluralizer.ts(17,13): Error during template compile of 'AppPluralizer'\r\n  Only initialized variables and constants can be referenced in decorators because the value of this variable is needed by the template compiler in 'PLURAL_NAMES_TOKEN'\r\n    'PLURAL_NAMES_TOKEN' references 'PLURAL_NAMES_TOKEN'\r\n      'PLURAL_NAMES_TOKEN' references 'PLURAL_NAMES_TOKEN'\r\n        'PLURAL_NAMES_TOKEN' is not initialized at ../../ngrx-data/utils/interfaces.ts(13,22).\r\n```\r\nThe constant _was initialized_ ... on **line 16** in `ngrx-data/utils/interfaces.ts`.\r\nNotice the line number is **13** in the error message. Thats where the token is _declared_ in the  `d.ts` type definition file (`interfaces.d.ts`), not the `.ts` source file. \r\n\r\nShuffling the order of exports in the top level `index.ts` would fix one use case but trigger another.\r\n\r\nThese are all clues that **you are using barrels and AOT + ngPackagr` do not like barrels**.\r\n\r\n## Expected behavior\r\n\r\nI think we should be able to use barrels.\r\n\r\nAOT + ngPackagr _should be able to determine the proper dependency order_ as is possible with JIT compilation.\r\n\r\n## Minimal reproduction of the problem with instructions\r\n\r\nThere is no easy way to reproduce this bad behavior because barrels often appear to work. The problem likely arises when a library's sub-files refer to files that are exported in other barrels (even when those references are direct to the dependent files, by-passing barrels).\r\n\r\nYou can see the horror story play-out in the `1.0.0-beta.12` and `1.0.0-beta.13` releases of https://github.com/johnpapa/angular-ngrx-data.\r\n\r\nThis repo has both a library (`/lib`) and an example that uses that library (`/src/client`).\r\n\r\nTo experience the problem:\r\n* clone `https://github.com/johnpapa/angular-ngrx-data`\r\n* go back to the [Beta 12 commit](https://github.com/johnpapa/angular-ngrx-data/releases/tag/1.0.0-beta.12)\r\n* `npm install`\r\n* `npm run build-all` # this should succeed.\r\n*  Edit `lib/src/index.ts`\r\n* Move `export * from './utils';` to the bottom of the file\r\n* `npm run build-lib` # rebuilds the library\r\n* `ng build --aot` # now it fails with the strange `InjectionToken` error ^^^\r\n\r\nYou can build with AOT if you remove the following providers from `src/client/app/store/entity-store.module.ts`\r\n```\r\n    { provide: Logger, useClass: AppLogger },\r\n    { provide: Pluralizer, useClass: AppPluralizer }\r\n```\r\nThis succeeds because these providers reference the library's `Logger` and `Pluralizer` abstract classes in `./util` (the barrel).\r\nRemoving them by-passes the library reference lookup that produces the errors.\r\n\r\n>Pragmatically, this means that the library author (me) won't discover there is a problem until some consumer (you) tries to override the default logger and pluralizer behaviors by supplying alternative implementations through this official extension point.\r\n\r\n* revert change to `lib/src/index.ts`.\r\n* `npm run build-lib` # rebuilds the library\r\n* `ng build --aot` # build succeeds\r\n\r\nA dev build (e.g, `ng serve`) works fine at any point in this process.\r\n\r\nIf you now move forward to [Beta 13](https://github.com/johnpapa/angular-ngrx-data/releases/tag/1.0.0-beta.13) where barrels are eliminated, all of these problems go away and you can build the sample app with `ng build --aot` at any point.\r\n\r\n## What is the motivation / use case for changing the behavior?\r\n\r\nBarrels nicely encapsulate and minimize low-level details of a library's internal folder structure.\r\nThey work great with JIT. Obviously not with AOT at this time.\r\n\r\n## Environment\r\n\r\n\u003cpre>\u003ccode>\r\nAngular version: 5.2.10\r\nngPackagr version: 2.4.2\r\n\u003c/pre>\u003c/code>\r\n\r\nI do not know if it is still a problem in v.6. I don't have the time to find out.\r\n\r\nBrowser: _Irrelevant_\r\n\r\nFor Tooling issues: _irrelevant_\r\n\r\n","author":{"url":"https://github.com/wardbell","@type":"Person","name":"wardbell"},"datePublished":"2018-05-04T17:05:58Z","url":"https://github.com/angular/angular/issues/23713"}

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:de201b99-4e6a-0714-8ae8-6ef487880108
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC33E:1087D4:92EEF2:C5876D:6B00E89F
html-safe-nonce495410737878d2bf19f63e48288eba1219cc72f7a6448f9d3c225c717f767583
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzNFOjEwODdENDo5MkVFRjI6QzU4NzZEOjZCMDBFODlGIiwidmlzaXRvcl9pZCI6Ijc4NDc0NzM3NjM1MjMyOTEyOTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbf5b2674e66d883aef8e1d47ab64d325b6c97af12b807cde01913af8dd019558
hovercard-subject-tagissue:320351363
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/23713/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7798b5ef3feb7be6bbc3654a5a7e7d447962698fdf5a3f418311162989d7a9c0/angular/angular/issues/23713
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7798b5ef3feb7be6bbc3654a5a7e7d447962698fdf5a3f418311162989d7a9c0/angular/angular/issues/23713
og:image:altThis issue describes mysterious build failures for apps that depend on an npm-installed library that was built with barrels. A barrel is an index.ts file that consolidates exported symbols of sever...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamewardbell
hostnamegithub.com
expected-hostnamegithub.com
None27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
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
release624179fb8b88d26ba5bba08894eb60a1c5a1d93d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/23713#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F23713
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%2Fissues%2F23713
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
Reloadhttps://github.com/angular/angular/issues/23713
Reloadhttps://github.com/angular/angular/issues/23713
Reloadhttps://github.com/angular/angular/issues/23713
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests140 (140)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/23713
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/23713
Apps cannot build with AOT if a dependent library was built with barrelshttps://github.com/angular/angular/issues/23713#top
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/wardbell
wardbellhttps://github.com/wardbell
on May 4, 2018https://github.com/angular/angular/issues/23713#issue-320351363
https://github.com/johnpapa/angular-ngrx-datahttps://github.com/johnpapa/angular-ngrx-data
Beta 12 commithttps://github.com/johnpapa/angular-ngrx-data/releases/tag/1.0.0-beta.12
Beta 13https://github.com/johnpapa/angular-ngrx-data/releases/tag/1.0.0-beta.13
https://github.com/wardbell
wardbellhttps://github.com/wardbell
on May 4, 2018https://github.com/angular/angular/issues/23713#issuecomment-386666067
wardbellhttps://github.com/wardbell
on May 4, 2018https://github.com/angular/angular/issues/23713#event-1610319852
IgorMinarhttps://github.com/IgorMinar
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
on May 10, 2018https://github.com/angular/angular/issues/23713#event-1620861201
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on May 10, 2018https://github.com/angular/angular/issues/23713#event-1620861317
mheveryhttps://github.com/mhevery
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
severity1: confusinghttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22severity1%3A%20confusing%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
on May 24, 2018https://github.com/angular/angular/issues/23713#event-1645470922
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on May 24, 2018https://github.com/angular/angular/issues/23713#event-1645471137
https://github.com/piernik
piernikhttps://github.com/piernik
on Jun 13, 2018https://github.com/angular/angular/issues/23713#issuecomment-396871591
angular/angular-cli#11210https://github.com/angular/angular-cli/issues/11210
https://github.com/piernik
piernikhttps://github.com/piernik
on Jun 19, 2018https://github.com/angular/angular/issues/23713#issuecomment-398292744
https://github.com/jasonaden
jasonadenhttps://github.com/jasonaden
on Jun 22, 2018https://github.com/angular/angular/issues/23713#issuecomment-399503067
https://github.com/admosity
admosityhttps://github.com/admosity
on Jun 29, 2018https://github.com/angular/angular/issues/23713#issuecomment-401238568
@jefforahttps://github.com/jeffora
#22856https://github.com/angular/angular/pull/22856
@jasonadenhttps://github.com/jasonaden
@filipesilvahttps://github.com/filipesilva
@IgorMinarhttps://github.com/IgorMinar
https://user-images.githubusercontent.com/4655972/42071247-603627d2-7b28-11e8-9f01-b825d656b376.png
https://user-images.githubusercontent.com/4655972/42071740-dd2c0cb4-7b2a-11e8-97cc-6d1184d3ed3e.png
https://user-images.githubusercontent.com/4655972/42071989-4b2e9c8a-7b2c-11e8-8e1e-f6c6aa6d3c07.png
angular/angular-cli#8581https://github.com/angular/angular-cli/issues/8581
angular/angular-cli#7066https://github.com/angular/angular-cli/issues/7066
#24225https://github.com/angular/angular/issues/24225
#22825https://github.com/angular/angular/issues/22825
@mheveryhttps://github.com/mhevery
#24225https://github.com/angular/angular/issues/24225
https://github.com/jeffora
jefforahttps://github.com/jeffora
on Jul 6, 2018https://github.com/angular/angular/issues/23713#issuecomment-402906841
https://github.com/jasonaden
jasonadenhttps://github.com/jasonaden
on Jul 10, 2018https://github.com/angular/angular/issues/23713#issuecomment-403999779
@jefforahttps://github.com/jeffora
#22856https://github.com/angular/angular/pull/22856
jasonadenhttps://github.com/jasonaden
completedhttps://github.com/angular/angular/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 10, 2018https://github.com/angular/angular/issues/23713#event-1726766251
https://github.com/jeffora
jefforahttps://github.com/jeffora
on Jul 11, 2018https://github.com/angular/angular/issues/23713#issuecomment-404005466
@jasonadenhttps://github.com/jasonaden
https://github.com/admosity
admosityhttps://github.com/admosity
on Jul 11, 2018https://github.com/angular/angular/issues/23713#issuecomment-404291046
@jefforahttps://github.com/jeffora
https://github.com/Thorski
Thorskihttps://github.com/Thorski
on Aug 30, 2018https://github.com/angular/angular/issues/23713#issuecomment-417375800
https://github.com/dherges
dhergeshttps://github.com/dherges
on Sep 7, 2018https://github.com/angular/angular/issues/23713#issuecomment-419374809
rovicohttps://github.com/rovico
on Mar 20, 2019https://github.com/angular/angular/issues/23713#event-2216952614
#2 finally fixed aot building issue, rerlated on barrel index files. …https://github.com/sunrise-r/interface-admin-ng/commit/bea04942941e676b3e9e60f808e75551ca2fe3aa
#2https://github.com/sunrise-r/interface-admin-ng/issues/2
bea0494https://github.com/sunrise-r/interface-admin-ng/commit/bea04942941e676b3e9e60f808e75551ca2fe3aa
https://github.com/jonathanlie
jonathanliehttps://github.com/jonathanlie
on Jun 6, 2019https://github.com/angular/angular/issues/23713#issuecomment-499346336
https://github.com/robertsmith2
robertsmith2https://github.com/robertsmith2
on Jun 13, 2019https://github.com/angular/angular/issues/23713#issuecomment-501844601
@jonathanliehttps://github.com/jonathanlie
https://github.com/fabianedl777
fabianedl777https://github.com/fabianedl777
on Aug 26, 2019https://github.com/angular/angular/issues/23713#issuecomment-524913400
@jonathanliehttps://github.com/jonathanlie
@robertsmith2https://github.com/robertsmith2
https://github.com/apps/angular-automatic-lock-bot
angular-automatic-lock-bothttps://github.com/apps/angular-automatic-lock-bot
on Sep 26, 2019https://github.com/angular/angular/issues/23713#issuecomment-535572929
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 26, 2019https://github.com/angular/angular/issues/23713#event-2665854288
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/23713
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/23713
area: coreIssues related to the framework runtimehttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20core%22
freq1: lowhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22freq1%3A%20low%22
type: bug/fixhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%2Ffix%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
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.