This repository was archived by the owner on Apr 17, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 "prepare" : " husky install" ,
55 "debug" : " tsn ./src/bin/tsn.ts" ,
66 "tsn-debug" : " tsc && CLI_DEBUG=1 node ./dist/bin/tsn.js testscript.ts" ,
7- "tsn2 -debug" : " tsc && CLI_DEBUG=1 node ./dist/bin/tsn2 .js testscript.ts"
7+ "tsn -debug-esbuild " : " tsc && CLI_DEBUG=1 TSN_ESBUILD=1 node ./dist/bin/tsn .js testscript.ts"
88 },
99 "dependencies" : {
1010 "@naturalcycles/nodejs-lib" : " ^12.8.0" ,
3232 ],
3333 "main" : " dist/index.js" ,
3434 "bin" : {
35- "tsn2" : " dist/bin/tsn2.js" ,
3635 "tsn" : " dist/bin/tsn.js"
3736 },
3837 "publishConfig" : {
Original file line number Diff line number Diff line change 1616 ` -T -r tsconfig-paths/register -r dotenv/config ` . Will use ` ./scripts/tsconfig.json ` (file will be
1717 auto-generated in not present).
1818
19- - ` tsn2 ` is an experimental version of ` tsn ` that uses ` esbuild ` and ` esbuild-register ` instead of
20- ` typescript ` and ` ts-node ` .
19+ Set ` TSN_ESBUILD ` env variable to enable experimental ` esbuild ` transpilation, using ` esbuild ` and
20+ ` esbuild-register ` instead of ` typescript ` and ` ts-node ` .
2121
2222# Packaging
2323
Original file line number Diff line number Diff line change 11/*
22
33yarn tsn-debug
4- yarn tsn2 -debug
4+ yarn tsn -debug-esbuild
55
66 */
77
Original file line number Diff line number Diff line change @@ -8,11 +8,10 @@ import * as fs from 'fs'
88import * as path from 'path'
99import type * as nodejsLib from '@naturalcycles/nodejs-lib/dist/fs'
1010import * as c from 'chalk'
11- import * as tsnode from 'ts-node'
1211
1312const projectDir = path . join ( __dirname , '../..' )
1413const cfgDir = `${ projectDir } /cfg`
15- const { CLI_DEBUG } = process . env
14+ const { CLI_DEBUG , TSN_ESBUILD } = process . env
1615
1716try {
1817 main ( )
@@ -60,10 +59,18 @@ function main(): void {
6059 require ( 'loud-rejection/register' )
6160 require ( 'dotenv/config' )
6261
63- tsnode . register ( {
64- transpileOnly : true ,
65- project : projectTsconfigPath ,
66- } )
62+ if ( TSN_ESBUILD ) {
63+ const { register } = require ( 'esbuild-register/dist/node' )
64+ register ( {
65+ tsconfigRaw : fs . readFileSync ( projectTsconfigPath , 'utf8' ) ,
66+ } )
67+ } else {
68+ const tsnode = require ( 'ts-node' )
69+ tsnode . register ( {
70+ transpileOnly : true ,
71+ project : projectTsconfigPath ,
72+ } )
73+ }
6774
6875 if ( fs . existsSync ( `./node_modules/tsconfig-paths` ) ) {
6976 // ok, for the `paths` it works to load from the root `tsconfig` too
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments