Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b25121e

Browse files
crisbetothePunderWoman
authored andcommitted
fix(compiler): avoid having to duplicate core environment (#58444)
Switches to referencing the core environment directly in the generated code, instead of having to duplicate it. PR Close #58444
1 parent d7a7c80 commit b25121e

File tree

4 files changed

+26
-269
lines changed

4 files changed

+26
-269
lines changed

packages/compiler-cli/test/ngtsc/hmr_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ runInEachFileSystem(() => {
111111
/import\(\s*\/\* @vite-ignore \*\/\s+"\/@ng\/component\?c=test\.ts%40Cmp&t=" \+ encodeURIComponent\(d.timestamp\)/,
112112
);
113113
expect(jsContents).toMatch(
114-
/\).then\(m => i0\.ɵɵreplaceMetadata\(Cmp, m\.default, \[Dep, transformValue, TOKEN, Component, Inject, ViewChild, Input\]\)\);/,
114+
/\).then\(m => i0\.ɵɵreplaceMetadata\(Cmp, m\.default, i0, \[Dep, transformValue, TOKEN, Component, Inject, ViewChild, Input\]\)\);/,
115115
);
116116

117117
expect(hmrContents).toContain(

packages/compiler/src/render3/r3_hmr_compiler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ export function compileHmrInitializer(meta: R3HmrMetadata): o.Expression {
4343
const dataName = 'd';
4444
const locals = meta.locals.map((localName) => o.variable(localName));
4545

46-
// ɵɵreplaceMetadata(Comp, m.default, [...]);
46+
// ɵɵreplaceMetadata(Comp, m.default, core, [...]);
4747
const replaceMetadata = o
4848
.importExpr(R3.replaceMetadata)
49-
.callFn([meta.type, o.variable(moduleName).prop('default'), o.literalArr(locals)]);
49+
.callFn([
50+
meta.type,
51+
o.variable(moduleName).prop('default'),
52+
new o.ExternalExpr(R3.core),
53+
o.literalArr(locals),
54+
]);
5055

5156
// (m) => ɵɵreplaceMetadata(...)
5257
const replaceCallback = o.arrowFn([new o.FnParam(moduleName)], replaceMetadata);

packages/core/src/render3/hmr.ts

Lines changed: 3 additions & 257 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {Type} from '../interface/type';
1010
import {assertDefined} from '../util/assert';
1111
import {assertLView} from './assert';
12-
import {ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefineNgModule, ɵɵdefinePipe} from './definition';
1312
import {getComponentDef} from './def_getters';
1413
import {assertComponentDef} from './errors';
1514
import {refreshView} from './instructions/change_detection';
@@ -42,74 +41,29 @@ import {
4241
import {assertTNodeType} from './node_assert';
4342
import {destroyLView, removeViewFromDOM} from './node_manipulation';
4443

45-
import * as iframe_attrs_validation from '../sanitization/iframe_attrs_validation';
46-
import * as sanitization from '../sanitization/sanitization';
47-
import * as r3 from './instructions/all';
48-
import {
49-
ɵɵdefineInjectable,
50-
ɵɵdefineInjector,
51-
ɵɵinject,
52-
ɵɵinvalidFactoryDep,
53-
forwardRef,
54-
resolveForwardRef,
55-
} from '../di';
56-
import {registerNgModuleType} from '../linker/ng_module_registration';
57-
import {ɵɵgetInheritedFactory} from './di';
58-
import {ɵɵgetComponentDepsFactory} from './local_compilation';
59-
import {ɵɵpipeBind1, ɵɵpipeBind2, ɵɵpipeBind3, ɵɵpipeBind4, ɵɵpipeBindV, ɵɵpipe} from './pipe';
60-
import {
61-
ɵɵpureFunction0,
62-
ɵɵpureFunction1,
63-
ɵɵpureFunction2,
64-
ɵɵpureFunction3,
65-
ɵɵpureFunction4,
66-
ɵɵpureFunction5,
67-
ɵɵpureFunction6,
68-
ɵɵpureFunction7,
69-
ɵɵpureFunction8,
70-
ɵɵpureFunctionV,
71-
} from './pure_function';
72-
import {ɵɵsetComponentScope, ɵɵsetNgModuleScope} from './scope';
73-
import {ɵɵresetView, ɵɵenableBindings, ɵɵdisableBindings, ɵɵrestoreView} from './state';
74-
import {ɵɵtemplateRefExtractor} from './view_engine_compatibility_prebound';
75-
import {ɵɵHostDirectivesFeature} from './features/host_directives_feature';
76-
import {ɵɵNgOnChangesFeature} from './features/ng_onchanges_feature';
77-
import {ɵɵProvidersFeature} from './features/providers_feature';
78-
import {ɵɵCopyDefinitionFeature} from './features/copy_definition_feature';
79-
import {ɵɵInheritDefinitionFeature} from './features/inherit_definition_feature';
80-
import {ɵɵInputTransformsFeature} from './features/input_transforms_feature';
81-
import {ɵɵExternalStylesFeature} from './features/external_styles_feature';
82-
import {ɵɵresolveBody, ɵɵresolveDocument, ɵɵresolveWindow} from './util/misc_utils';
83-
import {ɵsetClassDebugInfo} from './debug/set_debug_info';
84-
85-
/** Cached environment for all HMR calls. */
86-
let hmrEnvironment: Record<string, unknown> | null = null;
87-
8844
/**
8945
* Replaces the metadata of a component type and re-renders all live instances of the component.
9046
* @param type Class whose metadata will be replaced.
9147
* @param applyMetadata Callback that will apply a new set of metadata on the `type` when invoked.
48+
* @param environment Core runtime environment to use when applying the HMR update.
9249
* @param locals Local symbols from the source location that have to be exposed to the callback.
9350
* @codeGenApi
9451
*/
9552
export function ɵɵreplaceMetadata(
9653
type: Type<unknown>,
9754
applyMetadata: (...args: [Type<unknown>, Record<string, unknown>, ...unknown[]]) => void,
55+
environment: Record<string, unknown>,
9856
locals: unknown[],
9957
) {
10058
ngDevMode && assertComponentDef(type);
10159
const oldDef = getComponentDef(type)!;
10260

103-
if (hmrEnvironment === null) {
104-
hmrEnvironment = getHmrEnv();
105-
}
106-
10761
// The reason `applyMetadata` is a callback that is invoked (almost) immediately is because
10862
// the compiler usually produces more code than just the component definition, e.g. there
10963
// can be functions for embedded views, the variables for the constant pool and `setClassMetadata`
11064
// calls. The callback allows us to keep them isolate from the rest of the app and to invoke
11165
// them at the right time.
112-
applyMetadata.apply(null, [type, hmrEnvironment, ...locals]);
66+
applyMetadata.apply(null, [type, environment, ...locals]);
11367

11468
// If a `tView` hasn't been created yet, it means that this component hasn't been instantianted
11569
// before. In this case there's nothing left for us to do aside from patching it in.
@@ -278,211 +232,3 @@ function resetProjectionState(tNode: TElementNode): void {
278232
tNode.projection = null;
279233
}
280234
}
281-
282-
/**
283-
* The HMR replacement function needs access to all of `core`. This is similar to the
284-
* `angularCoreEnv`, but without `replaceMetadata` to avoid circular dependencies. Furthermore,
285-
* we can't something like a `nonHmrEnv` that is then combined with `replaceMetadata` to form the
286-
* full environment, because it seems to break tree shaking internally.
287-
*
288-
* TODO(crisbeto): this is a temporary solution, we should be able to pass this in directly.
289-
*/
290-
function getHmrEnv(): Record<string, unknown> {
291-
return {
292-
'ɵɵattribute': r3.ɵɵattribute,
293-
'ɵɵattributeInterpolate1': r3.ɵɵattributeInterpolate1,
294-
'ɵɵattributeInterpolate2': r3.ɵɵattributeInterpolate2,
295-
'ɵɵattributeInterpolate3': r3.ɵɵattributeInterpolate3,
296-
'ɵɵattributeInterpolate4': r3.ɵɵattributeInterpolate4,
297-
'ɵɵattributeInterpolate5': r3.ɵɵattributeInterpolate5,
298-
'ɵɵattributeInterpolate6': r3.ɵɵattributeInterpolate6,
299-
'ɵɵattributeInterpolate7': r3.ɵɵattributeInterpolate7,
300-
'ɵɵattributeInterpolate8': r3.ɵɵattributeInterpolate8,
301-
'ɵɵattributeInterpolateV': r3.ɵɵattributeInterpolateV,
302-
'ɵɵdefineComponent': ɵɵdefineComponent,
303-
'ɵɵdefineDirective': ɵɵdefineDirective,
304-
'ɵɵdefineInjectable': ɵɵdefineInjectable,
305-
'ɵɵdefineInjector': ɵɵdefineInjector,
306-
'ɵɵdefineNgModule': ɵɵdefineNgModule,
307-
'ɵɵdefinePipe': ɵɵdefinePipe,
308-
'ɵɵdirectiveInject': r3.ɵɵdirectiveInject,
309-
'ɵɵgetInheritedFactory': ɵɵgetInheritedFactory,
310-
'ɵɵinject': ɵɵinject,
311-
'ɵɵinjectAttribute': r3.ɵɵinjectAttribute,
312-
'ɵɵinvalidFactory': r3.ɵɵinvalidFactory,
313-
'ɵɵinvalidFactoryDep': ɵɵinvalidFactoryDep,
314-
'ɵɵtemplateRefExtractor': ɵɵtemplateRefExtractor,
315-
'ɵɵresetView': ɵɵresetView,
316-
'ɵɵHostDirectivesFeature': ɵɵHostDirectivesFeature,
317-
'ɵɵNgOnChangesFeature': ɵɵNgOnChangesFeature,
318-
'ɵɵProvidersFeature': ɵɵProvidersFeature,
319-
'ɵɵCopyDefinitionFeature': ɵɵCopyDefinitionFeature,
320-
'ɵɵInheritDefinitionFeature': ɵɵInheritDefinitionFeature,
321-
'ɵɵInputTransformsFeature': ɵɵInputTransformsFeature,
322-
'ɵɵExternalStylesFeature': ɵɵExternalStylesFeature,
323-
'ɵɵnextContext': r3.ɵɵnextContext,
324-
'ɵɵnamespaceHTML': r3.ɵɵnamespaceHTML,
325-
'ɵɵnamespaceMathML': r3.ɵɵnamespaceMathML,
326-
'ɵɵnamespaceSVG': r3.ɵɵnamespaceSVG,
327-
'ɵɵenableBindings': ɵɵenableBindings,
328-
'ɵɵdisableBindings': ɵɵdisableBindings,
329-
'ɵɵelementStart': r3.ɵɵelementStart,
330-
'ɵɵelementEnd': r3.ɵɵelementEnd,
331-
'ɵɵelement': r3.ɵɵelement,
332-
'ɵɵelementContainerStart': r3.ɵɵelementContainerStart,
333-
'ɵɵelementContainerEnd': r3.ɵɵelementContainerEnd,
334-
'ɵɵelementContainer': r3.ɵɵelementContainer,
335-
'ɵɵpureFunction0': ɵɵpureFunction0,
336-
'ɵɵpureFunction1': ɵɵpureFunction1,
337-
'ɵɵpureFunction2': ɵɵpureFunction2,
338-
'ɵɵpureFunction3': ɵɵpureFunction3,
339-
'ɵɵpureFunction4': ɵɵpureFunction4,
340-
'ɵɵpureFunction5': ɵɵpureFunction5,
341-
'ɵɵpureFunction6': ɵɵpureFunction6,
342-
'ɵɵpureFunction7': ɵɵpureFunction7,
343-
'ɵɵpureFunction8': ɵɵpureFunction8,
344-
'ɵɵpureFunctionV': ɵɵpureFunctionV,
345-
'ɵɵgetCurrentView': r3.ɵɵgetCurrentView,
346-
'ɵɵrestoreView': ɵɵrestoreView,
347-
'ɵɵlistener': r3.ɵɵlistener,
348-
'ɵɵprojection': r3.ɵɵprojection,
349-
'ɵɵsyntheticHostProperty': r3.ɵɵsyntheticHostProperty,
350-
'ɵɵsyntheticHostListener': r3.ɵɵsyntheticHostListener,
351-
'ɵɵpipeBind1': ɵɵpipeBind1,
352-
'ɵɵpipeBind2': ɵɵpipeBind2,
353-
'ɵɵpipeBind3': ɵɵpipeBind3,
354-
'ɵɵpipeBind4': ɵɵpipeBind4,
355-
'ɵɵpipeBindV': ɵɵpipeBindV,
356-
'ɵɵprojectionDef': r3.ɵɵprojectionDef,
357-
'ɵɵhostProperty': r3.ɵɵhostProperty,
358-
'ɵɵproperty': r3.ɵɵproperty,
359-
'ɵɵpropertyInterpolate': r3.ɵɵpropertyInterpolate,
360-
'ɵɵpropertyInterpolate1': r3.ɵɵpropertyInterpolate1,
361-
'ɵɵpropertyInterpolate2': r3.ɵɵpropertyInterpolate2,
362-
'ɵɵpropertyInterpolate3': r3.ɵɵpropertyInterpolate3,
363-
'ɵɵpropertyInterpolate4': r3.ɵɵpropertyInterpolate4,
364-
'ɵɵpropertyInterpolate5': r3.ɵɵpropertyInterpolate5,
365-
'ɵɵpropertyInterpolate6': r3.ɵɵpropertyInterpolate6,
366-
'ɵɵpropertyInterpolate7': r3.ɵɵpropertyInterpolate7,
367-
'ɵɵpropertyInterpolate8': r3.ɵɵpropertyInterpolate8,
368-
'ɵɵpropertyInterpolateV': r3.ɵɵpropertyInterpolateV,
369-
'ɵɵpipe': ɵɵpipe,
370-
'ɵɵqueryRefresh': r3.ɵɵqueryRefresh,
371-
'ɵɵqueryAdvance': r3.ɵɵqueryAdvance,
372-
'ɵɵviewQuery': r3.ɵɵviewQuery,
373-
'ɵɵviewQuerySignal': r3.ɵɵviewQuerySignal,
374-
'ɵɵloadQuery': r3.ɵɵloadQuery,
375-
'ɵɵcontentQuery': r3.ɵɵcontentQuery,
376-
'ɵɵcontentQuerySignal': r3.ɵɵcontentQuerySignal,
377-
'ɵɵreference': r3.ɵɵreference,
378-
'ɵɵclassMap': r3.ɵɵclassMap,
379-
'ɵɵclassMapInterpolate1': r3.ɵɵclassMapInterpolate1,
380-
'ɵɵclassMapInterpolate2': r3.ɵɵclassMapInterpolate2,
381-
'ɵɵclassMapInterpolate3': r3.ɵɵclassMapInterpolate3,
382-
'ɵɵclassMapInterpolate4': r3.ɵɵclassMapInterpolate4,
383-
'ɵɵclassMapInterpolate5': r3.ɵɵclassMapInterpolate5,
384-
'ɵɵclassMapInterpolate6': r3.ɵɵclassMapInterpolate6,
385-
'ɵɵclassMapInterpolate7': r3.ɵɵclassMapInterpolate7,
386-
'ɵɵclassMapInterpolate8': r3.ɵɵclassMapInterpolate8,
387-
'ɵɵclassMapInterpolateV': r3.ɵɵclassMapInterpolateV,
388-
'ɵɵstyleMap': r3.ɵɵstyleMap,
389-
'ɵɵstyleMapInterpolate1': r3.ɵɵstyleMapInterpolate1,
390-
'ɵɵstyleMapInterpolate2': r3.ɵɵstyleMapInterpolate2,
391-
'ɵɵstyleMapInterpolate3': r3.ɵɵstyleMapInterpolate3,
392-
'ɵɵstyleMapInterpolate4': r3.ɵɵstyleMapInterpolate4,
393-
'ɵɵstyleMapInterpolate5': r3.ɵɵstyleMapInterpolate5,
394-
'ɵɵstyleMapInterpolate6': r3.ɵɵstyleMapInterpolate6,
395-
'ɵɵstyleMapInterpolate7': r3.ɵɵstyleMapInterpolate7,
396-
'ɵɵstyleMapInterpolate8': r3.ɵɵstyleMapInterpolate8,
397-
'ɵɵstyleMapInterpolateV': r3.ɵɵstyleMapInterpolateV,
398-
'ɵɵstyleProp': r3.ɵɵstyleProp,
399-
'ɵɵstylePropInterpolate1': r3.ɵɵstylePropInterpolate1,
400-
'ɵɵstylePropInterpolate2': r3.ɵɵstylePropInterpolate2,
401-
'ɵɵstylePropInterpolate3': r3.ɵɵstylePropInterpolate3,
402-
'ɵɵstylePropInterpolate4': r3.ɵɵstylePropInterpolate4,
403-
'ɵɵstylePropInterpolate5': r3.ɵɵstylePropInterpolate5,
404-
'ɵɵstylePropInterpolate6': r3.ɵɵstylePropInterpolate6,
405-
'ɵɵstylePropInterpolate7': r3.ɵɵstylePropInterpolate7,
406-
'ɵɵstylePropInterpolate8': r3.ɵɵstylePropInterpolate8,
407-
'ɵɵstylePropInterpolateV': r3.ɵɵstylePropInterpolateV,
408-
'ɵɵclassProp': r3.ɵɵclassProp,
409-
'ɵɵadvance': r3.ɵɵadvance,
410-
'ɵɵtemplate': r3.ɵɵtemplate,
411-
'ɵɵconditional': r3.ɵɵconditional,
412-
'ɵɵdefer': r3.ɵɵdefer,
413-
'ɵɵdeferWhen': r3.ɵɵdeferWhen,
414-
'ɵɵdeferOnIdle': r3.ɵɵdeferOnIdle,
415-
'ɵɵdeferOnImmediate': r3.ɵɵdeferOnImmediate,
416-
'ɵɵdeferOnTimer': r3.ɵɵdeferOnTimer,
417-
'ɵɵdeferOnHover': r3.ɵɵdeferOnHover,
418-
'ɵɵdeferOnInteraction': r3.ɵɵdeferOnInteraction,
419-
'ɵɵdeferOnViewport': r3.ɵɵdeferOnViewport,
420-
'ɵɵdeferPrefetchWhen': r3.ɵɵdeferPrefetchWhen,
421-
'ɵɵdeferPrefetchOnIdle': r3.ɵɵdeferPrefetchOnIdle,
422-
'ɵɵdeferPrefetchOnImmediate': r3.ɵɵdeferPrefetchOnImmediate,
423-
'ɵɵdeferPrefetchOnTimer': r3.ɵɵdeferPrefetchOnTimer,
424-
'ɵɵdeferPrefetchOnHover': r3.ɵɵdeferPrefetchOnHover,
425-
'ɵɵdeferPrefetchOnInteraction': r3.ɵɵdeferPrefetchOnInteraction,
426-
'ɵɵdeferPrefetchOnViewport': r3.ɵɵdeferPrefetchOnViewport,
427-
'ɵɵdeferHydrateWhen': r3.ɵɵdeferHydrateWhen,
428-
'ɵɵdeferHydrateNever': r3.ɵɵdeferHydrateNever,
429-
'ɵɵdeferHydrateOnIdle': r3.ɵɵdeferHydrateOnIdle,
430-
'ɵɵdeferHydrateOnImmediate': r3.ɵɵdeferHydrateOnImmediate,
431-
'ɵɵdeferHydrateOnTimer': r3.ɵɵdeferHydrateOnTimer,
432-
'ɵɵdeferHydrateOnHover': r3.ɵɵdeferHydrateOnHover,
433-
'ɵɵdeferHydrateOnInteraction': r3.ɵɵdeferHydrateOnInteraction,
434-
'ɵɵdeferHydrateOnViewport': r3.ɵɵdeferHydrateOnViewport,
435-
'ɵɵdeferEnableTimerScheduling': r3.ɵɵdeferEnableTimerScheduling,
436-
'ɵɵrepeater': r3.ɵɵrepeater,
437-
'ɵɵrepeaterCreate': r3.ɵɵrepeaterCreate,
438-
'ɵɵrepeaterTrackByIndex': r3.ɵɵrepeaterTrackByIndex,
439-
'ɵɵrepeaterTrackByIdentity': r3.ɵɵrepeaterTrackByIdentity,
440-
'ɵɵcomponentInstance': r3.ɵɵcomponentInstance,
441-
'ɵɵtext': r3.ɵɵtext,
442-
'ɵɵtextInterpolate': r3.ɵɵtextInterpolate,
443-
'ɵɵtextInterpolate1': r3.ɵɵtextInterpolate1,
444-
'ɵɵtextInterpolate2': r3.ɵɵtextInterpolate2,
445-
'ɵɵtextInterpolate3': r3.ɵɵtextInterpolate3,
446-
'ɵɵtextInterpolate4': r3.ɵɵtextInterpolate4,
447-
'ɵɵtextInterpolate5': r3.ɵɵtextInterpolate5,
448-
'ɵɵtextInterpolate6': r3.ɵɵtextInterpolate6,
449-
'ɵɵtextInterpolate7': r3.ɵɵtextInterpolate7,
450-
'ɵɵtextInterpolate8': r3.ɵɵtextInterpolate8,
451-
'ɵɵtextInterpolateV': r3.ɵɵtextInterpolateV,
452-
'ɵɵi18n': r3.ɵɵi18n,
453-
'ɵɵi18nAttributes': r3.ɵɵi18nAttributes,
454-
'ɵɵi18nExp': r3.ɵɵi18nExp,
455-
'ɵɵi18nStart': r3.ɵɵi18nStart,
456-
'ɵɵi18nEnd': r3.ɵɵi18nEnd,
457-
'ɵɵi18nApply': r3.ɵɵi18nApply,
458-
'ɵɵi18nPostprocess': r3.ɵɵi18nPostprocess,
459-
'ɵɵresolveWindow': ɵɵresolveWindow,
460-
'ɵɵresolveDocument': ɵɵresolveDocument,
461-
'ɵɵresolveBody': ɵɵresolveBody,
462-
'ɵɵsetComponentScope': ɵɵsetComponentScope,
463-
'ɵɵsetNgModuleScope': ɵɵsetNgModuleScope,
464-
'ɵɵregisterNgModuleType': registerNgModuleType,
465-
'ɵɵgetComponentDepsFactory': ɵɵgetComponentDepsFactory,
466-
'ɵsetClassDebugInfo': ɵsetClassDebugInfo,
467-
'ɵɵdeclareLet': r3.ɵɵdeclareLet,
468-
'ɵɵstoreLet': r3.ɵɵstoreLet,
469-
'ɵɵreadContextLet': r3.ɵɵreadContextLet,
470-
471-
'ɵɵsanitizeHtml': sanitization.ɵɵsanitizeHtml,
472-
'ɵɵsanitizeStyle': sanitization.ɵɵsanitizeStyle,
473-
'ɵɵsanitizeResourceUrl': sanitization.ɵɵsanitizeResourceUrl,
474-
'ɵɵsanitizeScript': sanitization.ɵɵsanitizeScript,
475-
'ɵɵsanitizeUrl': sanitization.ɵɵsanitizeUrl,
476-
'ɵɵsanitizeUrlOrResourceUrl': sanitization.ɵɵsanitizeUrlOrResourceUrl,
477-
'ɵɵtrustConstantHtml': sanitization.ɵɵtrustConstantHtml,
478-
'ɵɵtrustConstantResourceUrl': sanitization.ɵɵtrustConstantResourceUrl,
479-
'ɵɵvalidateIframeAttribute': iframe_attrs_validation.ɵɵvalidateIframeAttribute,
480-
481-
'forwardRef': forwardRef,
482-
'resolveForwardRef': resolveForwardRef,
483-
484-
'ɵɵtwoWayProperty': r3.ɵɵtwoWayProperty,
485-
'ɵɵtwoWayBindingSet': r3.ɵɵtwoWayBindingSet,
486-
'ɵɵtwoWayListener': r3.ɵɵtwoWayListener,
487-
};
488-
}

packages/core/test/acceptance/hmr_spec.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from '@angular/core';
3030
import {TestBed} from '@angular/core/testing';
3131
import {compileComponent} from '@angular/core/src/render3/jit/directive';
32+
import {angularCoreEnv} from '@angular/core/src/render3/jit/environment';
3233
import {clearTranslations, loadTranslations} from '@angular/localize';
3334
import {computeMsgId} from '@angular/compiler';
3435

@@ -1955,15 +1956,20 @@ describe('hot module replacement', () => {
19551956
const CREATED_INITIALLY_MARKER = '__ngCreatedInitially__';
19561957

19571958
function replaceMetadata(type: Type<unknown>, metadata: Component) {
1958-
ɵɵreplaceMetadata(type, () => {
1959-
// TODO: the content of this callback is a hacky workaround to invoke the compiler in a test.
1960-
// in reality the callback will be generated by the compiler to be something along the lines
1961-
// of `MyComp[ɵcmp] = /* metadata */`.
1962-
// TODO: in reality this callback should also include `setClassMetadata` and
1963-
// `setClassDebugInfo`.
1964-
(type as any)[ɵNG_COMP_DEF] = null;
1965-
compileComponent(type, metadata);
1966-
}, []);
1959+
ɵɵreplaceMetadata(
1960+
type,
1961+
() => {
1962+
// TODO: the content of this callback is a hacky workaround to invoke the compiler in a test.
1963+
// in reality the callback will be generated by the compiler to be something along the lines
1964+
// of `MyComp[ɵcmp] = /* metadata */`.
1965+
// TODO: in reality this callback should also include `setClassMetadata` and
1966+
// `setClassDebugInfo`.
1967+
(type as any)[ɵNG_COMP_DEF] = null;
1968+
compileComponent(type, metadata);
1969+
},
1970+
angularCoreEnv,
1971+
[],
1972+
);
19671973
}
19681974

19691975
function expectHTML(element: HTMLElement, expectation: string) {

0 commit comments

Comments
 (0)