Skip to content
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

Support swc ts-node option. #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ If you need to detect that you are running with `ts-node-dev`, check if `process

- If you want desktop-notifications you should install `node-notifier` package and use `--notify` flag.

- Especially for large code bases always consider running with `--transpile-only` flag which is normal for dev workflow and will speed up things greatly. Note, that `ts-node-dev` will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.
- Especially for large code bases always consider running with `--swc` or `--transpile-only` flag which is normal for dev workflow and will speed up things greatly. Note, that `ts-node-dev` will not put watch handlers on TS files that contain only types/interfaces (used only for type checking) - this is current limitation by design.

- `--ignore-watch` will NOT affect files ignored by TS compilation. Use `--ignore` option (or `TS_NODE_IGNORE` env variable) to pass **RegExp strings** for filtering files that should not be compiled, by default `/node_modules/` are ignored.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"rimraf": "^2.6.1",
"source-map-support": "^0.5.12",
"tree-kill": "^1.2.2",
"ts-node": "^10.4.0",
"ts-node": "^10.5.0",
"tsconfig": "^7.0.0"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const tsNodeFlags = {
'files',
'pretty',
'transpile-only',
'swc',
'prefer-ts-exts',
'prefer-ts',
'log-error',
Expand All @@ -37,6 +38,7 @@ const tsNodeFlags = {

const tsNodeAlias = {
'transpile-only': 'T',
'swc': 'W',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I can see in the official docs, ts-node does not use -W short flag for swc, there's only a full --swc option

'compiler-host': 'H',
ignore: 'I',
'ignore-diagnostics': 'D',
Expand All @@ -58,6 +60,7 @@ type TSNodeOptions = {
emit: boolean
files: boolean
'transpile-only': boolean
swc: boolean
pretty: boolean
scope: boolean
scopeDir: string,
Expand Down
3 changes: 2 additions & 1 deletion src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ export const makeCompiler = (
emit: options['emit'],
files: options['files'],
pretty: options['pretty'],
transpileOnly: options['transpile-only'],
transpileOnly: options['transpile-only'] ? true : undefined,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the original options['transpile-only'] assignment not working properly? Is there an edge case that had to be resolved with a ternary operator?

swc: options['swc'],
ignore: options['ignore'] ? split(options['ignore']) : undefined,
preferTsExts: options['prefer-ts-exts'],
logError: options['log-error'],
Expand Down
14 changes: 10 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4632,10 +4632,10 @@ ts-nameof@^5.0.0:
"@ts-nameof/transforms-ts" "^4.2.1"
glob "^7.1.6"

ts-node@^10.4.0:
version "10.4.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==
ts-node@^10.5.0:
version "10.5.0"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.5.0.tgz#618bef5854c1fbbedf5e31465cbb224a1d524ef9"
integrity sha512-6kEJKwVxAJ35W4akuiysfKwKmjkbYxwQMTBaAxo9KKAx/Yd26mPUyhGz3ji+EsJoAgrLqVsYHNuuYwQe22lbtw==
dependencies:
"@cspotcode/source-map-support" "0.7.0"
"@tsconfig/node10" "^1.0.7"
Expand All @@ -4648,6 +4648,7 @@ ts-node@^10.4.0:
create-require "^1.1.0"
diff "^4.0.1"
make-error "^1.1.1"
v8-compile-cache-lib "^3.0.0"
yn "3.1.1"

tsconfig-paths@^3.3.1:
Expand Down Expand Up @@ -4831,6 +4832,11 @@ uuid@^3.0.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04"

v8-compile-cache-lib@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz#0582bcb1c74f3a2ee46487ceecf372e46bce53e8"
integrity sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==

v8-compile-cache@^2.0.3:
version "2.1.1"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz#54bc3cdd43317bca91e35dcaf305b1a7237de745"
Expand Down