Skip to content

Commit 6b8c494

Browse files
JeanMechedevversion
authored andcommitted
feat(core): flipping the default value for standalone to true (#58169)
With this commit directives, components & pipes are standalone by default. To be declared in an `NgModule`, those require now `standalone: false`. PR Close #58169
1 parent bf9fd31 commit 6b8c494

File tree

5 files changed

+6
-2
lines changed

5 files changed

+6
-2
lines changed

packages/compiler-cli/src/ngtsc/annotations/common/src/standalone-default-value.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* A constant defining the default value for the standalone attribute in Directive and Pipes decorators.
1111
* Extracted to a separate file to facilitate G3 patches.
1212
*/
13-
export const NG_STANDALONE_DEFAULT_VALUE = false;
13+
export const NG_STANDALONE_DEFAULT_VALUE = true;

packages/compiler/src/render3/partial/directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export function createDirectiveDefinitionMap(
5454
// e.g. `type: MyDirective`
5555
definitionMap.set('type', meta.type.value);
5656

57+
// TODO: standalone as default value (invert the condition)
5758
if (meta.isStandalone) {
5859
definitionMap.set('isStandalone', o.literal(meta.isStandalone));
5960
}

packages/compiler/src/render3/r3_pipe_compiler.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function compilePipeFromMetadata(metadata: R3PipeMetadata): R3CompiledExp
6060
// e.g. `pure: true`
6161
definitionMapValues.push({key: 'pure', value: o.literal(metadata.pure), quoted: false});
6262

63+
// TODO: standalone as default value (invert the condition)
6364
if (metadata.isStandalone) {
6465
definitionMapValues.push({key: 'standalone', value: o.literal(true), quoted: false});
6566
}

packages/core/src/render3/definition.ts

+2
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ export function getPipeDef<T>(type: any): PipeDef<T> | null {
636636
*/
637637
export function isStandalone(type: Type<unknown>): boolean {
638638
const def = getComponentDef(type) || getDirectiveDef(type) || getPipeDef(type);
639+
// TODO: standalone as default value (invert the condition)
639640
return def !== null ? def.standalone : false;
640641
}
641642

@@ -664,6 +665,7 @@ function getNgDirectiveDef<T>(directiveDefinition: DirectiveDefinition<T>): Dire
664665
inputTransforms: null,
665666
inputConfig: directiveDefinition.inputs || EMPTY_OBJ,
666667
exportAs: directiveDefinition.exportAs || null,
668+
// TODO: standalone as default value (invert the condition)
667669
standalone: directiveDefinition.standalone === true,
668670
signals: directiveDefinition.signals === true,
669671
selectors: directiveDefinition.selectors || EMPTY_ARRAY,

packages/core/src/render3/standalone-default-value.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* A constant defining the default value for the standalone attribute in Directive and Pipes decorators.
1111
* Extracted to a separate file to facilitate G3 patches.
1212
*/
13-
export const NG_STANDALONE_DEFAULT_VALUE = false;
13+
export const NG_STANDALONE_DEFAULT_VALUE = true;

0 commit comments

Comments
 (0)