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: set legacy decorators version when experimentalDecorators enabled #189

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

Timeless0911
Copy link
Collaborator

@Timeless0911 Timeless0911 commented Sep 9, 2024

Summary

  • use tsconfck to find and parse tsconfig file
  • set legacy decorators version when experimentalDecorators enabled
  • add tsconfigPath test cases
  • prebundle rslog

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link

netlify bot commented Sep 9, 2024

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit 9a32c86
🔍 Latest deploy log https://app.netlify.com/sites/rslib/deploys/66e015d3f913e40008aadb31
😎 Deploy Preview https://deploy-preview-189--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Timeless0911 Timeless0911 enabled auto-merge (squash) September 9, 2024 11:48
Copy link
Member

@fi3ework fi3ework left a comment

Choose a reason for hiding this comment

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

I just recalled web-infra-dev/modern.js#5834.

How does esbuild do? See https://github.com/evanw/esbuild/blob/main/CHANGELOG.md#0210:

Note that this feature is different than the existing "TypeScript experimental decorators" feature that esbuild already implements. It uses similar syntax but behaves very differently, and the two are not compatible (although it's sometimes possible to write decorators that work with both). TypeScript experimental decorators will still be supported by esbuild going forward as they have been around for a long time, are very widely used, and let you do certain things that are not possible with JavaScript decorators (such as decorating function parameters). By default esbuild will parse and transform JavaScript decorators, but you can tell esbuild to parse and transform TypeScript experimental decorators instead by setting "experimentalDecorators": true in your tsconfig.json file.

For projects that have experimentalDecorator enabled in tsconfig, should we automatically switch to legacyDecorator (and emitDecoratorMetadata)? Additionally, when we perform checks between configurations later on, legacyDecorator should also check whether it is compatible with decorators.version.

In create-rslib, I think we're good to use the new version of decorator by default.

@Timeless0911
Copy link
Collaborator Author

https://github.com/web-infra-dev/rsbuild/blob/01a8b34143b4957225186e9b80b050103582e546/packages/core/src/plugins/swc.ts#L250-L273

The Rsbuild logic is above, and we should just do a tsconfig detect, and if users config experimentalDecorator: true, we automatically inject legacy decorator Rsbuild config.

@fi3ework
Copy link
Member

web-infra-dev/rsbuild@01a8b34/packages/core/src/plugins/swc.ts#L250-L273

The Rsbuild logic is above, and we should just do a tsconfig detect, and if users config experimentalDecorator: true, we automatically inject legacy decorator Rsbuild config.

Should this be handled by Rsbuild? I think it also applies to app building.

@Timeless0911
Copy link
Collaborator Author

web-infra-dev/rsbuild@01a8b34/packages/core/src/plugins/swc.ts#L250-L273
The Rsbuild logic is above, and we should just do a tsconfig detect, and if users config experimentalDecorator: true, we automatically inject legacy decorator Rsbuild config.

Should this be handled by Rsbuild? I think it also applies to app building.

Rsbuild does not want to be associated with tsconfig.json fields.

@Timeless0911 Timeless0911 force-pushed the test/decorators-tsconfig branch from 4f00f82 to 1600aad Compare September 10, 2024 06:55
@Timeless0911 Timeless0911 changed the title test: add decorators and tsconfig tests feat: set legacy decorators version when experimentalDecorators enabled Sep 10, 2024
@Timeless0911 Timeless0911 enabled auto-merge (squash) September 10, 2024 07:16
@Timeless0911 Timeless0911 enabled auto-merge (squash) September 10, 2024 08:32
@Timeless0911 Timeless0911 merged commit 63bb9ed into main Sep 10, 2024
11 checks passed
@Timeless0911 Timeless0911 deleted the test/decorators-tsconfig branch September 10, 2024 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants