Title: @ngtools/webpack: `elideImports` keeps type-only specifiers that are re-exported or `extends`-ed, so webpack 5.112 (build-angular 21.2.28) fails the build · Issue #34580 · angular/angular-cli · GitHub
Open Graph Title: @ngtools/webpack: `elideImports` keeps type-only specifiers that are re-exported or `extends`-ed, so webpack 5.112 (build-angular 21.2.28) fails the build · Issue #34580 · angular/angular-cli
X Title: @ngtools/webpack: `elideImports` keeps type-only specifiers that are re-exported or `extends`-ed, so webpack 5.112 (build-angular 21.2.28) fails the build · Issue #34580 · angular/angular-cli
Description: Command build (also serve) Is this a regression? Yes. The previous version in which this bug was not present was 21.2.27 (webpack 5.105.2). Strictly speaking, 21.2.27 already emits the bad import too (see below). webpack 5.112 just makes...
Open Graph Description: Command build (also serve) Is this a regression? Yes. The previous version in which this bug was not present was 21.2.27 (webpack 5.105.2). Strictly speaking, 21.2.27 already emits the bad import t...
X Description: Command build (also serve) Is this a regression? Yes. The previous version in which this bug was not present was 21.2.27 (webpack 5.105.2). Strictly speaking, 21.2.27 already emits the bad import t...
Opengraph URL: https://github.com/angular/angular-cli/issues/34580
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@ngtools/webpack: `elideImports` keeps type-only specifiers that are re-exported or `extends`-ed, so webpack 5.112 (build-angular 21.2.28) fails the build","articleBody":"### Command\n\nbuild (also serve)\n\n### Is this a regression?\n\nYes. The previous version in which this bug was not present was **21.2.27** (webpack 5.105.2). Strictly speaking, 21.2.27 already emits the bad import too (see below). webpack 5.112 just makes it an error.\n\n### Description\n\nWith `@angular-devkit/build-angular:browser` 21.2.28 (which updated webpack to 5.112.0), an AOT build fails with:\n\n```\n./src/app/data.service.ts:1:0-33 - Error: export 'Status' (imported as 'Status') was not found in './types' (module has no exports)\n```\n\n`Status` is an interface. The failure needs all three of these in one file:\n\n1. The file has a decorated class, so `removeIvyJitSupportCalls` removes its `ɵsetClassMetadata` call and runs `elideImports`.\n2. One `import { ... }` statement brings in several interfaces.\n3. Some of those interfaces are used only in type annotations, and at least one is either re-exported (`export type { Status }`) or used in an interface `extends Status`.\n\nWhat happens:\n\n- `elideImports` drops the annotation-only specifiers. Its visitor skips `TypeReferenceNode`s.\n- It keeps the others as \"used\". It records `ExportSpecifier`s without checking for `export type`, and it only skips `implements` heritage clauses, so an interface's `extends` counts as a use.\n- That rewrites the `ImportDeclaration`. TypeScript then skips its own import elision for that statement, because `isElisionBlocked` is true when a `before` transformer has replaced the node.\n- So `import { Status } from './types'` survives into the emitted JS, although `Status` has no runtime value.\n\nWith webpack 5.105 this was a silent dead import. The repro's dev build on 21.2.27 still contains `__webpack_require__(/*! ./types */ ...)` in `data.service`'s module.\n\nwebpack 5.112 now link-checks import specifiers even when they are never read, and Angular's `strictExportPresence: true` makes that an error.\n\nControls (each of these builds cleanly on 21.2.28):\n\n- `import type { Item, Status }`\n- no `export type { Status }`, so both names are annotation-only and the whole import is removed\n- `import { Status }` on its own line plus `export type { Status }`, so nothing in that statement is partially removed and TypeScript elides it as usual\n- the same file without the `@Injectable` decorator, so `elideImports` never runs\n\nA possible fix is for `elideImports` to count a symbol as used only when its alias target has a value meaning (`SymbolFlags.Value`). Narrower alternatives: skip `export type` declarations and specifiers, and skip interface heritage clauses.\n\n### Minimal Reproduction\n\nSeven files. `npm install`, then `npx ng build` (or `npx ng build -c development`).\n\n`package.json`\n```json\n{\n \"name\": \"ngtools-webpack-type-reexport-repro\",\n \"private\": true,\n \"dependencies\": {\n \"@angular/common\": \"21.2.25\",\n \"@angular/compiler\": \"21.2.25\",\n \"@angular/core\": \"21.2.25\",\n \"@angular/platform-browser\": \"21.2.25\",\n \"rxjs\": \"7.8.2\",\n \"tslib\": \"2.8.1\"\n },\n \"devDependencies\": {\n \"@angular-devkit/build-angular\": \"21.2.28\",\n \"@angular/cli\": \"21.2.28\",\n \"@angular/compiler-cli\": \"21.2.25\",\n \"typescript\": \"5.9.3\"\n }\n}\n```\n\n`angular.json`\n```json\n{\n \"version\": 1,\n \"projects\": {\n \"repro\": {\n \"projectType\": \"application\",\n \"root\": \"\",\n \"sourceRoot\": \"src\",\n \"architect\": {\n \"build\": {\n \"builder\": \"@angular-devkit/build-angular:browser\",\n \"options\": {\n \"outputPath\": \"dist/repro\",\n \"index\": \"src/index.html\",\n \"main\": \"src/main.ts\",\n \"tsConfig\": \"tsconfig.json\"\n },\n \"configurations\": {\n \"production\": { \"optimization\": true, \"outputHashing\": \"all\" },\n \"development\": { \"optimization\": false, \"sourceMap\": true }\n },\n \"defaultConfiguration\": \"production\"\n }\n }\n }\n }\n}\n```\n\n`tsconfig.json`\n```json\n{\n \"compilerOptions\": {\n \"strict\": true,\n \"target\": \"ES2022\",\n \"module\": \"ES2022\",\n \"moduleResolution\": \"bundler\",\n \"lib\": [\"ES2022\", \"dom\"],\n \"skipLibCheck\": true\n },\n \"files\": [\"src/main.ts\"]\n}\n```\n\n`src/index.html`\n```html\n\u003c!doctype html>\n\u003chtml>\u003chead>\u003cmeta charset=\"utf-8\">\u003ctitle>repro\u003c/title>\u003c/head>\u003cbody>\u003capp-root>\u003c/app-root>\u003c/body>\u003c/html>\n```\n\n`src/main.ts`\n```ts\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent).catch(err => console.error(err));\n```\n\n`src/app/app.component.ts`\n```ts\nimport { Component, inject } from '@angular/core';\nimport { DataService } from './data.service';\n\n@Component({ selector: 'app-root', template: '{{ id }}' })\nexport class AppComponent {\n id = inject(DataService).first().id;\n}\n```\n\n`src/app/types.ts`\n```ts\nexport interface Item {\n id: number;\n}\n\nexport interface Status {\n done: boolean;\n}\n```\n\n`src/app/data.service.ts`\n```ts\nimport { Injectable } from '@angular/core';\nimport { Item, Status } from './types';\n\n// Re-export a type for consumers of this service.\nexport type { Status };\n\n@Injectable({ providedIn: 'root' })\nexport class DataService {\n first(): Item {\n return { id: 1 };\n }\n}\n```\n\nThe `extends` variant fails the same way. Replace the `export type { Status };` line with:\n\n```ts\nexport interface DetailedStatus extends Status {\n note: string;\n}\n```\n\n### Exception or Error\n\n```\n./src/app/data.service.ts:1:0-33 - Error: export 'Status' (imported as 'Status') was not found in './types' (module has no exports)\n```\n\n### Your Environment\n\n```\nAngular CLI : 21.2.28\nAngular : 21.2.25\nNode.js : 20.20.2\nPackage Manager : npm 10.8.2\nOperating System : darwin arm64\n\n@angular-devkit/build-angular 21.2.28\n@angular/cli 21.2.28\n@angular/common 21.2.25\n@angular/compiler 21.2.25\n@angular/compiler-cli 21.2.25\n@angular/core 21.2.25\n@angular/platform-browser 21.2.25\nrxjs 7.8.2\ntypescript 5.9.3\nwebpack 5.112.0\n```\n\nAlso reproduced on Node 22.23.2 (node:22-alpine) in the real app.\n\n### Anything else relevant?\n\n- We hit this in a production app when moving from build-angular 21.2.26 to 21.2.28. 7 interface names in 3 files failed, and both `ng build` and `ng serve` broke.\n- Workaround: `import type`.\n- Neither TypeScript guard catches it. `isolatedModules` doesn't flag the pattern, and `verbatimModuleSyntax` flags every type import in a large codebase.\n- `ngc` alone emits these files correctly. Only the `@ngtools/webpack` pipeline leaves the specifier behind.\n- The `@angular/build` (esbuild) builders are not affected, as far as we can tell.\n","author":{"url":"https://github.com/ohItzYosh","@type":"Person","name":"ohItzYosh"},"datePublished":"2026-10-29T06:41:04Z","url":"https://github.com/angular/angular-cli/issues/34580"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:76461f09-bbd3-5b86-d5c9-3417c36e04f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4C0:3F8AB1:3B2A4F4:4B29C89:6B01E848 |
| html-safe-nonce | 4740b2ed9da56f1dbf012c83ef790632ea5890cccbeb9a7443dea4b333a8e4b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEMwOjNGOEFCMTozQjJBNEY0OjRCMjlDODk6NkIwMUU4NDgiLCJ2aXNpdG9yX2lkIjoiNjQyNTUyNjE2NzYwMzg5ODQ0MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd66f1d5916b9ea0455e3b7f63efec0dea9912d2e6a0227afe7723ced5a05360 |
| hovercard-subject-tag | issue:6094423486 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34580/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6d3da24a792ce92ced3d1a91b0e15e1f7176e2c8011faad1605f7e50d249efcd/angular/angular-cli/issues/34580 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6d3da24a792ce92ced3d1a91b0e15e1f7176e2c8011faad1605f7e50d249efcd/angular/angular-cli/issues/34580 |
| og:image:alt | Command build (also serve) Is this a regression? Yes. The previous version in which this bug was not present was 21.2.27 (webpack 5.105.2). Strictly speaking, 21.2.27 already emits the bad import t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ohItzYosh |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width