Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@schematics/angular): Implement a standalone flag for new applications #24848

Merged
merged 1 commit into from Mar 21, 2023

Conversation

Brocco
Copy link
Contributor

@Brocco Brocco commented Mar 13, 2023

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

The ability to create an application without the use of NgModules does not exist.

Issue Number: #23976

What is the new behavior?

The flag --standalone is added to both the ng new command as well as ng generate application schematic.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Mar 13, 2023
Copy link

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

@Brocco great work, thanks! 👍 Just left a few minor comments.

@alan-agius4 alan-agius4 linked an issue Mar 13, 2023 that may be closed by this pull request
@Brocco Brocco marked this pull request as ready for review March 14, 2023 20:17
@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Mar 15, 2023
@alan-agius4 alan-agius4 self-requested a review March 15, 2023 11:39
@@ -0,0 +1,14 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Most of the files in module-file and standalone-files are the same 6 out of the 8 files. Can we have these into a separate directory and re-use it instead of have them multiple times?

My concern here is that certain files should always be the same irrespective if users select standalone and not. But we already started diverging example the index.html file is not identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Combined most of the files to a set of common directories, but kept a few separate in order to not overly complicate the internal logic.

packages/schematics/angular/application/index_spec.ts Outdated Show resolved Hide resolved
packages/schematics/angular/application/index_spec.ts Outdated Show resolved Hide resolved
packages/schematics/angular/application/index_spec.ts Outdated Show resolved Hide resolved
packages/schematics/angular/application/util.ts Outdated Show resolved Hide resolved
@eneajaho
Copy link
Contributor

eneajaho commented Mar 15, 2023

Hello, this is great 🔥

I have a question, isn't it better to have the config directly in the main.ts file?

bootstrapApplication(AppComponent, {
  providers: [
    provideRouter()
  ]
})

This way we don't need another file like app.config.ts. One less file to explain.

I understand that app.config.ts imitates AppModule's model and is easier for devs to connect the dots with the newer version, but isn't it better if this separation is done by devs themselves?

Things like router or http client or animations, are setup only once, and changed very little during development, that's why I think it's better to have them in one file in main.ts.

EDIT: Also, that's the default behavior of the migration schematic, put providers in the main.ts file.

@Brocco Brocco force-pushed the standalone branch 2 times, most recently from 145214d to 693857a Compare March 20, 2023 21:08
@Brocco
Copy link
Contributor Author

Brocco commented Mar 21, 2023

@eneajaho the decision to put these dependencies in app.config (or app.routes) is to keep them closer to the application in the app directory. This location parallels the location of app.module. Also by keeping it outside of main.ts for the browser will allow the same configuration to be used for apps taking advantage of universal which creates a main.server.ts file.

Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

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

I believe that we can still simply the schematic greatly. But let's do that in a followup to unblock the other schematics.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 21, 2023
@angular-robot angular-robot bot merged commit a832c20 into angular:main Mar 21, 2023
@Brocco Brocco deleted the standalone branch March 24, 2023 01:10
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 24, 2023
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 detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add --standalone option to ng new
6 participants