ts-checker-rspack-plugin 1.5.0 → 1.5.2

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,30 +114,31 @@ 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
- | `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')` | If supplied this is a custom path where TypeScript can be found. In `tsgo` mode, it must be an absolute path to `typescript/package.json` from TypeScript 7+ or `@typescript/native-preview/package.json`. |
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
- Install TypeScript 7.0 RC to enable `tsgo` automatically:
131
+ Install the latest TypeScript to enable `tsgo` automatically:
131
132
 
132
133
  ```sh
133
134
  # with npm
134
- npm install -D typescript@rc
135
+ npm install -D typescript@latest
135
136
 
136
137
  # with yarn
137
- yarn add -D typescript@rc
138
+ yarn add -D typescript@latest
138
139
 
139
140
  # with pnpm
140
- pnpm add -D typescript@rc
141
+ pnpm add -D typescript@latest
141
142
  ```
142
143
 
143
144
  Or install `@typescript/native-preview` and enable `tsgo` explicitly:
@@ -161,7 +162,7 @@ new TsCheckerRspackPlugin({
161
162
  });
162
163
  ```
163
164
 
164
- > The `@typescript/native-preview` usage is deprecated and kept only for compatibility. We recommend installing `typescript@rc` to use `tsgo`.
165
+ > The `@typescript/native-preview` usage is deprecated and kept only for compatibility. We recommend installing `typescript@latest` to use `tsgo`.
165
166
 
166
167
  Limitations:
167
168
 
package/lib/index.js CHANGED
@@ -3726,7 +3726,7 @@ var __webpack_exports__ = {};
3726
3726
  const TYPESCRIPT_PREVIEW_PACKAGE_JSON = `${TYPESCRIPT_PREVIEW_PACKAGE}/package.json`;
3727
3727
  function resolveTypeScriptGoPackageJsonPath(config) {
3728
3728
  if (!external_node_path_default().isAbsolute(config.typescriptPath) || 'package.json' !== external_node_path_default().basename(config.typescriptPath)) throw new Error("The typescriptPath option must be an absolute path to a package.json file when tsgo is enabled.");
3729
- if (!config.tsgoPackage) throw new Error(`The typescriptPath option must point to "${TYPESCRIPT_PREVIEW_PACKAGE_JSON}" or "${TYPESCRIPT_PACKAGE}@rc".`);
3729
+ if (!config.tsgoPackage) throw new Error(`The typescriptPath option must point to "${TYPESCRIPT_PREVIEW_PACKAGE_JSON}" or "${TYPESCRIPT_PACKAGE}@latest".`);
3730
3730
  return config.typescriptPath;
3731
3731
  }
3732
3732
  async function resolveTypeScriptGoNativeExecutablePath(packageJsonPath, packageName) {
@@ -4184,11 +4184,11 @@ var __webpack_exports__ = {};
4184
4184
  }
4185
4185
  function createTypeScriptGoSupportError(config, error) {
4186
4186
  const message = [
4187
- `When you enable TsCheckerRspackPlugin with \`typescript.tsgo\`, you must install \`${TYPESCRIPT_PACKAGE}@rc\` or \`${TYPESCRIPT_PREVIEW_PACKAGE}\` package.`
4187
+ `When you enable TsCheckerRspackPlugin with \`typescript.tsgo\`, you must install \`${TYPESCRIPT_PACKAGE}@latest\` or \`${TYPESCRIPT_PREVIEW_PACKAGE}\` package.`
4188
4188
  ];
4189
- if (!isDefaultTypeScriptGoPath(config.typescriptPath)) message.push(`If you set \`typescript.typescriptPath\`, it must be an absolute path to \`${TYPESCRIPT_PACKAGE_JSON}\` from \`${TYPESCRIPT_PACKAGE}@rc\` or \`${TYPESCRIPT_PREVIEW_PACKAGE_JSON}\`.`);
4189
+ if (!isDefaultTypeScriptGoPath(config.typescriptPath)) message.push(`If you set \`typescript.typescriptPath\`, it must be an absolute path to \`${TYPESCRIPT_PACKAGE_JSON}\` from \`${TYPESCRIPT_PACKAGE}@latest\` or \`${TYPESCRIPT_PREVIEW_PACKAGE_JSON}\`.`);
4190
4190
  if (error instanceof Error && error.message) message.push(`Failed to resolve the tsgo executable: ${error.message}`);
4191
- message.push(`You can install it with \`npm add ${TYPESCRIPT_PACKAGE}@rc -D\` or \`npm add ${TYPESCRIPT_PREVIEW_PACKAGE} -D\`.`);
4191
+ message.push(`You can install it with \`npm add ${TYPESCRIPT_PACKAGE}@latest -D\` or \`npm add ${TYPESCRIPT_PREVIEW_PACKAGE} -D\`.`);
4192
4192
  return new Error(message.join(external_node_os_default().EOL));
4193
4193
  }
4194
4194
  function assertTypeScriptGoSupport(config) {
@@ -4444,16 +4444,23 @@ var __webpack_exports__ = {};
4444
4444
  defaultSeverity
4445
4445
  };
4446
4446
  }
4447
- function resolveInstalledTypeScriptPackageForTsgo() {
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 = require.resolve(TYPESCRIPT_PACKAGE_JSON);
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 require.resolve(TYPESCRIPT_PREVIEW_PACKAGE_JSON);
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: require.resolve("typescript"),
4483
+ typescriptPath: resolveModule("typescript", options.resolveRoot),
4477
4484
  tsgo: false
4478
4485
  };
4479
- const installedTypeScriptTsgoPackage = resolveInstalledTypeScriptPackageForTsgo();
4480
- if (installedTypeScriptTsgoPackage) return {
4481
- typescriptPath: installedTypeScriptTsgoPackage.packageJsonPath,
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: require.resolve("typescript")
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 typescriptRuntimeConfig = resolveTypeScriptRuntimeConfig(optionsAsObject);
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
- ...optionsAsObject,
4519
+ ...normalizedOptions,
4506
4520
  ...typescriptRuntimeConfig,
4507
4521
  configFile: configFile,
4508
- configOverwrite: optionsAsObject.configOverwrite || {},
4509
- context: optionsAsObject.context || external_node_path_default().dirname(configFile),
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
- ...optionsAsObject.diagnosticOptions || {}
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-checker-rspack-plugin",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Runs typescript type checker and linter on separate process.",
5
5
  "keywords": [
6
6
  "rspack",
@@ -25,26 +25,26 @@
25
25
  "dependencies": {
26
26
  "@rspack/lite-tapable": "^1.1.2",
27
27
  "chokidar": "^3.6.0",
28
- "memfs": "^4.57.7",
28
+ "memfs": "^4.57.8",
29
29
  "picocolors": "^1.1.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@babel/code-frame": "^7.29.7",
33
- "@rslib/core": "^0.22.1",
34
- "@rslint/core": "^0.6.1",
35
- "@rspack/core": "^2.0.8",
36
- "@rstest/core": "^0.10.4",
33
+ "@rslib/core": "^0.23.1",
34
+ "@rslint/core": "^0.6.4",
35
+ "@rspack/core": "^2.1.2",
36
+ "@rstest/core": "^0.10.6",
37
37
  "@types/babel__code-frame": "^7.27.0",
38
38
  "@types/is-glob": "^4.0.4",
39
39
  "@types/mock-fs": "^4.13.4",
40
40
  "@types/node": "^24.13.2",
41
- "@typescript/native-preview": "7.0.0-dev.20260613.1",
41
+ "@typescript/native-preview": "7.0.0-dev.20260630.1",
42
42
  "cross-env": "^10.1.0",
43
43
  "husky": "^9.1.7",
44
44
  "is-glob": "^4.0.3",
45
45
  "minimatch": "^10.2.5",
46
46
  "mock-fs": "^5.5.0",
47
- "prettier": "^3.8.4",
47
+ "prettier": "^3.9.4",
48
48
  "strip-ansi": "^7.2.0",
49
49
  "typescript": "^6.0.3"
50
50
  },