-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
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. |
Thanks! No worries, take your time! |
index.js
Outdated
@@ -156,6 +156,7 @@ var extensions = { | |||
}); | |||
}, | |||
}, | |||
'@swc/register', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
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.
* 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
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! |
* 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
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