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

Add support for swc #74

Merged
merged 1 commit into from
Apr 2, 2022
Merged

Add support for swc #74

merged 1 commit into from
Apr 2, 2022

Conversation

HRKings
Copy link
Contributor

@HRKings HRKings commented Nov 19, 2021

Hey! This is a simple PR to add support for swc, since it is increasing in popularity and it's very fast! While it is supposed to be a drop-in replacement for babel, I only adding it on TypeScript extension as is what I more used to

@HRKings HRKings changed the title Add support swc Add support for swc Nov 19, 2021
@phated
Copy link
Member

phated commented Nov 19, 2021

This is super cool! I probably won't have time to look at it until after the holiday, but I'll try to get it in asap.

@HRKings
Copy link
Contributor Author

HRKings commented Nov 22, 2021

Thanks! No worries, take your time!

@phated phated added this to In progress in v5 Nov 22, 2021
index.js Outdated
@@ -156,6 +156,7 @@ var extensions = {
});
},
},
'@swc/register',
Copy link
Member

Choose a reason for hiding this comment

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

@HRKings I believe we need to implement this the same way that babel is registered. Otherwise swc hooks all of their DEFAULT_EXTENSIONS. We only want to hook .ts which can be passed as an option. https://github.com/swc-project/register/blob/master/src/node.ts#L106

Copy link
Member

Choose a reason for hiding this comment

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

It looks like they support the ignore option, too. So it'll be almost the same, without rootMode

Copy link
Member

Choose a reason for hiding this comment

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

swc might only support regexp strings in the ignore, I can't tell and couldn't find it in their docs. Their code is also very hard to traverse so idk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the delay, I added the hook for swc

Copy link
Member

Choose a reason for hiding this comment

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

@HRKings I'm just waiting on a new release from the swc/register team to get support for this: swc-project/register@d9a617a

Fwiw, I think this will allow us to implement .swc.js like we do .babel.js for babel.

Copy link
Member

Choose a reason for hiding this comment

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

It seems that they released it; however, the author doesn't understand why programmatic usage would be useful so we have to import it as @swc/register/lib/node

index.js Outdated
register: function(hook) {
hook({
extensions: '.ts',
ignore: [ignoreNonBabelAndNodeModules],
Copy link
Member

Choose a reason for hiding this comment

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

Assuming those changes are released, we'll want to evaluate supporting .swc.js and changing this ignore to one specific for swc.

hasparus added a commit to dethcrypto/dethcode that referenced this pull request Mar 31, 2022
* Use esbuild-register instead of ts-node

* Alias esbuild-register to typescript-register as `interpret` doesn't know ESBuild exists

See:
- gulpjs/interpret#74
- https://github.dev/webpack/webpack-cli/blob/b39dfb68fc478194c438d128ed1f7232a5346a1c/packages/webpack-cli/src/webpack-cli.ts#L1796
@phated phated merged commit f160451 into gulpjs:master Apr 2, 2022
@phated
Copy link
Member

phated commented Apr 2, 2022

Thanks for doing the heavy lifting @HRKings! I did a bit of cleanup to make sure this could land but it looked great otherwise.

This and esbuild will need to go out in the next major. Stay tuned!

@HRKings
Copy link
Contributor Author

HRKings commented Apr 5, 2022

Thanks for doing the heavy lifting @HRKings! I did a bit of cleanup to make sure this could land but it looked great otherwise.

This and esbuild will need to go out in the next major. Stay tuned!

Thanks! It was a honor to contribute! Keep the good work!

@phated phated moved this from In progress to Done in v5 Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v5
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants