ts-checker-rspack-plugin 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -114,18 +114,19 @@ Options for the TypeScript checker (`typescript` option object).
|
|
|
114
114
|
| `mode` | `'readonly'` or `'write-dts'` or `'write-tsbuildinfo'` or `'write-references'` | `build === true ? 'write-tsbuildinfo' ? 'readonly'` | Use `readonly` if you don't want to write anything on the disk, `write-dts` to write only `.d.ts` files, `write-tsbuildinfo` to write only `.tsbuildinfo` files, `write-references` to write both `.js` and `.d.ts` files of project references (last 2 modes requires `build: true`). |
|
|
115
115
|
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
|
|
116
116
|
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
|
|
117
|
-
| `
|
|
117
|
+
| `resolveRoot` | `string` | `undefined` | Root used to resolve the default TypeScript package. Relative paths are resolved from `compiler.options.context`. Only used when `typescriptPath` is not set. |
|
|
118
|
+
| `typescriptPath` | `string` | `require.resolve('typescript/package.json')` for TypeScript 7+, `require.resolve('@typescript/native-preview/package.json')` when `tsgo` falls back to preview, otherwise `require.resolve('typescript')` | Custom TypeScript path. In `tsgo` mode, use an absolute path to `typescript/package.json` or `@typescript/native-preview/package.json`. |
|
|
118
119
|
| `tsgo` | `boolean` | `true` when TypeScript 7+ is detected, otherwise `false` | Enables experimental TypeScript Go support. The plugin runs the TypeScript Go checker binary in a child process. |
|
|
119
120
|
|
|
120
121
|
### TypeScript Go support
|
|
121
122
|
|
|
122
123
|
`typescript.tsgo` can reduce type-checking time by about 5-10x, especially on large projects, by using the Go implementation of TypeScript. It enables experimental [typescript-go](https://github.com/microsoft/typescript-go) support through TypeScript 7+ or [`@typescript/native-preview`](https://www.npmjs.com/package/@typescript/native-preview).
|
|
123
124
|
|
|
124
|
-
When the configured or default installed `typescript` package is major version 7 or higher, the plugin enables `typescript.tsgo` automatically and runs the TypeScript Go executable from that package. When `typescript.tsgo: true` is set without a custom `typescriptPath` and TypeScript 7+ is not installed, the plugin falls back to `@typescript/native-preview`.
|
|
125
|
+
When the configured or default installed `typescript` package is major version 7 or higher, the plugin enables `typescript.tsgo` automatically and runs the TypeScript Go executable from that package. The default package detection uses `typescript.resolveRoot` when it is set. When `typescript.tsgo: true` is set without a custom `typescriptPath` and TypeScript 7+ is not installed, the plugin falls back to `@typescript/native-preview`.
|
|
125
126
|
|
|
126
127
|
In this mode, the plugin runs the TypeScript Go binary in a child process, parses its diagnostics, and reports them through the existing issue formatter when possible. If the output cannot be parsed safely, the raw output is printed and the build fails when it exits with errors.
|
|
127
128
|
|
|
128
|
-
Supported options include `typescript.configFile`, `typescript.context`, `typescript.build`, `typescript.typescriptPath`, `async`, and `logger`. It also supports `tsconfig.json` compiler options used by `tsgo`, including `incremental` and `composite`.
|
|
129
|
+
Supported options include `typescript.configFile`, `typescript.context`, `typescript.build`, `typescript.resolveRoot`, `typescript.typescriptPath`, `async`, and `logger`. It also supports `tsconfig.json` compiler options used by `tsgo`, including `incremental` and `composite`.
|
|
129
130
|
|
|
130
131
|
Install TypeScript 7.0 RC to enable `tsgo` automatically:
|
|
131
132
|
|
package/lib/index.js
CHANGED
|
@@ -4444,16 +4444,23 @@ var __webpack_exports__ = {};
|
|
|
4444
4444
|
defaultSeverity
|
|
4445
4445
|
};
|
|
4446
4446
|
}
|
|
4447
|
-
function
|
|
4447
|
+
function resolveModule(request, resolveRoot) {
|
|
4448
|
+
return resolveRoot ? require.resolve(request, {
|
|
4449
|
+
paths: [
|
|
4450
|
+
resolveRoot
|
|
4451
|
+
]
|
|
4452
|
+
}) : require.resolve(request);
|
|
4453
|
+
}
|
|
4454
|
+
function resolveInstalledTsgoPackage(resolveRoot) {
|
|
4448
4455
|
try {
|
|
4449
|
-
const packageJsonPath =
|
|
4456
|
+
const packageJsonPath = resolveModule(TYPESCRIPT_PACKAGE_JSON, resolveRoot);
|
|
4450
4457
|
const tsgoPackage = resolveTypeScriptGoPackage(packageJsonPath);
|
|
4451
4458
|
if (tsgoPackage?.tsgoPackage === "typescript") return tsgoPackage;
|
|
4452
4459
|
} catch {}
|
|
4453
4460
|
}
|
|
4454
|
-
function resolveDefaultPreviewPackageJsonPath() {
|
|
4461
|
+
function resolveDefaultPreviewPackageJsonPath(resolveRoot) {
|
|
4455
4462
|
try {
|
|
4456
|
-
return
|
|
4463
|
+
return resolveModule(TYPESCRIPT_PREVIEW_PACKAGE_JSON, resolveRoot);
|
|
4457
4464
|
} catch {
|
|
4458
4465
|
return TYPESCRIPT_PREVIEW_PACKAGE_JSON;
|
|
4459
4466
|
}
|
|
@@ -4473,46 +4480,53 @@ var __webpack_exports__ = {};
|
|
|
4473
4480
|
};
|
|
4474
4481
|
}
|
|
4475
4482
|
if (false === options.tsgo) return {
|
|
4476
|
-
typescriptPath:
|
|
4483
|
+
typescriptPath: resolveModule("typescript", options.resolveRoot),
|
|
4477
4484
|
tsgo: false
|
|
4478
4485
|
};
|
|
4479
|
-
const
|
|
4480
|
-
if (
|
|
4481
|
-
typescriptPath:
|
|
4486
|
+
const installedTsgoPackage = resolveInstalledTsgoPackage(options.resolveRoot);
|
|
4487
|
+
if (installedTsgoPackage) return {
|
|
4488
|
+
typescriptPath: installedTsgoPackage.packageJsonPath,
|
|
4482
4489
|
tsgo: true,
|
|
4483
4490
|
tsgoPackage: "typescript"
|
|
4484
4491
|
};
|
|
4485
4492
|
if (true === options.tsgo) return {
|
|
4486
|
-
typescriptPath: resolveDefaultPreviewPackageJsonPath(),
|
|
4493
|
+
typescriptPath: resolveDefaultPreviewPackageJsonPath(options.resolveRoot),
|
|
4487
4494
|
tsgo: true,
|
|
4488
4495
|
tsgoPackage: 'preview'
|
|
4489
4496
|
};
|
|
4490
4497
|
return {
|
|
4491
|
-
typescriptPath:
|
|
4498
|
+
typescriptPath: resolveModule("typescript", options.resolveRoot)
|
|
4492
4499
|
};
|
|
4493
4500
|
}
|
|
4494
4501
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
4495
4502
|
let configFile = 'object' == typeof options ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
|
|
4496
4503
|
configFile = external_node_path_default().normalize(external_node_path_default().isAbsolute(configFile) ? configFile : external_node_path_default().resolve(compiler.options.context || process.cwd(), configFile));
|
|
4497
4504
|
const optionsAsObject = 'object' == typeof options ? options : {};
|
|
4498
|
-
const
|
|
4505
|
+
const resolveRoot = optionsAsObject.resolveRoot ? external_node_path_default().isAbsolute(optionsAsObject.resolveRoot) ? optionsAsObject.resolveRoot : external_node_path_default().resolve(compiler.options.context || process.cwd(), optionsAsObject.resolveRoot) : void 0;
|
|
4506
|
+
const normalizedOptions = {
|
|
4507
|
+
...optionsAsObject,
|
|
4508
|
+
...resolveRoot ? {
|
|
4509
|
+
resolveRoot
|
|
4510
|
+
} : {}
|
|
4511
|
+
};
|
|
4512
|
+
const typescriptRuntimeConfig = resolveTypeScriptRuntimeConfig(normalizedOptions);
|
|
4499
4513
|
return {
|
|
4500
4514
|
enabled: Boolean(options) || void 0 === options,
|
|
4501
4515
|
memoryLimit: 8192,
|
|
4502
4516
|
build: false,
|
|
4503
4517
|
mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
|
|
4504
4518
|
profile: false,
|
|
4505
|
-
...
|
|
4519
|
+
...normalizedOptions,
|
|
4506
4520
|
...typescriptRuntimeConfig,
|
|
4507
4521
|
configFile: configFile,
|
|
4508
|
-
configOverwrite:
|
|
4509
|
-
context:
|
|
4522
|
+
configOverwrite: normalizedOptions.configOverwrite || {},
|
|
4523
|
+
context: normalizedOptions.context || external_node_path_default().dirname(configFile),
|
|
4510
4524
|
diagnosticOptions: {
|
|
4511
4525
|
syntactic: false,
|
|
4512
4526
|
semantic: true,
|
|
4513
4527
|
declaration: false,
|
|
4514
4528
|
global: false,
|
|
4515
|
-
...
|
|
4529
|
+
...normalizedOptions.diagnosticOptions || {}
|
|
4516
4530
|
}
|
|
4517
4531
|
};
|
|
4518
4532
|
}
|
|
@@ -13,6 +13,7 @@ interface TypeScriptWorkerConfig {
|
|
|
13
13
|
mode: 'readonly' | 'write-dts' | 'write-tsbuildinfo' | 'write-references';
|
|
14
14
|
diagnosticOptions: TypeScriptDiagnosticsOptions;
|
|
15
15
|
profile: boolean;
|
|
16
|
+
resolveRoot?: string;
|
|
16
17
|
typescriptPath: string;
|
|
17
18
|
tsgo?: boolean;
|
|
18
19
|
tsgoPackage?: TypeScriptGoPackage;
|
|
@@ -9,6 +9,7 @@ type TypeScriptWorkerOptions = {
|
|
|
9
9
|
mode?: 'readonly' | 'write-tsbuildinfo' | 'write-dts' | 'write-references';
|
|
10
10
|
diagnosticOptions?: Partial<TypeScriptDiagnosticsOptions>;
|
|
11
11
|
profile?: boolean;
|
|
12
|
+
resolveRoot?: string;
|
|
12
13
|
typescriptPath?: string;
|
|
13
14
|
tsgo?: boolean;
|
|
14
15
|
};
|