Skip to content

refactor(@angular/ssr): export tokens from the /tokens entry point #28678

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

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

alan-agius4
Copy link
Collaborator

This commit relocates the DI tokens to a dedicated entry point. This change ensures that we do not depend on tree-shaking to eliminate server code from client bundles.

Closes #28670

"src/**/*.ts",
],
),
module_name = "@angular/ssr/tokens",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Any other ideas for as an entry-point name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@angular/ssr/tokens seems reasonable to me.

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: major This PR is targeted for the next major release labels Oct 21, 2024
This commit relocates the DI tokens to a dedicated entry point. This change ensures that we do not depend on tree-shaking to eliminate server code from client bundles.

Closes angular#28670
Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

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

Is the goal to support users doing:

import { REQUEST } from '@angular/ssr/tokens';

inject(REQUEST, { optional: true });

And be able to run that on the client without a risk of retaining server code?

I can see some users having encountering friction from having to import the non-default entry point, but IDE auto-imports should mostly solve that problem, and reducing the risk of server code in the client bundle seems worth the trade-off.

"src/**/*.ts",
],
),
module_name = "@angular/ssr/tokens",
Copy link
Collaborator

Choose a reason for hiding this comment

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

@angular/ssr/tokens seems reasonable to me.

@alan-agius4
Copy link
Collaborator Author

Is the goal to support users doing:

import { REQUEST } from '@angular/ssr/tokens';

inject(REQUEST, { optional: true });

And be able to run that on the client without a risk of retaining server code?

I can see some users having encountering friction from having to import the non-default entry point, but IDE auto-imports should mostly solve that problem, and reducing the risk of server code in the client bundle seems worth the trade-off.

Correct.

@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 Oct 21, 2024
@alan-agius4 alan-agius4 merged commit 1cacb8d into angular:main Oct 21, 2024
30 of 31 checks passed
@alan-agius4 alan-agius4 deleted the move-tokens branch October 21, 2024 16:37
@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 Nov 21, 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 target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server code goes to browser bundle on v19
2 participants