-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Angular: Support v19.2 when @angular/animations is not installed #30611
Conversation
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.
10 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -71,8 +63,8 @@ export class PropertyExtractor implements NgModuleMetadata { | |||
} | |||
} | |||
|
|||
private init() { | |||
const analyzed = this.analyzeMetadata(this.metadata); | |||
public async init() { |
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.
logic: init() is now public and async but constructor no longer calls it - this could cause issues if callers forget to call init()
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.
instead of requiring everyone to call PropertyExtractor.init()
manually after constructing, maybe you can do:
constructor(
private metadata: NgModuleMetadata,
private component?: any
) {
return this.init().then(() => this);
}
so you can do await new PropertyExtractor()
, that will run init and return the instance.
); | ||
return [true, provideNoopAnimations()]; | ||
if (ngModule === animations.NoopAnimationsModule) { | ||
console.error( |
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.
style: console.error() used for NoopAnimationsModule warning while other similar warnings use console.warn() - should be consistent
console.error( | |
console.warn( |
try { | ||
await import('@angular/platform-browser/animations'); | ||
} catch (e) { | ||
webpackConfig.plugins.push( | ||
new WebpackIgnorePlugin({ | ||
resourceRegExp: /@angular\/platform-browser\/animations$/, | ||
}) | ||
); | ||
} |
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.
style: Consider catching a more specific error type than just 'e' to avoid accidentally catching unrelated errors
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.
logic: Removing this template file will break the OpenCloseComponent and its stories unless corresponding changes are made to move this template inline or provide an alternative.
View your CI Pipeline Execution ↗ for commit 46eb952.
☁️ Nx Cloud last updated this comment at |
82faba9
to
d0b1713
Compare
854b7a6
to
46eb952
Compare
@@ -71,8 +63,8 @@ export class PropertyExtractor implements NgModuleMetadata { | |||
} | |||
} | |||
|
|||
private init() { | |||
const analyzed = this.analyzeMetadata(this.metadata); | |||
public async init() { |
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.
instead of requiring everyone to call PropertyExtractor.init()
manually after constructing, maybe you can do:
constructor(
private metadata: NgModuleMetadata,
private component?: any
) {
return this.init().then(() => this);
}
so you can do await new PropertyExtractor()
, that will run init and return the instance.
That's correct. But I have decided against it after reading https://dev.to/somedood/the-proper-way-to-write-async-constructors-in-javascript-1o8c |
Closes #
What I did
In the current release candidate of Angular (v19.2.0-rc.0) it doesn't install
@angular/animations
per default when initializing Angular freshly. Storybook, though, had some imports on@angular/animations
which started to fail.Now, Storybook doesn't require having
@angular/animations
being present, but conditionally applies logic when it is.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
Here's my analysis of the pull request:
Makes Angular renderer compatible with Angular v19.2 by making @angular/animations optional, focusing on dynamic imports and conditional animation handling.
AbstractRenderer.ts
forPropertyExtractor.init()
to handle conditional animation loadingframework-preset-angular-cli.ts
to conditionally import animations and addWebpackIgnorePlugin
when module is missing@angular/animations
an optional peer dependency inpackage.json
with version range>=15.0.0 < 20.0.0
PropertyExtractor.ts
to handle standalone components defaulting to true in Angular 19+