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: use Ionic standalone components #504

Merged
merged 1 commit into from
Nov 29, 2023
Merged

feat: use Ionic standalone components #504

merged 1 commit into from
Nov 29, 2023

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Nov 29, 2023

Support for generating standalone components and pages was added in 5523f7a. However, this work used the lazy loaded build of Ionic via IonicModule since Ionic standalone components did not exist yet.

Now that Ionic standalone components have been released, I'd like to update the page/component generation to use Ionic standalone components instead of IonicModule.

Note: You may encounter a waitForAsync syntax error when testing. This is fixed in #505.

closes #500

import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';<% if(!standalone) {%>
import { IonicModule } from '@ionic/angular';<%} %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IonicModule is only needed for the lazy loaded build

Comment on lines -13 to +14
imports: [IonicModule.forRoot()]
imports: [IonicModule.forRoot()]<%} %><% if(standalone) {%>
imports: [<%= classify(name) %><%= classify(type) %>],<%} %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If standalone we need to pass the component in imports. If not standalone we need to pass the component in declarations and IonicModule in imports.

@@ -3,7 +3,8 @@ import { Component, OnInit } from '@angular/core';
@Component({
selector: '<%= selector %>',
templateUrl: './<%= dasherize(name) %>.<%= dasherize(type) %>.html',
styleUrls: ['./<%= dasherize(name) %>.<%= dasherize(type) %>.<%= styleext %>'],
styleUrls: ['./<%= dasherize(name) %>.<%= dasherize(type) %>.<%= styleext %>'],<% if(standalone) {%>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't there before, but the application compiled. My understanding is that standalone components should have standalone: true.

@@ -2,14 +2,14 @@ import { Component, OnInit } from '@angular/core';<% if(routePath) { %>
import { ActivatedRoute, Params } from '@angular/router';<% } %><% if(standalone) {%>
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';<%} %>
import { IonContent, IonHeader, IonTitle, IonToolbar } from '@ionic/angular/standalone';<%} %>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This uses actual Ionic standalone components instead of the lazy loaded ones.

@liamdebeasi liamdebeasi marked this pull request as ready for review November 29, 2023 16:14
Copy link
Contributor

@sean-perkins sean-perkins left a comment

Choose a reason for hiding this comment

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

Proposed changes look good.

@liamdebeasi liamdebeasi merged commit 8d6ce1c into main Nov 29, 2023
2 checks passed
@liamdebeasi liamdebeasi deleted the standalone branch November 29, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: standalone schematics
2 participants