-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix(angular): ng add @ionic/angular in standalone projects #28523
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Let me know if you have any questions on how to review. I can run through creating a new angular project, testing the schematic and looking at the diffs 👍 |
@@ -61,8 +61,8 @@ | |||
"zone.js": ">=0.11.0" | |||
}, | |||
"devDependencies": { | |||
"@angular-devkit/core": "^14.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if this is related, but I get the following error when I try to run ionic serve
:
liamdebeasi@MacBook-Pro angular-17 % ionic serve
> ng run app:serve --host=localhost --port=8100
[ng] Error: Unknown arguments: host, port
[ERROR] ng has unexpectedly closed (exit code 1).
This happens in ng16 and ng17.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe the schematic updates should impact that. This schematic's execution context is purely for the ng add
command. After that it has no usage.
For example if I use the dev-build to run ng add
and then install the latest version of @ionic/angular
I get the same exception when using ionic serve
:
sean@MacBook-Air ~/d/i/i/a/angular-blank (main)> ionic serve
> ng run app:serve --host=localhost --port=8100
[ng] Error: Unknown arguments: host, port
Developers really should be using the start
command script with their projects: npm start
.
Edit: But we should probably track this problem for the Ionic CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok looked into this more. You cannot assume to use ionic serve
in a new Angular project. If the project name is not "app" it won't work.
For example my project is called angular-blank
, so the command would need to be:
ng run angular-blank:serve --host=localhost --port=8100
> ng run angular-blank:serve --host=localhost --port=8100
Initial Chunk Files | Names | Raw Size
polyfills.js | polyfills | 82.71 kB |
styles.css | styles | 32.69 kB |
main.js | main | 23.47 kB |
| Initial Total | 138.87 kB
Application bundle generation complete. [2.358 seconds]
Watch mode enabled. Watching for file changes...
➜ Local: http://localhost:8100/
Our schematic could change the project name, but I think that is extremely high risk to break a lot of things in the consumers project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this problem happened before the dev build them I'm fine keeping it out of scope. I assumed you could use ionic serve
because the ionic.config.json
file was present, but maybe that's not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you can use the Ionic CLI if you provide the project name for your angular project. If a name is not provided it defaults to app
.
e.g.:
ionic serve --project=angular-blank
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to go once my final comment is addressed.
Issue number: Resolves #28514
What is the current behavior?
When using the
@ionic/angular
schematic in an Angular 17 project (ng add @ionic/angular
), developers will receive an error preventing the schematic from running.Additionally, the previous implementations of the schematic are out of sync with the current state of the Ionic starters:
variables.css
is empty and missing Ionic's defaultsionic.config.json
is not createdWhat is the new behavior?
ng add @ionic/angular
works with Angular 17 projectsng add @ionic/angular
has fallback behavior for Angular 16 projects usingAppModule
variables.css
from Ionic starters@angular-devkit/schematics
and@schematics/angular
.@ionic/angular-toolkit
CLI configuration and schematics configuration in theangular.json
ionic.config.json
Does this introduce a breaking change?
Other information
Dev-build:
7.5.5-dev.11700239837.1925bbdb
To test this PR:
npm install -g @angular/cli@17
ng new angular-17
ng add @ionic/[email protected]
provideIonicAngular({})
is added to theapp.config.ts
ionic.config.json
was createdangular.json
was updated with the@ionic/angular-devkit
configurationsNow verify legacy behavior:
npm install -g @angular/cli@16
ng new angular-16
ng add @ionic/[email protected]
IonicModule.forRoot({})
is added to theapp.module.ts
angular.json
ionic.config.json
was createdangular.json
was updated with the@ionic/angular-devkit
configurations