-
-
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 esbuild-register for typescript extensions #77
Conversation
Thanks! Wisp is super old and I've always had problems with it. Don't worry about it here |
All right 👌 LMK if there's something to change in my code then. |
index.js
Outdated
@@ -146,6 +146,7 @@ var extensions = { | |||
'typescript-register', | |||
'typescript-require', | |||
'sucrase/register/ts', | |||
'esbuild-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.
It looks like this hooks too many extensions if you use it the "default" way: https://github.com/egoist/esbuild-register/blob/master/src/node.ts#L67-L74
I believe we need to implement this similar to babel/register. See their register function at https://github.com/egoist/esbuild-register/blob/master/src/node.ts#L96
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.
Makes sense — so we can pass just .ts
or .tsx
to extensions
.
https://github.com/egoist/esbuild-register/blob/master/src/node.ts#L98
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.
Yep! We needed to add the "extended" config syntax so we didn't hook extra extensions with babel. We want to be really delicate with the hooking
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.
Ouch, we'll have to require esbuild-register/dist/node
, right? It's not exposed to the outside.
Something like the following?
{
module: 'esbuild-register/dist/node',
register: function(mod) {
mod.register({
extensions: '[.ts'],
target: 'node' + process.version.slice(1),
});
},
},
I'm not a huge fan of accessing /dist/node
, but we also can't use esbuild
directly, so maybe it
ould be better to create an issue asking if dist/node
can be considered public API.
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.
I'd be fine with your snippet, but I also agree that it should probably be part of their public API. Not sure if that is something @egoist would want to do.
Hey @phated, I just pushed the change with "extended" config syntax. I'm not sure if it's all right, because now the |
Just flakey. We might just drop support for these extensions in a breaking release 🤔 |
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.
Thanks for doing this! 🙇
Thanks! I'm actually hoping to finish #36 before we ship v3! |
Hi @phated 👋
I felt so smart with my workaround until you mentioned we could do this in a civilized way :P