Skip to content

Conversation

@alan-agius4
Copy link
Collaborator

@angular/platform-server/init entry-point is side-effectful and thus it's not safe to perform advanced optimizations.

…/init` from unsafe optimizations

`@angular/platform-server/init` entry-point is side-effectful and thus it's not safe to perform advanced optimizations.
@alan-agius4 alan-agius4 requested a review from clydin April 27, 2023 09:33
@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 27, 2023

if (optimize) {
const angularPackage = /[\\/]node_modules[\\/]@angular[\\/]/.test(this.resourcePath);
// @angular/platform-server/init entry-point has side-effects.
Copy link
Member

Choose a reason for hiding this comment

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

what about other side-effect entry-points? we might be adding arbitrary ones. Can't we rely on the sideEffects field in package.json? We also have localize/init IIRC (but yes- that one is usually not in user code I think)

Copy link
Member

Choose a reason for hiding this comment

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

Once we move this into the actual FW packaging and bundling process, these checks can all be removed.
Also, adding any side effect entry points should be done with care since import statement usage then can become order dependent. As well as also causing deoptimizations in other aspects of the build pipeline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@angular/localize/init is not in users code indeed.

Copy link
Member

Choose a reason for hiding this comment

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

Yes exactly, just need to be careful in adding new entry-points. I don't think the current solution is ideal (and I'm not aware of the concrete plans going forward)

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Apr 27, 2023
@angular-robot angular-robot bot merged commit 621d088 into angular:main Apr 27, 2023
@alan-agius4 alan-agius4 deleted the side-effect-bo branch April 27, 2023 12:40
@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 May 28, 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 target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants