diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4fd76c31e..64af4bda5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,7 +51,7 @@ jobs: matrix: os: [ubuntu, windows] # Don't forget to add all new flavors to this list! - flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] + flavor: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] include: # Node 12.15 - flavor: 1 @@ -95,64 +95,47 @@ jobs: nodeFlag: 14 typescript: next typescriptFlag: next - - flavor: 8 - node: 14 - nodeFlag: 14 - typescript: rc - typescriptFlag: rc # Node 16 # Node 16.11.1 # Earliest version that supports old ESM Loader Hooks API: https://github.com/TypeStrong/ts-node/pull/1522 - - flavor: 9 + - flavor: 8 node: 16.11.1 nodeFlag: 16_11_1 typescript: latest typescriptFlag: latest - - flavor: 10 + - flavor: 9 node: 16 nodeFlag: 16 typescript: latest typescriptFlag: latest downgradeNpm: true - - flavor: 11 + - flavor: 10 node: 16 nodeFlag: 16 typescript: 2.7 typescriptFlag: 2_7 downgradeNpm: true - - flavor: 12 + - flavor: 11 node: 16 nodeFlag: 16 typescript: next typescriptFlag: next downgradeNpm: true - - flavor: 13 - node: 16 - nodeFlag: 16 - typescript: rc - typescriptFlag: rc - downgradeNpm: true # Node 18 - - flavor: 14 + - flavor: 12 node: 18 nodeFlag: 18 typescript: latest typescriptFlag: latest downgradeNpm: true - - flavor: 15 + - flavor: 13 node: 18 nodeFlag: 18 typescript: next typescriptFlag: next downgradeNpm: true - - flavor: 16 - node: 18 - nodeFlag: 18 - typescript: rc - typescriptFlag: rc - downgradeNpm: true # Node nightly - - flavor: 17 + - flavor: 14 node: nightly nodeFlag: nightly typescript: latest diff --git a/README.md b/README.md index 56296e0e8..a08d36481 100644 --- a/README.md +++ b/README.md @@ -285,8 +285,8 @@ You can use this sample configuration as a starting point: ```jsonc title="tsconfig.json" { - // This is an alias to @tsconfig/node12: https://github.com/tsconfig/bases - "extends": "ts-node/node12/tsconfig.json", + // This is an alias to @tsconfig/node16: https://github.com/tsconfig/bases + "extends": "ts-node/node16/tsconfig.json", // Most ts-node options can be specified here using their programmatic names. "ts-node": { @@ -675,7 +675,7 @@ ts-node --scope Scope compiler to files within `scopeDir`. Anything outside this directory is ignored. -\*Default: `false`
+*Default:* `false`
*Environment:* `TS_NODE_SCOPE` ### scopeDir @@ -721,10 +721,12 @@ Disable top-level await in REPL. Equivalent to node's [`--no-experimental-repl- Enable experimental hooks that re-map imports and require calls to support: -* resolves `.js` to `.ts`, so that `import "./foo.js"` will execute `foo.ts` -* resolves `.cjs` to `.cts` -* resolves `.mjs` to `.mts` -* allows including file extensions in CommonJS, for consistency with ESM where this is often mandatory +* remapping extensions, e.g. so that `import "./foo.js"` will execute `foo.ts`. Currently the following extensions will be mapped: + * `.js` to `.ts`, `.tsx`, or `.jsx` + * `.cjs` to `.cts` + * `.mjs` to `.mts` + * `.jsx` to `.tsx` +* including file extensions in CommonJS, for consistency with ESM where this is often mandatory In the future, this hook will also support: @@ -744,7 +746,7 @@ ts-node --experimentalSpecifierResolution node ``` Like node's [`--experimental-specifier-resolution`](https://nodejs.org/dist/latest-v18.x/docs/api/esm.html#customizing-esm-specifier-resolution-algorithm), but can also be set in your `tsconfig.json` for convenience. -Requires `esm` to be enabled. +Requires [`esm`](#esm) to be enabled. *Default:* `explicit`
@@ -1059,7 +1061,7 @@ It is often better to use `tsc --noEmit` to typecheck as part of your tests or l * Enable [swc](#swc) * This is by far the fastest option -* Enable [`transpileOnly`](#options) to skip typechecking without swc +* Enable [`transpileOnly`](#transpileonly) to skip typechecking without swc ## With typechecking @@ -1189,7 +1191,7 @@ sourcemap support, and global ts-node CLI. Plugins automatically derive an appro The `transpiler` option allows using third-party transpiler plugins with ts-node. `transpiler` must be given the name of a module which can be `require()`d. The built-in `swc` plugin is exposed as `ts-node/transpilers/swc`. -For example, to use a hypothetical "speedy-ts-compiler", first install it into your project: `npm install speedy-ts-compiler` +For example, to use a hypothetical "@cspotcode/fast-ts-compiler", first install it into your project: `npm install @cspotcode/fast-ts-compiler` Then add the following to your tsconfig: @@ -1197,7 +1199,7 @@ Then add the following to your tsconfig: { "ts-node": { "transpileOnly": true, - "transpiler": "speedy-ts-compiler" + "transpiler": "@cspotcode/fast-ts-compiler" } } ``` diff --git a/api-extractor/ts-node.api.md b/api-extractor/ts-node.api.md index b5b8af2fe..9e16ce1d0 100644 --- a/api-extractor/ts-node.api.md +++ b/api-extractor/ts-node.api.md @@ -294,7 +294,7 @@ export interface TSCommon { // (undocumented) resolveModuleNameFromCache: typeof _ts.resolveModuleNameFromCache; // (undocumented) - resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: _ts.CompilerOptions, host: _ts.ModuleResolutionHost, redirectedReference?: _ts.ResolvedProjectReference, cache?: _ts.TypeReferenceDirectiveResolutionCache, resolutionMode?: _ts.SourceFile['impliedNodeFormat']): _ts.ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + resolveTypeReferenceDirective: typeof _ts.resolveTypeReferenceDirective; // (undocumented) ScriptSnapshot: typeof _ts.ScriptSnapshot; // (undocumented) @@ -315,8 +315,13 @@ export namespace TSCommon { export type FileReference = _ts.FileReference; // (undocumented) export interface LanguageServiceHost extends _ts.LanguageServiceHost { + } + // (undocumented) + export namespace ModuleKind { + // (undocumented) + export type CommonJS = _ts.ModuleKind.CommonJS; // (undocumented) - resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | _ts.FileReference[], containingFile: string, redirectedReference: _ts.ResolvedProjectReference | undefined, options: _ts.CompilerOptions, containingFileMode?: _ts.SourceFile['impliedNodeFormat'] | undefined): (_ts.ResolvedTypeReferenceDirective | undefined)[]; + export type ESNext = _ts.ModuleKind.ESNext; } // (undocumented) export type ModuleKindEnum = typeof _ts.ModuleKind & { diff --git a/package-lock.json b/package-lock.json index 825e70c72..9722c5fd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ts-node", - "version": "10.8.0", + "version": "10.8.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -4670,9 +4670,9 @@ } }, "typescript": { - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "version": "4.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.2.tgz", + "integrity": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A==", "dev": true }, "typescript-json-schema": { diff --git a/package.json b/package.json index 2eeb8f6a3..96cc40187 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-node", - "version": "10.8.0", + "version": "10.8.1", "description": "TypeScript execution environment and REPL for node.js, with source map support", "main": "dist/index.js", "exports": { @@ -138,7 +138,7 @@ "semver": "^7.1.3", "throat": "^6.0.1", "typedoc": "^0.22.10", - "typescript": "4.6.4", + "typescript": "4.7.2", "typescript-json-schema": "^0.53.0", "util.promisify": "^1.0.1" }, diff --git a/src/index.ts b/src/index.ts index 607d5976d..799731f2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ -import { relative, basename, extname, dirname, join } from 'path'; +import { relative, basename, extname, dirname, join, isAbsolute } from 'path'; import { Module } from 'module'; import * as util from 'util'; -import { fileURLToPath } from 'url'; +import { fileURLToPath, pathToFileURL } from 'url'; import type * as _sourceMapSupport from '@cspotcode/source-map-support'; import { BaseError } from 'make-error'; @@ -1667,8 +1667,11 @@ function updateOutput( */ function updateSourceMap(sourceMapText: string, fileName: string) { const sourceMap = JSON.parse(sourceMapText); - sourceMap.file = fileName; - sourceMap.sources = [fileName]; + const outputFileName = isAbsolute(fileName) + ? pathToFileURL(fileName).href + : fileName; + sourceMap.file = outputFileName; + sourceMap.sources = [outputFileName]; delete sourceMap.sourceRoot; return JSON.stringify(sourceMap); } diff --git a/src/resolver-functions.ts b/src/resolver-functions.ts index 9884c29c8..afe13b463 100644 --- a/src/resolver-functions.ts +++ b/src/resolver-functions.ts @@ -95,16 +95,24 @@ export function createResolverFunctions(kwargs: { containingFile: string, reusedNames: string[] | undefined, redirectedReference: TSCommon.ResolvedProjectReference | undefined, - optionsOnlyWithNewerTsVersions: TSCommon.CompilerOptions + optionsOnlyWithNewerTsVersions: TSCommon.CompilerOptions, + containingSourceFile?: TSCommon.SourceFile ): (TSCommon.ResolvedModule | undefined)[] => { - return moduleNames.map((moduleName) => { + return moduleNames.map((moduleName, i) => { + const mode = containingSourceFile + ? (ts as any as TSInternal).getModeForResolutionAtIndex?.( + containingSourceFile, + i + ) + : undefined; const { resolvedModule } = ts.resolveModuleName( moduleName, containingFile, config.options, host, moduleResolutionCache, - redirectedReference + redirectedReference, + mode ); if (resolvedModule) { fixupResolvedModule(resolvedModule); @@ -117,12 +125,14 @@ export function createResolverFunctions(kwargs: { const getResolvedModuleWithFailedLookupLocationsFromCache: TSCommon.LanguageServiceHost['getResolvedModuleWithFailedLookupLocationsFromCache'] = ( moduleName, - containingFile + containingFile, + resolutionMode?: TSCommon.ModuleKind.CommonJS | TSCommon.ModuleKind.ESNext ): TSCommon.ResolvedModuleWithFailedLookupLocations | undefined => { const ret = ts.resolveModuleNameFromCache( moduleName, containingFile, - moduleResolutionCache + moduleResolutionCache, + resolutionMode ); if (ret && ret.resolvedModule) { fixupResolvedModule(ret.resolvedModule); diff --git a/src/test/helpers.ts b/src/test/helpers.ts index 0a58c5a6b..08392a29e 100644 --- a/src/test/helpers.ts +++ b/src/test/helpers.ts @@ -68,6 +68,14 @@ export const nodeSupportsImportAssertions = semver.gte( process.version, '17.1.0' ); +// Node 14.13.0 has a bug where it tries to lex CJS files to discover named exports *before* +// we transform the code. +// In other words, it tries to parse raw TS as CJS and balks at `export const foo =`, expecting to see `exports.foo =` +// This lexing only happens when CJS TS is imported from the ESM loader. +export const nodeSupportsImportingTransformedCjsFromEsm = semver.gte( + process.version, + '14.13.1' +); /** Supports tsconfig "extends" >= v3.2.0 */ export const tsSupportsTsconfigInheritanceViaNodePackages = semver.gte( ts.version, diff --git a/src/test/module-node/1778.spec.ts b/src/test/module-node/1778.spec.ts new file mode 100644 index 000000000..43d65e0f7 --- /dev/null +++ b/src/test/module-node/1778.spec.ts @@ -0,0 +1,38 @@ +import { createExec } from '../exec-helpers'; +import { + ctxTsNode, + nodeSupportsEsmHooks, + TEST_DIR, + tsSupportsStableNodeNextNode16, + CMD_TS_NODE_WITHOUT_PROJECT_FLAG, + nodeSupportsSpawningChildProcess, +} from '../helpers'; +import { context, expect } from '../testlib'; +import { join } from 'path'; + +const exec = createExec({ + cwd: TEST_DIR, +}); + +const test = context(ctxTsNode); + +test.suite( + 'Issue #1778: typechecker resolver should take importer\'s module type -- cjs or esm -- into account when resolving package.json "exports"', + (test) => { + test.runIf( + nodeSupportsEsmHooks && + nodeSupportsSpawningChildProcess && + tsSupportsStableNodeNextNode16 + ); + test('test', async () => { + const { err, stdout } = await exec( + `${CMD_TS_NODE_WITHOUT_PROJECT_FLAG} ./index.ts`, + { + cwd: join(TEST_DIR, '1778'), + } + ); + expect(err).toBe(null); + expect(stdout).toBe('{ esm: true }\n'); + }); + } +); diff --git a/src/test/module-node.spec.ts b/src/test/module-node/module-node.spec.ts similarity index 95% rename from src/test/module-node.spec.ts rename to src/test/module-node/module-node.spec.ts index b182444ea..7ebb3fd4c 100644 --- a/src/test/module-node.spec.ts +++ b/src/test/module-node/module-node.spec.ts @@ -1,14 +1,15 @@ -import { expect, context } from './testlib'; +import { expect, context } from '../testlib'; import { CMD_TS_NODE_WITHOUT_PROJECT_FLAG, isOneOf, + nodeSupportsImportingTransformedCjsFromEsm, resetNodeEnvironment, tsSupportsStableNodeNextNode16, -} from './helpers'; +} from '../helpers'; import * as Path from 'path'; -import { ctxTsNode } from './helpers'; -import { exec } from './exec-helpers'; -import { file, project, ProjectAPI as ProjectAPI } from './fs-helpers'; +import { ctxTsNode } from '../helpers'; +import { exec } from '../exec-helpers'; +import { file, project, ProjectAPI as ProjectAPI } from '../fs-helpers'; const test = context(ctxTsNode); test.beforeEach(async () => { @@ -18,7 +19,9 @@ type Test = typeof test; // Declare one test case for each permutations of project configuration test.suite('TypeScript module=NodeNext and Node16', (test) => { - test.runIf(tsSupportsStableNodeNextNode16); + test.runIf( + tsSupportsStableNodeNextNode16 && nodeSupportsImportingTransformedCjsFromEsm + ); for (const allowJs of [true, false]) { for (const typecheckMode of [ @@ -63,6 +66,7 @@ function declareTest(test: Test, testParams: TestParams) { t.log(stdout); t.log(stderr); expect(err).toBe(null); + expect(stdout).toMatch(/done\n$/); }); } @@ -216,6 +220,8 @@ function writeFixturesToFilesystem(name: string, testParams: TestParams) { } } + indexFile.content += `console.log('done');\n`; + proj.rm(); proj.write(); return proj; diff --git a/src/ts-compiler-types.ts b/src/ts-compiler-types.ts index 2f961b853..9077d4f99 100644 --- a/src/ts-compiler-types.ts +++ b/src/ts-compiler-types.ts @@ -32,16 +32,7 @@ export interface TSCommon { createModuleResolutionCache: typeof _ts.createModuleResolutionCache; resolveModuleName: typeof _ts.resolveModuleName; resolveModuleNameFromCache: typeof _ts.resolveModuleNameFromCache; - // Changed in TS 4.7 - resolveTypeReferenceDirective( - typeReferenceDirectiveName: string, - containingFile: string | undefined, - options: _ts.CompilerOptions, - host: _ts.ModuleResolutionHost, - redirectedReference?: _ts.ResolvedProjectReference, - cache?: _ts.TypeReferenceDirectiveResolutionCache, - resolutionMode?: _ts.SourceFile['impliedNodeFormat'] - ): _ts.ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + resolveTypeReferenceDirective: typeof _ts.resolveTypeReferenceDirective; createIncrementalCompilerHost: typeof _ts.createIncrementalCompilerHost; createSourceFile: typeof _ts.createSourceFile; getDefaultLibFileName: typeof _ts.getDefaultLibFileName; @@ -52,16 +43,7 @@ export interface TSCommon { ModuleResolutionKind: typeof _ts.ModuleResolutionKind; } export namespace TSCommon { - export interface LanguageServiceHost extends _ts.LanguageServiceHost { - // Modified in 4.7 - resolveTypeReferenceDirectives?( - typeDirectiveNames: string[] | _ts.FileReference[], - containingFile: string, - redirectedReference: _ts.ResolvedProjectReference | undefined, - options: _ts.CompilerOptions, - containingFileMode?: _ts.SourceFile['impliedNodeFormat'] | undefined - ): (_ts.ResolvedTypeReferenceDirective | undefined)[]; - } + export interface LanguageServiceHost extends _ts.LanguageServiceHost {} export type ModuleResolutionHost = _ts.ModuleResolutionHost; export type ParsedCommandLine = _ts.ParsedCommandLine; export type ResolvedModule = _ts.ResolvedModule; @@ -79,6 +61,12 @@ export namespace TSCommon { ? typeof _ts.ModuleKind['Node16'] : 100; }; + // Can't figure out how to re-export an enum + // `export import ... =` complains that _ts is type-only import + export namespace ModuleKind { + export type CommonJS = _ts.ModuleKind.CommonJS; + export type ESNext = _ts.ModuleKind.ESNext; + } } /** @@ -129,6 +117,11 @@ export interface TSInternal { basePath: string, usage: 'files' | 'directories' | 'exclude' ): string | undefined; + // Added in TS 4.7 + getModeForResolutionAtIndex?( + file: TSInternal.SourceFileImportsList, + index: number + ): _ts.SourceFile['impliedNodeFormat']; } /** @internal */ export namespace TSInternal { @@ -139,4 +132,8 @@ export namespace TSInternal { getCurrentDirectory(): string; useCaseSensitiveFileNames: boolean; } + // Note: is only a partial declaration, TS sources declare other fields + export interface SourceFileImportsList { + impliedNodeFormat?: TSCommon.SourceFile['impliedNodeFormat']; + } } diff --git a/tests/1778/index.ts b/tests/1778/index.ts new file mode 100644 index 000000000..ace4327b7 --- /dev/null +++ b/tests/1778/index.ts @@ -0,0 +1,6 @@ +import foo from 'foo'; + +// This file is ESM, so if typechecker's resolver is working correctly, will +// resolve to the foo's package.json "exports" mapping for "default", not "require" +const bar: { esm: true } = foo; +console.log(bar); diff --git a/tests/1778/node_modules/foo/cjs/index.d.ts b/tests/1778/node_modules/foo/cjs/index.d.ts new file mode 100644 index 000000000..a84bc1bc3 --- /dev/null +++ b/tests/1778/node_modules/foo/cjs/index.d.ts @@ -0,0 +1,2 @@ +declare const foo: {cjs: true} +export default foo diff --git a/tests/1778/node_modules/foo/cjs/index.js b/tests/1778/node_modules/foo/cjs/index.js new file mode 100644 index 000000000..9a4be3c24 --- /dev/null +++ b/tests/1778/node_modules/foo/cjs/index.js @@ -0,0 +1 @@ +module.exports = {cjs: true} diff --git a/tests/1778/node_modules/foo/cjs/package.json b/tests/1778/node_modules/foo/cjs/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/tests/1778/node_modules/foo/cjs/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/tests/1778/node_modules/foo/esm/index.d.ts b/tests/1778/node_modules/foo/esm/index.d.ts new file mode 100644 index 000000000..1da8fb3af --- /dev/null +++ b/tests/1778/node_modules/foo/esm/index.d.ts @@ -0,0 +1,2 @@ +declare const foo: {esm: true} +export default foo diff --git a/tests/1778/node_modules/foo/esm/index.js b/tests/1778/node_modules/foo/esm/index.js new file mode 100644 index 000000000..2b573c6c7 --- /dev/null +++ b/tests/1778/node_modules/foo/esm/index.js @@ -0,0 +1 @@ +export default {esm: true} diff --git a/tests/1778/node_modules/foo/package.json b/tests/1778/node_modules/foo/package.json new file mode 100644 index 000000000..e12814a53 --- /dev/null +++ b/tests/1778/node_modules/foo/package.json @@ -0,0 +1,9 @@ +{ + "type": "module", + "exports": { + ".": { + "require": "./cjs/index.js", + "default": "./esm/index.js" + } + } +} diff --git a/tests/1778/package.json b/tests/1778/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/tests/1778/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/tests/1778/tsconfig.json b/tests/1778/tsconfig.json new file mode 100644 index 000000000..1ec416b41 --- /dev/null +++ b/tests/1778/tsconfig.json @@ -0,0 +1,9 @@ +{ + "ts-node": { + "esm": true + }, + "compilerOptions": { + "module": "NodeNext", + "noEmit": true + } +} diff --git a/tsdoc.json b/tsdoc.json index 0316a4fcc..501e2ea59 100644 --- a/tsdoc.json +++ b/tsdoc.json @@ -21,6 +21,11 @@ "tagName": "@allOf", "syntaxKind": "block", "allowMultiple": false + }, + { + "tagName": "@category", + "syntaxKind": "inline", + "allowMultiple": false } ] } diff --git a/website/docs/configuration.md b/website/docs/configuration.md index 130a69eba..9e6f9b948 100644 --- a/website/docs/configuration.md +++ b/website/docs/configuration.md @@ -27,8 +27,8 @@ You can use this sample configuration as a starting point: ```json title="tsconfig.json" { - // This is an alias to @tsconfig/node12: https://github.com/tsconfig/bases - "extends": "ts-node/node12/tsconfig.json", + // This is an alias to @tsconfig/node16: https://github.com/tsconfig/bases + "extends": "ts-node/node16/tsconfig.json", // Most ts-node options can be specified here using their programmatic names. "ts-node": { diff --git a/website/docs/options.md b/website/docs/options.md index 2ddf09fb9..0c59f203b 100644 --- a/website/docs/options.md +++ b/website/docs/options.md @@ -328,7 +328,7 @@ ts-node --scope Scope compiler to files within `scopeDir`. Anything outside this directory is ignored. -*Default: `false`
+*Default:* `false`
*Environment:* `TS_NODE_SCOPE` ### scopeDir @@ -374,10 +374,12 @@ Disable top-level await in REPL. Equivalent to node's [`--no-experimental-repl- Enable experimental hooks that re-map imports and require calls to support: -* resolves `.js` to `.ts`, so that `import "./foo.js"` will execute `foo.ts` -* resolves `.cjs` to `.cts` -* resolves `.mjs` to `.mts` -* allows including file extensions in CommonJS, for consistency with ESM where this is often mandatory +* remapping extensions, e.g. so that `import "./foo.js"` will execute `foo.ts`. Currently the following extensions will be mapped: + * `.js` to `.ts`, `.tsx`, or `.jsx` + * `.cjs` to `.cts` + * `.mjs` to `.mts` + * `.jsx` to `.tsx` +* including file extensions in CommonJS, for consistency with ESM where this is often mandatory In the future, this hook will also support: @@ -397,7 +399,7 @@ ts-node --experimentalSpecifierResolution node ``` Like node's [`--experimental-specifier-resolution`](https://nodejs.org/dist/latest-v18.x/docs/api/esm.html#customizing-esm-specifier-resolution-algorithm), but can also be set in your `tsconfig.json` for convenience. -Requires `esm` to be enabled. +Requires [`esm`](#esm) to be enabled. *Default:* `explicit`
diff --git a/website/docs/performance.md b/website/docs/performance.md index aebc50def..21704761e 100644 --- a/website/docs/performance.md +++ b/website/docs/performance.md @@ -8,9 +8,9 @@ These tricks will make ts-node faster. It is often better to use `tsc --noEmit` to typecheck as part of your tests or linting. In these cases, ts-node can skip typechecking. -* Enable [swc](./transpilers.md#swc) +* Enable [swc](./swc.md) * This is by far the fastest option -* Enable [`transpileOnly`](./options.md) to skip typechecking without swc +* Enable [`transpileOnly`](./options.md#transpileonly) to skip typechecking without swc ## With typechecking diff --git a/website/docs/transpilers.md b/website/docs/transpilers.md index 2274bf554..4371a864c 100644 --- a/website/docs/transpilers.md +++ b/website/docs/transpilers.md @@ -17,7 +17,7 @@ sourcemap support, and global ts-node CLI. Plugins automatically derive an appro The `transpiler` option allows using third-party transpiler plugins with ts-node. `transpiler` must be given the name of a module which can be `require()`d. The built-in `swc` plugin is exposed as `ts-node/transpilers/swc`. -For example, to use a hypothetical "speedy-ts-compiler", first install it into your project: `npm install speedy-ts-compiler` +For example, to use a hypothetical "@cspotcode/fast-ts-compiler", first install it into your project: `npm install @cspotcode/fast-ts-compiler` Then add the following to your tsconfig: @@ -25,7 +25,7 @@ Then add the following to your tsconfig: { "ts-node": { "transpileOnly": true, - "transpiler": "speedy-ts-compiler" + "transpiler": "@cspotcode/fast-ts-compiler" } } ```