Skip to content

feat(compiler-cli): Adapt the compiler to use standalone by default. #58169

Closed
JeanMeche wants to merge 9 commits intoangular:mainfrom
JeanMeche:feat/standalone-standalone-compiler
Closed

feat(compiler-cli): Adapt the compiler to use standalone by default. #58169
JeanMeche wants to merge 9 commits intoangular:mainfrom
JeanMeche:feat/standalone-standalone-compiler

Conversation

@JeanMeche
Copy link
Copy Markdown
Member

@JeanMeche JeanMeche commented Oct 11, 2024

On top of #58160 & #58175

This PR flips the default for standalone from false to true for components, directives and pipes.
This PR also includes the necessary changes for the impacted tests as well as other targets that dependens on them (adev, benchmarks etc).

@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit area: build & ci Related the build and CI infrastructure of the project area: core Issues related to the framework runtime area: docs-infra Angular.dev application and infrastructure labels Oct 11, 2024
@ngbot ngbot bot added this to the Backlog milestone Oct 11, 2024
@angular-robot angular-robot bot added area: devtools area: language-service Issues related to Angular's VS Code language service area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 11, 2024
@JeanMeche JeanMeche added state: blocked target: major This PR is targeted for the next major release labels Oct 11, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime area: compiler Issues related to `ngc`, Angular's template compiler area: migrations Issues related to `ng update`/`ng generate` migrations and removed area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Oct 11, 2024
@JeanMeche JeanMeche force-pushed the feat/standalone-standalone-compiler branch from 480c7f9 to 408084f Compare October 11, 2024 15:02
@angular-robot angular-robot bot added area: core Issues related to the framework runtime area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Oct 11, 2024
@JeanMeche JeanMeche force-pushed the feat/standalone-standalone-compiler branch from 408084f to 5c327a2 Compare October 11, 2024 15:10
@angular-robot angular-robot bot removed the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 11, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime area: compiler Issues related to `ngc`, Angular's template compiler and removed area: core Issues related to the framework runtime labels Oct 12, 2024
@JeanMeche JeanMeche force-pushed the feat/standalone-standalone-compiler branch from 4c1af50 to 2d8b834 Compare October 12, 2024 11:45
@angular-robot angular-robot bot added area: core Issues related to the framework runtime area: compiler Issues related to `ngc`, Angular's template compiler and removed area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Oct 12, 2024
@JeanMeche JeanMeche marked this pull request as draft October 12, 2024 11:46
@JeanMeche JeanMeche force-pushed the feat/standalone-standalone-compiler branch from 2d8b834 to d225472 Compare October 12, 2024 11:47
@angular-robot angular-robot bot removed the area: compiler Issues related to `ngc`, Angular's template compiler label Oct 12, 2024
JeanMeche and others added 6 commits October 14, 2024 10:02
With this commit directives, components & pipes are standalone by default.

To be declared in an `NgModule`, those require now `standalone: false`.
Use `semver` in the partial compiler to decide on a default value

Co-authored-by: Alex Rickabaugh <alxhub@users.noreply.github.com>
`UpgradeComponent` is meant to be used as a subclass, it doesn't need to disable `standalone`.
After flipping the standalone default value, this is reflected in the partial output result.
… default

This commit is part of the migration to standalone by default.
With this commit, the standalone migration will only migrate code with `standalone: false` to standalone by default (without the standalone attribute)
);
}

const STANDALONE_IS_DEFAULT_RANGE = new semver.Range('>= 19.0.0', {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure that 0.0.0-PLACEHOLDER is also considered to pass.

}

const SINGLE_DIGIT_VERSIONS = /^\d\./;
const V11_V18 = /1[12345678]\./;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could probably combine this into a single Regex. e.g. V1_TO_18 = ^([1-9]|1[0-8])\.

@JeanMeche
Copy link
Copy Markdown
Member Author

JeanMeche commented Oct 15, 2024

This change has currently an issue in our compliance tests.
Tests that rely on explicit standalone: false aren't compiled correctly by the linked target.

Edit: fixed

Copy link
Copy Markdown
Contributor

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Reviewed-for: global-approvers

@jelbourn
Copy link
Copy Markdown
Contributor

Caretaker note: presubmit failure looks like a flake to me; I ran a TGP for these changes yesterday and it was green

@devversion
Copy link
Copy Markdown
Member

This PR was merged into the repository by commit 9ab663e.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime area: devtools area: docs-infra Angular.dev application and infrastructure area: language-service Issues related to Angular's VS Code language service area: migrations Issues related to `ng update`/`ng generate` migrations area: upgrade Issues related to AngularJS → Angular upgrade APIs detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants