{"id":25270177,"url":"https://github.com/distante/angular-nx-tree-shaking-error","last_synced_at":"2025-04-06T06:15:57.940Z","repository":{"id":62601974,"uuid":"560889467","full_name":"distante/angular-nx-tree-shaking-error","owner":"distante","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-05T12:33:00.000Z","size":429,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T11:39:24.366Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/distante.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-11-02T13:48:49.000Z","updated_at":"2022-11-02T13:49:08.000Z","dependencies_parsed_at":"2023-02-04T04:47:47.231Z","dependency_job_id":null,"html_url":"https://github.com/distante/angular-nx-tree-shaking-error","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fangular-nx-tree-shaking-error","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fangular-nx-tree-shaking-error/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fangular-nx-tree-shaking-error/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distante%2Fangular-nx-tree-shaking-error/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/distante","download_url":"https://codeload.github.com/distante/angular-nx-tree-shaking-error/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247441057,"owners_count":20939239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-12T11:29:32.806Z","updated_at":"2025-04-06T06:15:57.911Z","avatar_url":"https://github.com/distante.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree Shaking Problem\r\n\r\n\u003e This repo reproduces a tree shaking problem with angular apps and nx.\r\n\r\nThe monorepo has one angular app (`MyApp`) and one angular library (`MyLibrary`). \r\n\r\n`MyLibrary` contains an `MyLibraryModule` that declares and exports `MyComponentComponent`.\r\n\r\n```typescript\r\n@NgModule({\r\n  imports: [CommonModule],\r\n  declarations: [MyComponentComponent],\r\n  exports: [MyComponentComponent],\r\n})\r\nexport class MyLibraryModule {}\r\n```\r\n\r\nIt is imported in `MyApp` `app.module.ts` file.\r\n```typescript\r\n@NgModule({\r\n  declarations: [AppComponent, NxWelcomeComponent],\r\n  imports: [BrowserModule, MyLibraryModule],\r\n  providers: [],\r\n  bootstrap: [AppComponent],\r\n})\r\nexport class AppModule {}\r\n```\r\n\r\n`MyLibrary` also exports some \"`stub`\" `testing` files that can be used by apps/libraries consumers for unit testing. Those files import some `@testing-library/angular` files in them.\r\n\r\n\u003e⚠️ Currently those files are not imported anywhere.\r\n\r\n# Problem\r\n\r\nAfter building the app with `npx nx build my-app --configuration=production` we get a couple of warnings after build:\r\n\r\n```\r\nWarning: /Users/saninn/dev/temp/tree-shaking/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js depends on 'aria-query'. CommonJS or AMD dependencies can cause optimization bailouts.\r\nFor more info see: https://angular.io/guide/build#configuring-commonjs-dependencies\r\n\r\nWarning: /Users/saninn/dev/temp/tree-shaking/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js depends on 'pretty-format'. CommonJS or AMD dependencies can cause optimization bailouts.\r\nFor more info see: https://angular.io/guide/build#configuring-commonjs-dependencies\r\n```\r\n\r\nand in the generated `main.*.js` file, `testing-library` is being included, even when we have configured our app with `\"optimization\": true,`.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistante%2Fangular-nx-tree-shaking-error","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistante%2Fangular-nx-tree-shaking-error","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistante%2Fangular-nx-tree-shaking-error/lists"}