Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/@ngtools/webpack/src/transformers/elide_imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export function elideImports(
.forEach((id) => {
if (removedSymbolMap.has(id.text)) {
const symbol = removedSymbolMap.get(id.text);
if (typeChecker.getSymbolAtLocation(id) === symbol.symbol) {

// Check if the symbol is the same or if it is a named export.
// Named exports don't have the same symbol but will have the same name.
if ((id.parent && id.parent.kind === ts.SyntaxKind.ExportSpecifier)
|| typeChecker.getSymbolAtLocation(id) === symbol.symbol) {
symbol.all.push(id);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe('@ngtools/webpack transformers', () => {

it('should not remove imports from types that are still used', () => {
const input = stripIndent`
import { Component, EventEmitter } from '@angular/core';
import { Component, ChangeDetectionStrategy, EventEmitter } from '@angular/core';

@Component({
selector: 'app-root',
Expand All @@ -123,16 +123,20 @@ describe('@ngtools/webpack transformers', () => {
notify: EventEmitter<string> = new EventEmitter<string>();
title = 'app';
}

export { ChangeDetectionStrategy };
`;
const output = stripIndent`
import { EventEmitter } from '@angular/core';
import { ChangeDetectionStrategy, EventEmitter } from '@angular/core';

export class AppComponent {
constructor() {
this.notify = new EventEmitter();
this.title = 'app';
}
}

export { ChangeDetectionStrategy };
`;

const { program, compilerHost } = createTypescriptContext(input);
Expand Down