You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User should be able to ts-node --sucrase or add "sucrase": true to tsconfig, just as they can do for swc.
I will maintain a to-do list of tasks based on conversations with @alangpierce.
Interface between ts-node and sucrase (WIP)
These are the bits to lock down into a non-breaking interface of sorts, between sucrase and ts-node
What module specifier should ts-node require() when user enables "sucrase": true?
basically, this is the value of the "transpiler" option, but I think we do a bit of project-local and global fallback require() conveniences to make things "just work"
What is the name of the module, if different than above?
e.g when we fail to require('sucrase/ts-node-plugin') then we should suggest that users add sucrase` to their package.json
we must(?) also declare optional peerDep for strict package managers
way for transpiler to return diagnostics
errors and warnings
from both create() and transpile()
way for transpiler to indicate REPL continuation / recoverable input
TODOs (WIP)
Add "sucrase" option to config
Add --sucrase flag to CLI
Add --sucrase flag to CLI --help
Redo docs to describe SWC and sucrase under same umbrella
In terms of plugin interface improvements, my impression is that there won't be that many plugins in the first place, so extra capabilities (e.g. diagnostics) should probably take priority over ease of use for plugin authors (e.g. isJsx and isTs flags). The current interface is already much easier to use than trying to integrate with node and TS from scratch, of course.
I think the transpiler plugin interface would be useful in these other use cases:
esbuild (for people using it elsewhere who want consistency)
Babel (for people already using it or people who have custom Babel plugins)
Any other ambitious transpiler authors.
Internal company/project use cases. For example, maybe you want to apply some regex to rewrite imports before or after running the code through tsc or some other transpiler.
Thinking through potential plugin interface changes, two other possible future ones come to mind (maybe already on your radar):
Allowing async transformations. This wouldn't be useful for Sucrase, but I know that esbuild transformSync is slower than the async transform. (I see you're already familiar with the details: Faster sync API via worker_thread evanw/esbuild#590 .) Presumably the sync API is necessary for require hooks, but theoretically the plugin interface could prefer the async version (e.g. for ESM hooks) and fall back to a sync implementation when necessary.
Document that plugins must be stateless so you can run the transformation in parallel using worker threads. (Or maybe provide a mechanism for plugins to opt in or out of parallelism.)
I think both of these could be introduced in a backcompat way.
way for transpiler to indicate REPL continuation / recoverable input
This issue tracks the work necessary on the ts-node side to offer first-class support for a sucrase transpiler.
Related to:
alangpierce/sucrase#726
alangpierce/sucrase#729
User should be able to
ts-node --sucrase
or add"sucrase": true
to tsconfig, just as they can do for swc.I will maintain a to-do list of tasks based on conversations with @alangpierce.
Interface between ts-node and sucrase (WIP)
These are the bits to lock down into a non-breaking interface of sorts, between sucrase and ts-node
require()
when user enables"sucrase": true
?"transpiler"
option, but I think we do a bit of project-local and global fallbackrequire()
conveniences to make things "just work"require('sucrase/ts-node-plugin') then we should suggest that users add
sucrase` to their package.jsoncreate()
andtranspile()
TODOs (WIP)
--sucrase
flag to CLI--sucrase
flag to CLI --help@internal
transpiler API bits publicts-node/src/transpilers/types.ts
Lines 22 to 44 in 97f9afd
nodeModuleEmitKind
create()
ortranspile()
callsTSNODE-SUCRASE-123
The text was updated successfully, but these errors were encountered: