-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: hot module replacement (HMR)state: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
Yes
Description
When trying out the new component HMR we ran into a couple issues when using dynamic component providers
For example:
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
providers: [isDevelopmentMode ? DirectiveTimingService : []],
standalone: false,
})
export class AppComponent {}
Throws app.component.ts:108 ReferenceError: DirectiveTimingService is not defined at runtime:
Not sure if this is the same or a different issue, but declaring a provider with useFactory and deps also throws an error
@Component({
selector: 'cu-prompt-template-empty-description',
templateUrl: './prompt-template-empty-description.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
{
provide: DropdownListKeyboardController,
useFactory: (
parentInjector: Injector,
dropdownListKeyboardController?: DropdownListKeyboardController,
) => {
if (!dropdownListKeyboardController) {
const injector = Injector.create({
providers: [{ provide: DropdownListKeyboardController }],
parent: parentInjector,
});
dropdownListKeyboardController = injector.get(
DropdownListKeyboardController,
);
}
return dropdownListKeyboardController;
},
deps: [
Injector,
[new Optional(), new SkipSelf(), DropdownListKeyboardController],
],
},
],
standalone: false,
})
export class PromptTemplateEmptyDescriptionComponent {}
Will throw ReferenceError: Optional is not defined:
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please let me know if the information above isn't sufficient to create a test case!
Please provide the environment you discovered this bug in (run ng version)
Angular: 19.1.2
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, localize, platform-browser
... platform-browser-dynamic, router, service-worker
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1901.3
@angular-devkit/build-angular 19.1.3
@angular-devkit/core 19.1.3
@angular-devkit/schematics 19.1.3
@angular/build 19.1.3
@angular/cdk 18.2.2
@angular/google-maps 15.2.9
@schematics/angular 19.1.3
ng-packagr 19.0.1
rxjs 7.8.0
typescript 5.6.3
webpack 5.96.1
zone.js 0.14.4
Anything else?
No response
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimecore: hot module replacement (HMR)state: has PR

