mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(core): remove the standalone feature (#58288)
By removing the standalone feature, we reduce the amount of code generated for components but at the cost of including the `StandaloneService` in the main bundle even if no standalone components are included in it. PR Close #58288
This commit is contained in:
parent
c7342bec24
commit
5d9cc8f408
55 changed files with 160 additions and 151 deletions
|
|
@ -15,7 +15,7 @@
|
|||
"uncompressed": {
|
||||
"main": 108611,
|
||||
"polyfills": 34169,
|
||||
"lazy.routes": 368
|
||||
"lazy.routes": 361
|
||||
}
|
||||
},
|
||||
"forms": {
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
"uncompressed": {
|
||||
"main": 11497,
|
||||
"polyfills": 33807,
|
||||
"defer.component": 351
|
||||
"defer.component": 345
|
||||
}
|
||||
},
|
||||
"platform-server-hydration/browser": {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ SignalCmp.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({
|
|||
type: SignalCmp,
|
||||
selectors: [["ng-component"]],
|
||||
signals: true,
|
||||
features: [i0.ɵɵStandaloneFeature],
|
||||
decls: 1,
|
||||
vars: 0,
|
||||
template: function SignalCmp_Template(rf, ctx) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
StandaloneCmp.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({
|
||||
type: StandaloneCmp,
|
||||
selectors: [["ng-component"]],
|
||||
features: [i0.ɵɵStandaloneFeature],
|
||||
decls: 1,
|
||||
vars: 0,
|
||||
template: function StandaloneCmp_Template(rf, ctx) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
StandaloneCmp.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({
|
||||
type: StandaloneCmp,
|
||||
selectors: [["ng-component"]],
|
||||
features: [i0.ɵɵStandaloneFeature],
|
||||
decls: 1,
|
||||
vars: 0,
|
||||
template: function StandaloneCmp_Template(rf, ctx) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ TestComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({
|
|||
selectors: [
|
||||
["test"]
|
||||
],
|
||||
features: [i0.ɵɵStandaloneFeature],
|
||||
decls: 1,
|
||||
vars: 0,
|
||||
template: function TestComponent_Template(rf, ctx) {
|
||||
|
|
|
|||
|
|
@ -10470,9 +10470,7 @@ runInEachFileSystem((os: string) => {
|
|||
const dtsContents = env.getContents('test.d.ts');
|
||||
|
||||
expect(jsContents).toContain('inputs: { value: [2, "value", "value", toNumber] }');
|
||||
expect(jsContents).toContain(
|
||||
'features: [i0.ɵɵInputTransformsFeature, i0.ɵɵStandaloneFeature]',
|
||||
);
|
||||
expect(jsContents).toContain('features: [i0.ɵɵInputTransformsFeature]');
|
||||
expect(dtsContents).toContain('static ngAcceptInputType_value: boolean | string;');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -539,8 +539,6 @@ export class Identifiers {
|
|||
moduleName: CORE,
|
||||
};
|
||||
|
||||
static StandaloneFeature: o.ExternalReference = {name: 'ɵɵStandaloneFeature', moduleName: CORE};
|
||||
|
||||
static ProvidersFeature: o.ExternalReference = {name: 'ɵɵProvidersFeature', moduleName: CORE};
|
||||
|
||||
static HostDirectivesFeature: o.ExternalReference = {
|
||||
|
|
|
|||
|
|
@ -148,10 +148,6 @@ function addFeatures(
|
|||
if (meta.lifecycle.usesOnChanges) {
|
||||
features.push(o.importExpr(R3.NgOnChangesFeature));
|
||||
}
|
||||
// TODO: better way of differentiating component vs directive metadata.
|
||||
if (meta.hasOwnProperty('template') && meta.isStandalone) {
|
||||
features.push(o.importExpr(R3.StandaloneFeature));
|
||||
}
|
||||
if ('externalStyles' in meta && meta.externalStyles?.length) {
|
||||
const externalStyleNodes = meta.externalStyles.map((externalStyle) => o.literal(externalStyle));
|
||||
features.push(
|
||||
|
|
|
|||
|
|
@ -33,11 +33,11 @@ import {PendingTasksInternal} from '../pending_tasks';
|
|||
import {RendererFactory2} from '../render/api';
|
||||
import {AfterRenderManager} from '../render3/after_render/manager';
|
||||
import {ComponentFactory as R3ComponentFactory} from '../render3/component_ref';
|
||||
import {isStandalone} from '../render3/definition';
|
||||
import {isStandalone} from '../render3/def_getters';
|
||||
import {ChangeDetectionMode, detectChangesInternal} from '../render3/instructions/change_detection';
|
||||
import {FLAGS, LView, LViewFlags} from '../render3/interfaces/view';
|
||||
import {LView} from '../render3/interfaces/view';
|
||||
import {publishDefaultGlobalUtils as _publishDefaultGlobalUtils} from '../render3/util/global_utils';
|
||||
import {removeLViewOnDestroy, requiresRefreshOrTraversal} from '../render3/util/view_utils';
|
||||
import {requiresRefreshOrTraversal} from '../render3/util/view_utils';
|
||||
import {ViewRef as InternalViewRef} from '../render3/view_ref';
|
||||
import {TESTABILITY} from '../testability/testability';
|
||||
import {isPromise} from '../util/lang';
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export {
|
|||
createEnvironmentInjector,
|
||||
} from './render3/ng_module_ref';
|
||||
export {createComponent, reflectComponentType, ComponentMirror} from './render3/component';
|
||||
export {isStandalone} from './render3/definition';
|
||||
export {isStandalone} from './render3/def_getters';
|
||||
export {AfterRenderPhase, AfterRenderRef} from './render3/after_render/api';
|
||||
export {publishExternalGlobalUtil as ɵpublishExternalGlobalUtil} from './render3/util/global_utils';
|
||||
export {
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ export {
|
|||
ɵɵsetComponentScope,
|
||||
ɵɵsetNgModuleScope,
|
||||
ɵɵgetComponentDepsFactory,
|
||||
ɵɵStandaloneFeature,
|
||||
ɵɵExternalStylesFeature,
|
||||
ɵɵstyleMap,
|
||||
ɵɵstyleMapInterpolate1,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import {PendingTasksInternal} from '../pending_tasks';
|
|||
import {assertLContainer, assertTNodeForLView} from '../render3/assert';
|
||||
import {bindingUpdated} from '../render3/bindings';
|
||||
import {ChainedInjector} from '../render3/chained_injector';
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef} from '../render3/definition';
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef} from '../render3/def_getters';
|
||||
import {getTemplateLocationDetails} from '../render3/instructions/element_validation';
|
||||
import {markViewDirty} from '../render3/instructions/mark_view_dirty';
|
||||
import {handleError} from '../render3/instructions/shared';
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import {RuntimeError, RuntimeErrorCode} from '../errors';
|
||||
import {Type} from '../interface/type';
|
||||
import {getComponentDef} from '../render3/definition';
|
||||
import {getComponentDef} from '../render3/def_getters';
|
||||
import {getFactoryDef} from '../render3/definition_factory';
|
||||
import {throwCyclicDependencyError, throwInvalidProviderError} from '../render3/errors_di';
|
||||
import {stringifyForError} from '../render3/util/stringify_utils';
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import {ViewEncapsulation} from '../metadata';
|
|||
import {Renderer2} from '../render';
|
||||
import {assertTNode} from '../render3/assert';
|
||||
import {collectNativeNodes, collectNativeNodesInLContainer} from '../render3/collect_native_nodes';
|
||||
import {getComponentDef} from '../render3/definition';
|
||||
import {getComponentDef} from '../render3/def_getters';
|
||||
import {CONTAINER_HEADER_OFFSET, LContainer} from '../render3/interfaces/container';
|
||||
import {isLetDeclaration, isTNodeShape, TNode, TNodeType} from '../render3/interfaces/node';
|
||||
import {RComment, RElement} from '../render3/interfaces/renderer_dom';
|
||||
|
|
|
|||
|
|
@ -9,11 +9,10 @@
|
|||
import {Injectable} from '../di/injectable';
|
||||
import {InjectionToken} from '../di/injection_token';
|
||||
import {StaticProvider} from '../di/interface/provider';
|
||||
import {MissingTranslationStrategy} from '../i18n/tokens';
|
||||
import {Type} from '../interface/type';
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {ComponentFactory as ComponentFactoryR3} from '../render3/component_ref';
|
||||
import {getComponentDef, getNgModuleDef} from '../render3/definition';
|
||||
import {getComponentDef, getNgModuleDef} from '../render3/def_getters';
|
||||
import {NgModuleFactory as NgModuleFactoryR3} from '../render3/ng_module_ref';
|
||||
import {maybeUnwrapFn} from '../render3/util/misc_utils';
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
import {Type} from '../interface/type';
|
||||
import {NgModuleType} from '../metadata/ng_module_def';
|
||||
import {getNgModuleDef} from '../render3/definition';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import {findMatchingDehydratedView, locateDehydratedViewsInContainer} from '../h
|
|||
import {isType, Type} from '../interface/type';
|
||||
import {assertNodeInjector} from '../render3/assert';
|
||||
import {ComponentFactory as R3ComponentFactory} from '../render3/component_ref';
|
||||
import {getComponentDef} from '../render3/definition';
|
||||
import {getComponentDef} from '../render3/def_getters';
|
||||
import {getParentInjectorLocation, NodeInjector} from '../render3/di';
|
||||
import {addToEndOfViewTree, createLContainer} from '../render3/instructions/shared';
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
import {RuntimeError, RuntimeErrorCode} from '../errors';
|
||||
import {assertDefined, assertEqual, assertNumber, throwError} from '../util/assert';
|
||||
|
||||
import {getComponentDef, getNgModuleDef} from './definition';
|
||||
import {getComponentDef, getNgModuleDef} from './def_getters';
|
||||
import {LContainer} from './interfaces/container';
|
||||
import {DirectiveDef} from './interfaces/definition';
|
||||
import {TIcu} from './interfaces/i18n';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import {Type} from '../interface/type';
|
|||
import {ComponentRef} from '../linker/component_factory';
|
||||
|
||||
import {ComponentFactory} from './component_ref';
|
||||
import {getComponentDef} from './definition';
|
||||
import {getComponentDef} from './def_getters';
|
||||
import {assertComponentDef} from './errors';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import {assertDefined, assertGreaterThan, assertIndexInRange} from '../util/asse
|
|||
|
||||
import {assertComponentType, assertNoDuplicateDirectives} from './assert';
|
||||
import {attachPatchData} from './context_discovery';
|
||||
import {getComponentDef} from './definition';
|
||||
import {getComponentDef} from './def_getters';
|
||||
import {depsTracker} from './deps_tracker/deps_tracker';
|
||||
import {getNodeInjectable, NodeInjector} from './di';
|
||||
import {registerPostOrderHooks} from './hooks';
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import {EnvironmentInjector} from '../../di/r3_injector';
|
|||
import {Type} from '../../interface/type';
|
||||
import {assertDefined, throwError} from '../../util/assert';
|
||||
import {assertTNode, assertTNodeForLView} from '../assert';
|
||||
import {getComponentDef} from '../definition';
|
||||
import {getComponentDef} from '../def_getters';
|
||||
import {getNodeInjectorLView, getNodeInjectorTNode, NodeInjector} from '../di';
|
||||
import {TNode} from '../interfaces/node';
|
||||
import {LView} from '../interfaces/view';
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import {Type} from '../../interface/type';
|
||||
import {getComponentDef} from '../definition';
|
||||
import {getComponentDef} from '../def_getters';
|
||||
import {ClassDebugInfo} from '../interfaces/definition';
|
||||
|
||||
/**
|
||||
|
|
|
|||
55
packages/core/src/render3/def_getters.ts
Normal file
55
packages/core/src/render3/def_getters.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {Type} from '../interface/type';
|
||||
import type {NgModuleDef} from '../r3_symbols';
|
||||
import {stringify} from '../util/stringify';
|
||||
import {NG_COMP_DEF, NG_DIR_DEF, NG_MOD_DEF, NG_PIPE_DEF} from './fields';
|
||||
import type {ComponentDef, DirectiveDef, PipeDef} from './interfaces/definition';
|
||||
|
||||
export function getNgModuleDef<T>(type: any, throwNotFound: true): NgModuleDef<T>;
|
||||
export function getNgModuleDef<T>(type: any): NgModuleDef<T> | null;
|
||||
export function getNgModuleDef<T>(type: any, throwNotFound?: boolean): NgModuleDef<T> | null {
|
||||
const ngModuleDef = type[NG_MOD_DEF] || null;
|
||||
if (!ngModuleDef && throwNotFound === true) {
|
||||
throw new Error(`Type ${stringify(type)} does not have 'ɵmod' property.`);
|
||||
}
|
||||
return ngModuleDef;
|
||||
}
|
||||
|
||||
/**
|
||||
* The following getter methods retrieve the definition from the type. Currently the retrieval
|
||||
* honors inheritance, but in the future we may change the rule to require that definitions are
|
||||
* explicit. This would require some sort of migration strategy.
|
||||
*/
|
||||
|
||||
export function getComponentDef<T>(type: any): ComponentDef<T> | null {
|
||||
return type[NG_COMP_DEF] || null;
|
||||
}
|
||||
|
||||
export function getDirectiveDef<T>(type: any): DirectiveDef<T> | null {
|
||||
return type[NG_DIR_DEF] || null;
|
||||
}
|
||||
|
||||
export function getPipeDef<T>(type: any): PipeDef<T> | null {
|
||||
return type[NG_PIPE_DEF] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given Component, Directive or Pipe is marked as standalone.
|
||||
* This will return false if passed anything other than a Component, Directive, or Pipe class
|
||||
* See [this guide](guide/components/importing) for additional information:
|
||||
*
|
||||
* @param type A reference to a Component, Directive or Pipe.
|
||||
* @publicApi
|
||||
*/
|
||||
export function isStandalone(type: Type<unknown>): boolean {
|
||||
const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
|
||||
// TODO: standalone as default value (invert the condition)
|
||||
return def !== null ? def.standalone : false;
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||
import {EnvironmentInjector} from '../di/r3_injector';
|
||||
import {formatRuntimeError, RuntimeErrorCode} from '../errors';
|
||||
import {Type, Writable} from '../interface/type';
|
||||
import {NgModuleDef} from '../metadata/ng_module_def';
|
||||
|
|
@ -15,9 +16,9 @@ import {ViewEncapsulation} from '../metadata/view';
|
|||
import {noSideEffects} from '../util/closure';
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../util/empty';
|
||||
import {initNgDevMode} from '../util/ng_dev_mode';
|
||||
import {stringify} from '../util/stringify';
|
||||
import {performanceMarkFeature} from '../util/performance';
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef} from './def_getters';
|
||||
|
||||
import {NG_COMP_DEF, NG_DIR_DEF, NG_MOD_DEF, NG_PIPE_DEF} from './fields';
|
||||
import type {
|
||||
ComponentDef,
|
||||
ComponentDefFeature,
|
||||
|
|
@ -39,6 +40,7 @@ import type {TAttributes, TConstantsOrFactory} from './interfaces/node';
|
|||
import {CssSelectorList} from './interfaces/projection';
|
||||
import {stringifyCSSSelectorList} from './node_selector_matcher';
|
||||
import {NG_STANDALONE_DEFAULT_VALUE} from './standalone-default-value';
|
||||
import {StandaloneService} from './standalone_service';
|
||||
|
||||
/**
|
||||
* Map of inputs for a given directive/component.
|
||||
|
|
@ -357,7 +359,11 @@ export function ɵɵdefineComponent<T>(
|
|||
directiveDefs: null!, // assigned in noSideEffects
|
||||
pipeDefs: null!, // assigned in noSideEffects
|
||||
dependencies: (baseDef.standalone && componentDefinition.dependencies) || null,
|
||||
getStandaloneInjector: null,
|
||||
getStandaloneInjector: baseDef.standalone
|
||||
? (parentInjector: EnvironmentInjector) => {
|
||||
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(def);
|
||||
}
|
||||
: null,
|
||||
getExternalStyles: null,
|
||||
signals: componentDefinition.signals ?? false,
|
||||
data: componentDefinition.data || {},
|
||||
|
|
@ -369,6 +375,11 @@ export function ɵɵdefineComponent<T>(
|
|||
id: '',
|
||||
};
|
||||
|
||||
// TODO: Do we still need/want this ?
|
||||
if (baseDef.standalone) {
|
||||
performanceMarkFeature('NgStandalone');
|
||||
}
|
||||
|
||||
initFeatures(def);
|
||||
const dependencies = componentDefinition.dependencies;
|
||||
def.directiveDefs = extractDefListOrFactory(dependencies, /* pipeDef */ false);
|
||||
|
|
@ -609,47 +620,6 @@ export function ɵɵdefinePipe<T>(pipeDef: {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The following getter methods retrieve the definition from the type. Currently the retrieval
|
||||
* honors inheritance, but in the future we may change the rule to require that definitions are
|
||||
* explicit. This would require some sort of migration strategy.
|
||||
*/
|
||||
|
||||
export function getComponentDef<T>(type: any): ComponentDef<T> | null {
|
||||
return type[NG_COMP_DEF] || null;
|
||||
}
|
||||
|
||||
export function getDirectiveDef<T>(type: any): DirectiveDef<T> | null {
|
||||
return type[NG_DIR_DEF] || null;
|
||||
}
|
||||
|
||||
export function getPipeDef<T>(type: any): PipeDef<T> | null {
|
||||
return type[NG_PIPE_DEF] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given Component, Directive or Pipe is marked as standalone.
|
||||
* This will return false if passed anything other than a Component, Directive, or Pipe class
|
||||
* See [this guide](guide/components/importing) for additional information:
|
||||
*
|
||||
* @param type A reference to a Component, Directive or Pipe.
|
||||
* @publicApi
|
||||
*/
|
||||
export function isStandalone(type: Type<unknown>): boolean {
|
||||
const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
|
||||
return def !== null ? def.standalone : false;
|
||||
}
|
||||
|
||||
export function getNgModuleDef<T>(type: any, throwNotFound: true): NgModuleDef<T>;
|
||||
export function getNgModuleDef<T>(type: any): NgModuleDef<T> | null;
|
||||
export function getNgModuleDef<T>(type: any, throwNotFound?: boolean): NgModuleDef<T> | null {
|
||||
const ngModuleDef = type[NG_MOD_DEF] || null;
|
||||
if (!ngModuleDef && throwNotFound === true) {
|
||||
throw new Error(`Type ${stringify(type)} does not have 'ɵmod' property.`);
|
||||
}
|
||||
return ngModuleDef;
|
||||
}
|
||||
|
||||
function getNgDirectiveDef<T>(directiveDefinition: DirectiveDefinition<T>): DirectiveDef<T> {
|
||||
const declaredInputs: Record<string, string> = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ import {RuntimeError, RuntimeErrorCode} from '../../errors';
|
|||
import {Type} from '../../interface/type';
|
||||
import {NgModuleType} from '../../metadata/ng_module_def';
|
||||
import {flatten} from '../../util/array_utils';
|
||||
import {getComponentDef, getNgModuleDef, isStandalone} from '../definition';
|
||||
import {
|
||||
import type {
|
||||
ComponentType,
|
||||
NgModuleScopeInfoFromDecorator,
|
||||
RawScopeInfoFromDecorator,
|
||||
} from '../interfaces/definition';
|
||||
import {isComponent, isDirective, isNgModule, isPipe, verifyStandaloneImport} from '../jit/util';
|
||||
import {getComponentDef, getNgModuleDef, isStandalone} from '../def_getters';
|
||||
import {maybeUnwrapFn} from '../util/misc_utils';
|
||||
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
import {RuntimeError, RuntimeErrorCode} from '../errors';
|
||||
import {Type} from '../interface/type';
|
||||
|
||||
import {getComponentDef} from './definition';
|
||||
import {getComponentDef} from './def_getters';
|
||||
import {getDeclarationComponentDef} from './instructions/element_validation';
|
||||
import {TNode} from './interfaces/node';
|
||||
import {LView, TVIEW} from './interfaces/view';
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {RuntimeError, RuntimeErrorCode} from '../../errors';
|
|||
import {Type} from '../../interface/type';
|
||||
import {assertEqual} from '../../util/assert';
|
||||
import {EMPTY_OBJ} from '../../util/empty';
|
||||
import {getComponentDef, getDirectiveDef} from '../definition';
|
||||
import {getComponentDef, getDirectiveDef} from '../def_getters';
|
||||
import {
|
||||
DirectiveDef,
|
||||
DirectiveDefFeature,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,8 @@
|
|||
import {Type} from '../interface/type';
|
||||
import {assertDefined} from '../util/assert';
|
||||
import {assertLView} from './assert';
|
||||
import {
|
||||
getComponentDef,
|
||||
ɵɵdefineComponent,
|
||||
ɵɵdefineDirective,
|
||||
ɵɵdefineNgModule,
|
||||
ɵɵdefinePipe,
|
||||
} from './definition';
|
||||
import {ɵɵdefineComponent, ɵɵdefineDirective, ɵɵdefineNgModule, ɵɵdefinePipe} from './definition';
|
||||
import {getComponentDef} from './def_getters';
|
||||
import {assertComponentDef} from './errors';
|
||||
import {refreshView} from './instructions/change_detection';
|
||||
import {renderView} from './instructions/render';
|
||||
|
|
@ -83,7 +78,6 @@ import {ɵɵProvidersFeature} from './features/providers_feature';
|
|||
import {ɵɵCopyDefinitionFeature} from './features/copy_definition_feature';
|
||||
import {ɵɵInheritDefinitionFeature} from './features/inherit_definition_feature';
|
||||
import {ɵɵInputTransformsFeature} from './features/input_transforms_feature';
|
||||
import {ɵɵStandaloneFeature} from './features/standalone_feature';
|
||||
import {ɵɵExternalStylesFeature} from './features/external_styles_feature';
|
||||
import {ɵɵresolveBody, ɵɵresolveDocument, ɵɵresolveWindow} from './util/misc_utils';
|
||||
import {ɵsetClassDebugInfo} from './debug/set_debug_info';
|
||||
|
|
@ -325,7 +319,6 @@ function getHmrEnv(): Record<string, unknown> {
|
|||
'ɵɵCopyDefinitionFeature': ɵɵCopyDefinitionFeature,
|
||||
'ɵɵInheritDefinitionFeature': ɵɵInheritDefinitionFeature,
|
||||
'ɵɵInputTransformsFeature': ɵɵInputTransformsFeature,
|
||||
'ɵɵStandaloneFeature': ɵɵStandaloneFeature,
|
||||
'ɵɵExternalStylesFeature': ɵɵExternalStylesFeature,
|
||||
'ɵɵnextContext': r3.ɵɵnextContext,
|
||||
'ɵɵnamespaceHTML': r3.ɵɵnamespaceHTML,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import {ɵɵInheritDefinitionFeature} from './features/inherit_definition_featur
|
|||
import {ɵɵInputTransformsFeature} from './features/input_transforms_feature';
|
||||
import {ɵɵNgOnChangesFeature} from './features/ng_onchanges_feature';
|
||||
import {ɵɵProvidersFeature} from './features/providers_feature';
|
||||
import {ɵɵStandaloneFeature} from './features/standalone_feature';
|
||||
import {ɵɵExternalStylesFeature} from './features/external_styles_feature';
|
||||
import {
|
||||
ComponentDef,
|
||||
|
|
@ -255,6 +254,5 @@ export {
|
|||
ɵɵProvidersFeature,
|
||||
ɵɵsetComponentScope,
|
||||
ɵɵsetNgModuleScope,
|
||||
ɵɵStandaloneFeature,
|
||||
ɵɵExternalStylesFeature,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {formatRuntimeError, RuntimeError, RuntimeErrorCode} from '../../errors';
|
|||
import {Type} from '../../interface/type';
|
||||
import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SchemaMetadata} from '../../metadata/schema';
|
||||
import {throwError} from '../../util/assert';
|
||||
import {getComponentDef} from '../definition';
|
||||
import {getComponentDef} from '../def_getters';
|
||||
import {ComponentDef} from '../interfaces/definition';
|
||||
import {TNodeType} from '../interfaces/node';
|
||||
import {RComment, RElement} from '../interfaces/renderer_dom';
|
||||
|
|
|
|||
|
|
@ -393,8 +393,7 @@ export interface ComponentDef<T> extends DirectiveDef<T> {
|
|||
tView: TView | null;
|
||||
|
||||
/**
|
||||
* A function added by the {@link ɵɵStandaloneFeature} and used by the framework to create
|
||||
* standalone injectors.
|
||||
* A function used by the framework to create standalone injectors.
|
||||
*/
|
||||
getStandaloneInjector:
|
||||
| ((parentInjector: EnvironmentInjector) => EnvironmentInjector | null)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import {ViewEncapsulation} from '../../metadata/view';
|
|||
import {flatten} from '../../util/array_utils';
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from '../../util/empty';
|
||||
import {initNgDevMode} from '../../util/ng_dev_mode';
|
||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../def_getters';
|
||||
import {depsTracker, USE_RUNTIME_DEPS_TRACKER_FOR_JIT} from '../deps_tracker/deps_tracker';
|
||||
import {NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF} from '../fields';
|
||||
import {ComponentDef, ComponentType, DirectiveDefList, PipeDefList} from '../interfaces/definition';
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ export const angularCoreEnv: {[name: string]: unknown} = (() => ({
|
|||
'ɵɵCopyDefinitionFeature': r3.ɵɵCopyDefinitionFeature,
|
||||
'ɵɵInheritDefinitionFeature': r3.ɵɵInheritDefinitionFeature,
|
||||
'ɵɵInputTransformsFeature': r3.ɵɵInputTransformsFeature,
|
||||
'ɵɵStandaloneFeature': r3.ɵɵStandaloneFeature,
|
||||
'ɵɵExternalStylesFeature': r3.ɵɵExternalStylesFeature,
|
||||
'ɵɵnextContext': r3.ɵɵnextContext,
|
||||
'ɵɵnamespaceHTML': r3.ɵɵnamespaceHTML,
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ import {NgModuleDef, NgModuleTransitiveScopes, NgModuleType} from '../../metadat
|
|||
import {deepForEach, flatten} from '../../util/array_utils';
|
||||
import {assertDefined} from '../../util/assert';
|
||||
import {EMPTY_ARRAY} from '../../util/empty';
|
||||
import {GENERATED_COMP_IDS} from '../definition';
|
||||
import {
|
||||
GENERATED_COMP_IDS,
|
||||
getComponentDef,
|
||||
getDirectiveDef,
|
||||
getNgModuleDef,
|
||||
getPipeDef,
|
||||
isStandalone,
|
||||
} from '../definition';
|
||||
} from '../def_getters';
|
||||
import {depsTracker, USE_RUNTIME_DEPS_TRACKER_FOR_JIT} from '../deps_tracker/deps_tracker';
|
||||
import {NG_COMP_DEF, NG_DIR_DEF, NG_FACTORY_DEF, NG_MOD_DEF, NG_PIPE_DEF} from '../fields';
|
||||
import {ComponentDef} from '../interfaces/definition';
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import {isForwardRef, resolveForwardRef} from '../../di/forward_ref';
|
|||
import {ModuleWithProviders} from '../../di/interface/provider';
|
||||
import {Type} from '../../interface/type';
|
||||
import {NgModuleDef} from '../../metadata/ng_module_def';
|
||||
import {getComponentDef, getDirectiveDef, getNgModuleDef, getPipeDef} from '../definition';
|
||||
import {ComponentType, DirectiveType, PipeType} from '../interfaces/definition';
|
||||
import {getComponentDef, getDirectiveDef, getPipeDef, getNgModuleDef} from '../def_getters';
|
||||
import type {ComponentType, DirectiveType, PipeType} from '../interfaces/definition';
|
||||
import {stringifyForError} from '../util/stringify_utils';
|
||||
|
||||
export function isModuleWithProviders(value: any): value is ModuleWithProviders<{}> {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import {assertDefined} from '../util/assert';
|
|||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {ComponentFactoryResolver} from './component_ref';
|
||||
import {getNgModuleDef} from './definition';
|
||||
import {getNgModuleDef} from './def_getters';
|
||||
import {maybeUnwrapFn} from './util/misc_utils';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ import {Type} from '../interface/type';
|
|||
import {flatten} from '../util/array_utils';
|
||||
import {noSideEffects} from '../util/closure';
|
||||
import {EMPTY_ARRAY} from '../util/empty';
|
||||
import {getNgModuleDef} from './def_getters';
|
||||
|
||||
import {extractDefListOrFactory, getNgModuleDef} from './definition';
|
||||
import {extractDefListOrFactory} from './definition';
|
||||
import {depsTracker} from './deps_tracker/deps_tracker';
|
||||
import {
|
||||
ComponentDef,
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@
|
|||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
import {ɵɵinject as inject} from '../../di/injector_compatibility';
|
||||
import {ɵɵdefineInjectable as defineInjectable} from '../../di/interface/defs';
|
||||
import {internalImportProvidersFrom} from '../../di/provider_collection';
|
||||
import {EnvironmentInjector} from '../../di/r3_injector';
|
||||
import {OnDestroy} from '../../interface/lifecycle_hooks';
|
||||
import {performanceMarkFeature} from '../../util/performance';
|
||||
import {ComponentDef} from '../interfaces/definition';
|
||||
import {createEnvironmentInjector} from '../ng_module_ref';
|
||||
import {ɵɵinject as inject} from '../di/injector_compatibility';
|
||||
import {ɵɵdefineInjectable as defineInjectable} from '../di/interface/defs';
|
||||
import {internalImportProvidersFrom} from '../di/provider_collection';
|
||||
import {EnvironmentInjector} from '../di/r3_injector';
|
||||
import {OnDestroy} from '../interface/lifecycle_hooks';
|
||||
import {ComponentDef} from './interfaces/definition';
|
||||
import {createEnvironmentInjector} from './ng_module_ref';
|
||||
|
||||
/**
|
||||
* A service used by the framework to create instances of standalone injectors. Those injectors are
|
||||
* created on demand in case of dynamic component instantiation and contain ambient providers
|
||||
* collected from the imports graph rooted at a given standalone component.
|
||||
*/
|
||||
class StandaloneService implements OnDestroy {
|
||||
export class StandaloneService implements OnDestroy {
|
||||
cachedInjectors = new Map<ComponentDef<unknown>, EnvironmentInjector | null>();
|
||||
|
||||
constructor(private _injector: EnvironmentInjector) {}
|
||||
|
|
@ -64,20 +63,3 @@ class StandaloneService implements OnDestroy {
|
|||
factory: () => new StandaloneService(inject(EnvironmentInjector)),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A feature that acts as a setup code for the {@link StandaloneService}.
|
||||
*
|
||||
* The most important responsibility of this feature is to expose the "getStandaloneInjector"
|
||||
* function (an entry points to a standalone injector creation) on a component definition object. We
|
||||
* go through the features infrastructure to make sure that the standalone injector creation logic
|
||||
* is tree-shakable and not included in applications that don't use standalone components.
|
||||
*
|
||||
* @codeGenApi
|
||||
*/
|
||||
export function ɵɵStandaloneFeature(definition: ComponentDef<unknown>) {
|
||||
performanceMarkFeature('NgStandalone');
|
||||
definition.getStandaloneInjector = (parentInjector: EnvironmentInjector) => {
|
||||
return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(definition);
|
||||
};
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ import {
|
|||
getLContext,
|
||||
readPatchedLView,
|
||||
} from '../context_discovery';
|
||||
import {getComponentDef, getDirectiveDef} from '../definition';
|
||||
import {getComponentDef, getDirectiveDef} from '../def_getters';
|
||||
import {NodeInjector} from '../di';
|
||||
import {DirectiveDef} from '../interfaces/definition';
|
||||
import {TElementNode, TNode, TNodeProviderIndexes} from '../interfaces/node';
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import {assertTNode, assertTNodeForLView} from '../assert';
|
|||
import {ChainedInjector} from '../chained_injector';
|
||||
import {getFrameworkDIDebugData} from '../debug/framework_injector_profiler';
|
||||
import {InjectedService, ProviderRecord} from '../debug/injector_profiler';
|
||||
import {getComponentDef} from '../definition';
|
||||
import {getComponentDef} from '../def_getters';
|
||||
import {
|
||||
getNodeInjectorLView,
|
||||
getNodeInjectorTNode,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import {
|
|||
ElementRef,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import {getComponentDef} from '@angular/core/src/render3/definition';
|
||||
import {getComponentDef} from '@angular/core/src/render3/def_getters';
|
||||
import {
|
||||
ComponentFixture,
|
||||
DeferBlockBehavior,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import {
|
|||
QueryList,
|
||||
ViewChildren,
|
||||
} from '@angular/core';
|
||||
import {getDirectiveDef} from '@angular/core/src/render3/definition';
|
||||
import {getDirectiveDef} from '@angular/core/src/render3/def_getters';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
ɵɵsetNgModuleScope,
|
||||
} from '@angular/core';
|
||||
import {ComponentType} from '@angular/core/src/render3';
|
||||
import {getNgModuleDef} from '@angular/core/src/render3/definition';
|
||||
import {getNgModuleDef} from '@angular/core/src/render3/def_getters';
|
||||
|
||||
describe('component dependencies in local compilation', () => {
|
||||
it('should compute correct set of dependencies when importing ng-modules directly', () => {
|
||||
|
|
|
|||
|
|
@ -1526,9 +1526,6 @@
|
|||
{
|
||||
"name": "writeToDirectiveInput"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵStandaloneFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵdefineComponent"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -257,6 +257,9 @@
|
|||
{
|
||||
"name": "EnvironmentInjector"
|
||||
},
|
||||
{
|
||||
"name": "EnvironmentNgModuleRefAdapter"
|
||||
},
|
||||
{
|
||||
"name": "ErrorHandler"
|
||||
},
|
||||
|
|
@ -530,6 +533,9 @@
|
|||
{
|
||||
"name": "SpecialCasedStyles"
|
||||
},
|
||||
{
|
||||
"name": "StandaloneService"
|
||||
},
|
||||
{
|
||||
"name": "StateValue"
|
||||
},
|
||||
|
|
@ -1325,6 +1331,9 @@
|
|||
{
|
||||
"name": "markViewForRefresh"
|
||||
},
|
||||
{
|
||||
"name": "markedFeatures"
|
||||
},
|
||||
{
|
||||
"name": "maybeWrapInNotSelector"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -164,6 +164,9 @@
|
|||
{
|
||||
"name": "EnvironmentInjector"
|
||||
},
|
||||
{
|
||||
"name": "EnvironmentNgModuleRefAdapter"
|
||||
},
|
||||
{
|
||||
"name": "ErrorHandler"
|
||||
},
|
||||
|
|
@ -404,6 +407,9 @@
|
|||
{
|
||||
"name": "SimpleChange"
|
||||
},
|
||||
{
|
||||
"name": "StandaloneService"
|
||||
},
|
||||
{
|
||||
"name": "Subject"
|
||||
},
|
||||
|
|
@ -1067,6 +1073,9 @@
|
|||
{
|
||||
"name": "markViewForRefresh"
|
||||
},
|
||||
{
|
||||
"name": "markedFeatures"
|
||||
},
|
||||
{
|
||||
"name": "maybeWrapInNotSelector"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1340,6 +1340,9 @@
|
|||
{
|
||||
"name": "init_decorators"
|
||||
},
|
||||
{
|
||||
"name": "init_def_getters"
|
||||
},
|
||||
{
|
||||
"name": "init_default_iterable_differ"
|
||||
},
|
||||
|
|
@ -2040,7 +2043,7 @@
|
|||
"name": "init_standalone_default_value"
|
||||
},
|
||||
{
|
||||
"name": "init_standalone_feature"
|
||||
"name": "init_standalone_service"
|
||||
},
|
||||
{
|
||||
"name": "init_state"
|
||||
|
|
@ -2627,9 +2630,6 @@
|
|||
{
|
||||
"name": "ɵɵNgOnChangesFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵStandaloneFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵdefer"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -224,6 +224,9 @@
|
|||
{
|
||||
"name": "EnvironmentInjector"
|
||||
},
|
||||
{
|
||||
"name": "EnvironmentNgModuleRefAdapter"
|
||||
},
|
||||
{
|
||||
"name": "ErrorHandler"
|
||||
},
|
||||
|
|
@ -569,6 +572,9 @@
|
|||
{
|
||||
"name": "SkipSelf"
|
||||
},
|
||||
{
|
||||
"name": "StandaloneService"
|
||||
},
|
||||
{
|
||||
"name": "StatusChangeEvent"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -227,6 +227,9 @@
|
|||
{
|
||||
"name": "EnvironmentInjector"
|
||||
},
|
||||
{
|
||||
"name": "EnvironmentNgModuleRefAdapter"
|
||||
},
|
||||
{
|
||||
"name": "ErrorHandler"
|
||||
},
|
||||
|
|
@ -551,6 +554,9 @@
|
|||
{
|
||||
"name": "SkipSelf"
|
||||
},
|
||||
{
|
||||
"name": "StandaloneService"
|
||||
},
|
||||
{
|
||||
"name": "StatusChangeEvent"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1442,9 +1442,6 @@
|
|||
{
|
||||
"name": "writeToDirectiveInput"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵStandaloneFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵdefineComponent"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2240,9 +2240,6 @@
|
|||
{
|
||||
"name": "ɵɵNgOnChangesFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵStandaloneFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵattribute"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1145,9 +1145,6 @@
|
|||
{
|
||||
"name": "writeToDirectiveInput"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵStandaloneFeature"
|
||||
},
|
||||
{
|
||||
"name": "ɵɵdefineComponent"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@
|
|||
{
|
||||
"name": "EnvironmentInjector"
|
||||
},
|
||||
{
|
||||
"name": "EnvironmentNgModuleRefAdapter"
|
||||
},
|
||||
{
|
||||
"name": "ErrorHandler"
|
||||
},
|
||||
|
|
@ -437,6 +440,9 @@
|
|||
{
|
||||
"name": "SkipSelf"
|
||||
},
|
||||
{
|
||||
"name": "StandaloneService"
|
||||
},
|
||||
{
|
||||
"name": "Subject"
|
||||
},
|
||||
|
|
@ -1277,6 +1283,9 @@
|
|||
{
|
||||
"name": "markViewForRefresh"
|
||||
},
|
||||
{
|
||||
"name": "markedFeatures"
|
||||
},
|
||||
{
|
||||
"name": "maybeWrapInNotSelector"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {
|
|||
} from '@angular/core';
|
||||
import {ɵɵdefineInjectable} from '@angular/core/src/di/interface/defs';
|
||||
import {NgModuleType} from '@angular/core/src/render3';
|
||||
import {getNgModuleDef} from '@angular/core/src/render3/definition';
|
||||
import {getNgModuleDef} from '@angular/core/src/render3/def_getters';
|
||||
import {ComponentFixture, inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {InternalNgModuleRef, NgModuleFactory} from '../../src/linker/ng_module_factory';
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
import {DOCUMENT} from '@angular/common';
|
||||
import {ApplicationRef, PLATFORM_ID, Provider, Type, ɵsetDocument} from '@angular/core';
|
||||
import {CLIENT_RENDER_MODE_FLAG} from '@angular/core/src/hydration/api';
|
||||
import {getComponentDef} from '@angular/core/src/render3/definition';
|
||||
import {getComponentDef} from '@angular/core/src/render3/def_getters';
|
||||
import {
|
||||
bootstrapApplication,
|
||||
HydrationFeature,
|
||||
|
|
|
|||
Loading…
Reference in a new issue