TypeStrong/ts-node
TypeScript execution and REPL for node.js
📋 Changes
- Fixed `tsconfig.json` file not found on latest TypeScript version (https://github.com/TypeStrong/ts-node/pull/2091)
📋 Changes
- Workaround nodejs bug introduced in 18.6.0 (#1838) @cspotcode
- Only affects projects on node >=18.6.0 using `--esm`
- Older versions of node and projects without `--esm` are unaffected
📋 Changes
- `--project` accepts path to a directory containing a `tsconfig.json` (#1829, #1830) @cspotcode
- previously it required an explicit filename
- Added helpful error message when swc version is too old to support our configuration (#1802) @cspotcode
- Added `experimentalTsImportSpecifiers` option which allows using voluntary `.ts` file extensions in import specifiers (undocumented except for [API docs](https://typestrong.org/ts-node/api/interfaces/CreateOptions.html#experimentalTsImportSpecifiers)) (#1815) @cspotcode
- Fixed bug where `child_process.fork()` would erroneously execute the parent's entrypoint script, not the intended child script (#1812, #1814) @devversion
- Fixed support for jsx modes `"react-jsx"` and `"react-jsxdev"` in swc transpiler (#1800, #1802) @cspotcode
- Fixed support for import assertions in swc transpiler (#1817, #1802) @cspotcode
- Fixed bug where calling `repl.evalCode()` with code not ending in a newline would not update the typechecker accordingly (#1764, #1824) @cspotcode
📋 Changes
- Revert "Use file URL for source map paths" (#1821) @cspotcode
- Fixes #1790: ts-node 10.8.1 regression where `nyc` code coverage reports had incorrect paths
- Fixes #1797: ts-node 10.8.1 regression where breakpoints did not hit in VSCode debugging
- Allow JSON imports in node 16.15 and up (#1792) @queengooborg
- JSON imports were already supported in v17.5 and up
- this change extends support to >=16.15.0,<17.0.0
- These version ranges match vanilla node's support for JSON imports
📋 Changes
- Fixed #1769: source URLs in source map cache were malformed on Windows, affecting code coverage reports (#1769, #1771) @PaperStrike
- Fixed #1778: typechecker was erronously resolving imports from ESM files as if they were from CJS files (#1778, #1782) @cspotcode
📋 Changes
- Added support for `module=NodeNext`, `module=Node16`, `.mts`, `.cts`, `.mjs`, and `.cjs` file extensions (#1414, #1694, #1744, #1745, #1727, #1717, #1753, #1757) @cspotcode
- For best results, enable `experimentalResolver` ([docs](https://typestrong.org/ts-node/docs/options#experimentalresolver))
- See TypeScript's official documentation: https://www.typescriptlang.org/docs/handbook/esm-node.html
- enables mixed-mode projects with both ESM and CommonJS
- enables all supported file extensions in TypeScript 4.7
- Obeys package.json "type"
- Added ability to include file extensions in CommonJS imports (#1727, #1753) @cspotcode
- Enables consistency with ESM, where file extensions are often mandatory
- + 27 more
📋 Changes
- Adds `--esm` flag, option, and `ts-node-esm` binary (#1258, #1655)
- Enables full `esm` support; no need for `--loader` nor `NODE_OPTIONS`
- Use shebang `#!/usr/bin/env ts-node-esm`, run `ts-node --esm`, or add to your tsconfig.json: `"ts-node": {"esm": true}`
- Unflag ESM json modules on node >=17.5.0 (#1661, #1665) @Jamesernator
- no longer requires `--experimental-json-modules`
- Lazy-load dependencies to improve startup responsiveness. (#1676)
- Fixed bug where "compiler", "transpiler", and swc backend would not resolve relative to the tsconfig.json that declared them (#1662, #1655)
- Enables reusable tsconfig.json shared via node module to include necessary dependencies
📋 Changes
- Adds workaround for extensionless entrypoints with ESM loader (#1649, #1654)
- You can now combine tools such as `mocha` with `--loader ts-node/esm`, where previously node would throw `[ERR_UNKNOWN_FILE_EXTENSION]`
- node has a bug where combining `--loader` with an extensionless entrypoint causes this error nodejs/node#33226
- Some tools, for example `mocha`, have an extensionless entrypoint. ([source](https://github.com/mochajs/mocha/blob/547ffd73535088322579d3d2026432112eae3d4b/package.json#L37), [source](https://github.com/mochajs/mocha/blob/547ffd73535088322579d3d2026432112eae3d4b/bin/mocha))
- Combining `NODE_OPTIONS=--loader ts-node/esm` with these tools causes this error. mochajs/mocha#4645
- node intends to fix this bug in a future release: nodejs/node#41711
- In the interim, we have implemented a workaround in ts-node.
- Adds support for target "ES2022" in `moduleTypes` overrides (#1650)
- + 5 more
📋 Changes
- Eliminate "Emit Skipped" errors (#693, #1345, #1629)
- Avoids all "Emit Skipped" errors by performing a fallback `transpileOnly`-style transformation.
- Does not affect typechecking. Type errors are still detected and thrown.
- Fallback has the same limitations as `isolatedModules`. This will only affect rare cases such as using `const enums` with `preserveConstEnums` disabled.
- Fixes #693
- Graduate swc transpiler out of experimental; add `swc: true` convenience option ([docs](https://typestrong.org/ts-node/docs/transpilers)) (#1487, #1536, #1613, #1627)
- `"swc": true` or `--swc` will use swc for faster execution
- This feature is no longer marked "experimental." Thank you to everyone who filed bugs!
- + 23 more
📝 Docs
- Explain `env -S` flag for shebangs ([docs](https://typestrong.org/ts-node/docs/usage#shebang)) (#1448, #1545) @sheeit, @chee
- Suggest `skipIgnore` when you want to compile files in node_modules ([docs](https://typestrong.org/ts-node/docs/how-it-works)) (#1553) @webstrand
- Fix typo in `moduleTypes` on options page ([docs](https://typestrong.org/ts-node/docs/options)) (#1630, #1633)
📦 Misc
- Adds experimental `experimentalResolverFeatures` option, but it does not do anything yet (#1514, #1614)
- https://github.com/TypeStrong/ts-node/compare/v10.4.0...v10.5.0
- https://github.com/TypeStrong/ts-node/milestone/4
📋 Changes
- Adds support for targets "es2020" and "es2021" to swc transpiler (#1521)
- Adds automatic target downgrade when using older versions of swc (#1521)
- If tsconfig specifies es2020, but your version of swc only supports up to es2019, ts-node will automatically switch to es2019 instead of throwing an error
- Improves types and API docs for `creatEsmHooks` ([API docs](https://typestrong.org/ts-node/api/index.html#createEsmHooks)) (#1506, #1529)
- Fix #1526: data URL handling in new ESM loader hooks API (#1526, #1529)
📋 Changes
- Add version check to use new loader hooks API for node >=16.12.0 (#1522) @shrujalshah28
📋 Changes
- Declare types for node builtin modules within REPL so you do not need to import them (#1424, #1500)
- Node REPL exposes builtin modules as globals; typechecker now understands this
- Typechecking should no longer raise errors when using builtins without first importing
- For example: `util.promisify(setTimeout)(1000)` or `fs.readFileSync('example.txt')`
- Add `createEsmHooks()` function to create ESM loader hooks ([API docs](https://typestrong.org/ts-node/api/index.html#createEsmHooks)) (#1439) @nonara
- Can be used to compose our loader hooks with another loader or additional logic
- `register()` accepts a ts-node `Service` ([API docs](https://typestrong.org/ts-node/api/index.html#register)) (#1474)
- `register(options)` is still supported; no breaking changes
- + 21 more
📋 Changes
- Fixes #1426: Do not import typescript outside of configuration/project loading (#1433, #1426) @Songkeys
- We take care to load your project's version of typescript, falling back to a globally-installed version if necessary.
- 10.2.0 introduced a bug where we did not do this consistently, causing global or npx installations of ts-node to attempt loading typescript relative to themselves, not your project.
- This failed if typescript was not globally installed or npx did not install peer dependencies.
📋 Changes
- Adds top-level await support to REPL (#1383, #245) @ejose19
- can be disabled with `--no-experimental-repl-await`, `experimentalReplAwait`, or `TS_NODE_EXPERIMENTAL_REPL_AWAIT` ([CLI docs](https://typestrong.org/ts-node/docs/options), [API docs](https://typestrong.org/ts-node/api/interfaces/CreateOptions.html#experimentalReplAwait))
- Setting `"pretty": false` disables pretty formatting of diagnostics even when stdout is a TTY (#1418, #1420) @elevatebart
- Applies to ts-node's `pretty` option, not to be confused with TypeScript's `pretty` option
- Ignores diagnostics which are annoying in an interactive REPL (#1396, #1120, #729, #850, #469)
- For example, when you input `const foo = 1` in the REPL, `foo` is unused. We ignore the resulting diagnostic `foo is declared but its value is never read`
- Diagnostics are only ignored in the REPL
- Diagnostics for non-REPL files imported by the REPL will still be shown
- + 7 more
📋 Changes
- Add `"moduleType"` option to override module type -- CommonJS or ECMAScript -- on select files. ([docs](https://typestrong.org/ts-node/docs/module-type-overrides)) (#1342, #1371, #1376)
- Useful when a configuration file, for example `webpack.config.ts`, must execute as CommonJS but the rest of the project is ESM
- selectively overrides `package.json` `"type"` and `tsconfig.json` `"module"`
- akin to `.cjs` and `.mjs` extensions, but for `.ts` and `.tsx` files
- thanks to @jayaddison for help on test coverage
- Implement `"extends"` support for `"ts-node"` options in `tsconfig.json` (#1328, #1356)
- `"ts-node": {}` options will be parsed from extended tsconfigs
- allows sharing and deduplicating ts-node configuration
- + 11 more
📋 Changes
- Adds `--show-config` to log the resolved configuration ([docs](https://typestrong.org/ts-node/docs/troubleshooting#understanding-configuration)) (#1100, #1243)
- Bundle and re-export @tsconfig/node* configurations for convenience ([docs](https://typestrong.org/ts-node/docs/configuration#tsconfigbases)) (#1202, #1236, #1313)
- Default to appropriate @tsconfig/node* configuration based on node and typescript versions ([docs](https://typestrong.org/ts-node/docs/configuration#default-config)) (#1202, #1236, #1313)
- Automatically reference @types/node; use globally-installed @types/node if not locally installed (#1240, #1257)
- Add `swc` integration and new `--transpiler` option to use third-party transpilers for a massive speed boost on large codebases ([docs](https://typestrong.org/ts-node/docs/transpilers)) (#779, #1160)
- Add `scopeDir` API option ([docs](https://typestrong.org/ts-node/api/interfaces/RegisterOptions.html#scopeDir)) (#1155)
- Add `projectSearchDir` API option ([docs](https://typestrong.org/ts-node/api/interfaces/RegisterOptions.html#projectSearchDir)) (#1155)
- Add `--cwd-mode` and `ts-node-cwd` to resolve config file relative to cwd, not entrypoint script (#1155)
- + 35 more
📋 Changes
- Published tarball had extra slashes in the paths of dist files. #1172
📋 Changes
- Expose ts-node REPL via the API (#1121) @MarcManiez
- Allow `--typeCheck` flag to override `--transpileOnly` flag specified in `tsconfig.json` (#1142)
- Rename interface `Register` to `Service`. It is still aliased as `Register` for backwards compatibility (#1158)
- Update code copied from node's ESM resolver to be the latest from node 15, to keep our ESM resolver's behavior as close as possible to vanilla node (#1167)
- ESM resolver will preserve search portion of URL, used for cache busting (#1165) @frandiox
- Fix ESM resolution of builtin modules on node >=14.13.1 (#1136)
- Recognize `--es-module-specifier-resolution` as an alias of `--experimental-specifier-resolution` for node 12 compatibility (#1122) @nguyensomniac
- Fix description of `ts-node-dev` in README (#1131) @iamandrewluca
- + 3 more
📋 Changes
- Throw `ERR_REQUIRE_ESM` when a file is `require()`d which should be loaded as ESM (#1031)
- Re-add `"exports"` declaration to package.json in backwards-compatible way, enabling `node --loader ts-node/esm` without file extension (#1028)
- Allow specifying `"require"` option via tsconfig (#925)
- REPL respects node's `NODE_NO_READLINE` environment variable (#1090)
- Add a transpile-only entrypoint for ESM loader: `node --loader ts-node/esm/transpile-only` (#1102) @concision
- [BREAKING] Drops support for node versions < 10 (#1036)
- [BREAKING] Re-add `realpath`, which should fix workflows that use symlinks, such as `pnpm`, Lerna workspaces, or other mono-repo configurations (#970)
- Compile files within `node_modules` when `--skip-ignore` or `--ignore` options are configured to allow it (#970)
- + 8 more
**Fixed** Fixes #1037: source maps broken on Windows. (#1038) **Misc** Fix failing tests on node 6 (#1035) Push coverage from Github Actions; remove TravisCI (#1034) Run tests e2e against an `npm pack && npm install`ed ts-node (#1032) Run CI tests on Windows (#1041) Run CI only once per commit on pull requests and master (#1042)
**Fix** Fixes #1026: revert the addition of package.json "exports" because it blocked `require()`s that used to work, for example `require('ts-node/register')` (#1027)
**Added** Experimental support for native ECMAScript modules in node >=13 (#1007, #1010)
**Fixed** Fix `--interactive` / `-i` flag so it forces REPL even when stdin is not a TTY (#1019)
**Fixed** Fix failing tests caused by recent changes to @types/node (#1016) Fix #945: Bump source-map-support dependency to include upstream fix for worker threads error handling (#1015) @addaleax Fix #1004: in `--scriptMode`, resolve config file relative to realpath of entrypoint script (#1009) Normalized filenames in cache to fix performance issues on Windows (#997) @sylc **Added** Add timestamps to debug logging (#994) @sylc **Docs** Improve coverage of the README (#1000) @KasparEtter Change order of install commands in README (#993) @jacobdcastro Mention `ts-node -vv` flag in issue template (#1001) Run GHActions tests on pull requests (#1017)
📋 Changes
- Avoid pushing to `rootFileNames` with version
📋 Changes
- Fix `--files` support be2c899
📋 Changes
- Add `sanitize=true` to README for SVGs to work on NPM
- Simplify `projectVersion++` by incrementing on each file change
- List all files for `getScriptFileNames` (#985) - revisits the change in https://github.com/TypeStrong/ts-node/issues/884
📋 Changes
- Remove buggy caching of `ts.sys.readDirectory` (#969)
- Fix REPL ASI handling when user input starts with `-` (#944)
- Implement `LanguageServiceHost::getProjectVersion` to workaround microsoft/TypeScript#36748 (#906
- Add `ts-node-transpile-only` binary (#939) @G-Rath
- Deprecate `ts-script` in favor of `ts-node-script` (#948) @G-Rath
- Fix bash syntax error in README (#943) @abraj
- Add Github issue templates (#959, #965, #947)
- Add IntelliJ debug instructions to README (#958)
- + 1 more
📋 Changes
- Downgrade `yn` due to node engine (#942)
📋 Changes
- Fix the resolution order of `TS_NODE_COMPILER_OPTIONS` - closes https://github.com/TypeStrong/ts-node/issues/938
