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(@angular/ssr): move CommonEngine API to /node entry-point #28278

Merged

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Aug 26, 2024

Refactored the CommonEngine API import path to remove Node.js dependencies from the @angular/ssr main entry-point.

BREAKING CHANGE:

The CommonEngine API now needs to be imported from @angular/ssr/node.

Before

import { CommonEngine } from '@angular/ssr';

After

import { CommonEngine } from '@angular/ssr/node';

@angular-robot angular-robot bot added detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit area: @angular/ssr labels Aug 26, 2024
@alan-agius4 alan-agius4 added the target: major This PR is targeted for the next major release label Aug 26, 2024
@alan-agius4 alan-agius4 requested a review from dgp1130 August 26, 2024 08:42
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 26, 2024
@alan-agius4 alan-agius4 force-pushed the create-secondary-entry-points-ssr branch 4 times, most recently from 27c2ee9 to e582d38 Compare August 26, 2024 09:41
}

recorder ??= tree.beginUpdate(sourceFile.fileName);
recorder.insertRight(ssrImport.moduleSpecifier.getEnd() - 1, '/node');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: What if the user has imported other symbols from @angular/ssr? I think we would want to create a new @angular/ssr/node import and move CommonEngine there, but leave the rest of the imports as is?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are no other exported symbols

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah cool, that makes this easier then. If so, do we really care about CommonEngine at all? Should we just look for imports of @angular/ssr and replace them with @angular/ssr/node?

I think an unused import {} from '@angular/ssr'; or import * as ssr from '@angular/ssr'; might fall through the cracks here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to check that we only migrate when the symbols start with CommonEngine otherwise the migration will not be idempotent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IMHO, those 2 cases are rare enough that doesn’t warrant to be included.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to check that we only migrate when the symbols start with CommonEngine otherwise the migration will not be idempotent.

I don't see why an @angular/ssr -> @angular/ssr/node rename wouldn't be idempotent, but I'll defer to you that's it's necessary.

I agree the import {} and import * as ssr cases probably aren't important enough to go out of our way for.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually one case would be if users start users the new API which is exported from '@angular/ssr' (When it's publicly available. We do not want to migrate those to use @angular/ssr/node.

Refactored the `CommonEngine` API import path to remove Node.js dependencies from the `@angular/ssr` main entry-point.

BREAKING CHANGE:

The `CommonEngine` API now needs to be imported from `@angular/ssr/node`.

**Before**
```ts
import { CommonEngine } from '@angular/ssr';
```

**After**
```ts
import { CommonEngine } from '@angular/ssr/node';
```
@alan-agius4 alan-agius4 force-pushed the create-secondary-entry-points-ssr branch from e582d38 to af4f287 Compare August 26, 2024 17:05
}

recorder ??= tree.beginUpdate(sourceFile.fileName);
recorder.insertRight(ssrImport.moduleSpecifier.getEnd() - 1, '/node');
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to check that we only migrate when the symbols start with CommonEngine otherwise the migration will not be idempotent.

I don't see why an @angular/ssr -> @angular/ssr/node rename wouldn't be idempotent, but I'll defer to you that's it's necessary.

I agree the import {} and import * as ssr cases probably aren't important enough to go out of our way for.

@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 Aug 27, 2024
@alan-agius4 alan-agius4 merged commit 4b09887 into angular:main Aug 27, 2024
29 checks passed
@alan-agius4 alan-agius4 deleted the create-secondary-entry-points-ssr branch August 27, 2024 06:57
@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 Sep 27, 2024
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 area: @angular/ssr detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants