-
-
Notifications
You must be signed in to change notification settings - Fork 547
Open
Labels
researchNeeds design work, investigation, or prototyping. Implementation uncertain.Needs design work, investigation, or prototyping. Implementation uncertain.
Milestone
Description
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
- 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 fallbackrequire()conveniences to make things "just work"
- basically, this is the value of the
- 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 addsucrase` to their package.json - we must(?) also declare optional peerDep for strict package managers
- e.g when we fail to
- way for transpiler to return diagnostics
- errors and warnings
- from both
create()andtranspile()
- way for transpiler to indicate REPL continuation / recoverable input
TODOs (WIP)
- Add "sucrase" option to config
- Add
--sucraseflag to CLI - Add
--sucraseflag to CLI --help - Redo docs to describe SWC and sucrase under same umbrella
- make
@internaltranspiler API bits publicts-node/src/transpilers/types.ts
Lines 22 to 44 in 97f9afd
/** @category Transpiler */ export interface CreateTranspilerOptions { // TODO this is confusing because its only a partial Service. Rename? // Careful: must avoid stripInternal breakage by guarding with Extract<> service: Pick< Service, Extract<'config' | 'options' | 'projectLocalResolveHelper', keyof Service> >; /** * If `"transpiler"` option is declared in an "extends" tsconfig, this path might be different than * the `projectLocalResolveHelper` * * @internal */ transpilerConfigLocalResolveHelper: ProjectLocalResolveHelper; /** * When using `module: nodenext` or `module: node12`, there are two possible styles of emit: * - CommonJS with dynamic imports preserved (not transformed into `require()` calls) * - ECMAScript modules with `import foo = require()` transformed into `require = createRequire(); const foo = require()` * @internal */ nodeModuleEmitKind?: NodeModuleEmitKind; } nodeModuleEmitKind
- figure out how sucrase should send us diagnostics: errors or warnings
- either from
create()ortranspile()calls - let plugins declare their own "name" to namespace the diagnostics: e.g.
TSNODE-SUCRASE-123 - Maybe becomes part of the interface described above, or maybe merely part of the transpiler API
- either from
- accept sourcemap as object in transpiler API
- expose api version? to make future breaks easier to detect by plugins?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
researchNeeds design work, investigation, or prototyping. Implementation uncertain.Needs design work, investigation, or prototyping. Implementation uncertain.