ts-checker-rspack-plugin 1.4.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 +50 -30
- package/lib/index.js +128 -29
- package/lib/typescript/type-script-go-constants.d.ts +5 -3
- package/lib/typescript/type-script-go-package.d.ts +15 -0
- package/lib/typescript/type-script-go-runner.d.ts +6 -1
- package/lib/typescript/type-script-worker-config.d.ts +4 -1
- package/lib/typescript/type-script-worker-options.d.ts +1 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -104,45 +104,55 @@ Rspack's modules resolution**. It means that you have to setup `tsconfig.json` c
|
|
|
104
104
|
|
|
105
105
|
Options for the TypeScript checker (`typescript` option object).
|
|
106
106
|
|
|
107
|
-
| Name | Type | Default value
|
|
108
|
-
| ------------------- | ------------------------------------------------------------------------------ |
|
|
109
|
-
| `memoryLimit` | `number` | `8192`
|
|
110
|
-
| `configFile` | `string` | `'tsconfig.json'`
|
|
111
|
-
| `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }`
|
|
112
|
-
| `context` | `string` | `dirname(configuration.configFile)`
|
|
113
|
-
| `build` | `boolean` | `false`
|
|
114
|
-
| `mode` | `'readonly'` or `'write-dts'` or `'write-tsbuildinfo'` or `'write-references'` | `build === true ? 'write-tsbuildinfo' ? 'readonly'`
|
|
115
|
-
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }`
|
|
116
|
-
| `profile` | `boolean` | `false`
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
107
|
+
| Name | Type | Default value | Description |
|
|
108
|
+
| ------------------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
109
|
+
| `memoryLimit` | `number` | `8192` | Memory limit for the checker process in MB. If the process exits with the allocation failed error, try to increase this number. |
|
|
110
|
+
| `configFile` | `string` | `'tsconfig.json'` | Path to the `tsconfig.json` file (path relative to the `compiler.options.context` or absolute path) |
|
|
111
|
+
| `configOverwrite` | `object` | `{ compilerOptions: { skipLibCheck: true, sourceMap: false, inlineSourceMap: false, declarationMap: false } }` | This configuration will overwrite configuration from the `tsconfig.json` file. Supported fields are: `extends`, `compilerOptions`, `include`, `exclude`, `files`, and `references`. |
|
|
112
|
+
| `context` | `string` | `dirname(configuration.configFile)` | The base path for finding files specified in the `tsconfig.json`. Same as the `context` option from the [ts-loader](https://github.com/TypeStrong/ts-loader#context). Useful if you want to keep your `tsconfig.json` in an external package. Keep in mind that **not** having a `tsconfig.json` in your project root can cause different behaviour between `ts-checker-rspack-plugin` and `tsc`. When using editors like `VS Code` it is advised to add a `tsconfig.json` file to the root of the project and extend the config file referenced in option `configFile`. |
|
|
113
|
+
| `build` | `boolean` | `false` | The equivalent of the `--build` flag for the `tsc` command. |
|
|
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
|
+
| `diagnosticOptions` | `object` | `{ syntactic: false, semantic: true, declaration: false, global: false }` | Settings to select which diagnostics do we want to perform. |
|
|
116
|
+
| `profile` | `boolean` | `false` | Measures and prints timings related to the TypeScript performance. |
|
|
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`. |
|
|
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
|
-
`typescript.tsgo`
|
|
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
|
-
|
|
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
|
-
- `async`.
|
|
128
|
-
- `logger`.
|
|
129
|
-
- `tsconfig.json` compiler options used by tsgo, including `incremental` and `composite`.
|
|
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.
|
|
130
128
|
|
|
131
|
-
|
|
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`.
|
|
132
130
|
|
|
133
|
-
|
|
134
|
-
- `issue.defaultSeverity` works for matched diagnostics.
|
|
135
|
-
- Raw tsgo stdout/stderr is printed when the plugin cannot safely parse the output.
|
|
131
|
+
Install TypeScript 7.0 RC to enable `tsgo` automatically:
|
|
136
132
|
|
|
137
|
-
|
|
133
|
+
```sh
|
|
134
|
+
# with npm
|
|
135
|
+
npm install -D typescript@rc
|
|
138
136
|
|
|
139
|
-
|
|
140
|
-
-
|
|
141
|
-
- `typescript.profile`.
|
|
142
|
-
- TypeScript API based formatting or filesystem output rewrites.
|
|
143
|
-
- Plugin-controlled declaration or reference emit modes such as `write-dts` and `write-references`; tsgo is always run with `--noEmit`.
|
|
137
|
+
# with yarn
|
|
138
|
+
yarn add -D typescript@rc
|
|
144
139
|
|
|
145
|
-
|
|
140
|
+
# with pnpm
|
|
141
|
+
pnpm add -D typescript@rc
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Or install `@typescript/native-preview` and enable `tsgo` explicitly:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
# with npm
|
|
148
|
+
npm install -D @typescript/native-preview
|
|
149
|
+
|
|
150
|
+
# with yarn
|
|
151
|
+
yarn add -D @typescript/native-preview
|
|
152
|
+
|
|
153
|
+
# with pnpm
|
|
154
|
+
pnpm add -D @typescript/native-preview
|
|
155
|
+
```
|
|
146
156
|
|
|
147
157
|
```js
|
|
148
158
|
new TsCheckerRspackPlugin({
|
|
@@ -152,6 +162,16 @@ new TsCheckerRspackPlugin({
|
|
|
152
162
|
});
|
|
153
163
|
```
|
|
154
164
|
|
|
165
|
+
> The `@typescript/native-preview` usage is deprecated and kept only for compatibility. We recommend installing `typescript@rc` to use `tsgo`.
|
|
166
|
+
|
|
167
|
+
Limitations:
|
|
168
|
+
|
|
169
|
+
- `issue.include`, `issue.exclude`, and `issue.defaultSeverity` only apply to diagnostics whose `tsgo` output can be matched by `file`, `line`, `column`, `code`, and `message`.
|
|
170
|
+
- `typescript.configOverwrite`, `typescript.diagnosticOptions`, and `typescript.profile` are not supported.
|
|
171
|
+
- TypeScript API-based formatting or filesystem output rewrites are not supported.
|
|
172
|
+
- Plugin-controlled declaration or reference emit modes such as `write-dts` and `write-references` are not supported; `tsgo` always runs with `--noEmit`.
|
|
173
|
+
- This integration may change when TypeScript provides a stable JavaScript API for `tsgo`.
|
|
174
|
+
|
|
155
175
|
### Issues options
|
|
156
176
|
|
|
157
177
|
Options for the issues filtering (`issue` option object).
|
package/lib/index.js
CHANGED
|
@@ -3717,21 +3717,39 @@ var __webpack_exports__ = {};
|
|
|
3717
3717
|
Error.captureStackTrace(this, this.constructor);
|
|
3718
3718
|
}
|
|
3719
3719
|
}
|
|
3720
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
3721
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
3720
3722
|
const external_node_url_namespaceObject = require("node:url");
|
|
3721
|
-
const
|
|
3722
|
-
const
|
|
3723
|
+
const TYPESCRIPT_PACKAGE = "typescript";
|
|
3724
|
+
const TYPESCRIPT_PACKAGE_JSON = `${TYPESCRIPT_PACKAGE}/package.json`;
|
|
3725
|
+
const TYPESCRIPT_PREVIEW_PACKAGE = "@typescript/native-preview";
|
|
3726
|
+
const TYPESCRIPT_PREVIEW_PACKAGE_JSON = `${TYPESCRIPT_PREVIEW_PACKAGE}/package.json`;
|
|
3723
3727
|
function resolveTypeScriptGoPackageJsonPath(config) {
|
|
3724
|
-
if (!external_node_path_default().isAbsolute(config.typescriptPath) || 'package.json' !== external_node_path_default().basename(config.typescriptPath)) throw new Error(
|
|
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".`);
|
|
3725
3730
|
return config.typescriptPath;
|
|
3726
3731
|
}
|
|
3727
|
-
async function
|
|
3728
|
-
const
|
|
3729
|
-
const getExePathPath = external_node_path_default().resolve(external_node_path_default().dirname(tsgoPkgPath), './lib/getExePath.js');
|
|
3732
|
+
async function resolveTypeScriptGoNativeExecutablePath(packageJsonPath, packageName) {
|
|
3733
|
+
const getExePathPath = external_node_path_default().resolve(external_node_path_default().dirname(packageJsonPath), './lib/getExePath.js');
|
|
3730
3734
|
const getExePathUrl = (0, external_node_url_namespaceObject.pathToFileURL)(getExePathPath).href;
|
|
3731
3735
|
const getExePathModule = await import(getExePathUrl);
|
|
3732
3736
|
const getExePath = getExePathModule.default || getExePathModule.getExePath;
|
|
3733
|
-
if ('function' != typeof getExePath) throw new Error(`Cannot resolve the typescript-go executable from "${
|
|
3734
|
-
|
|
3737
|
+
if ('function' != typeof getExePath) throw new Error(`Cannot resolve the typescript-go executable from "${packageName}".`);
|
|
3738
|
+
const executablePath = getExePath();
|
|
3739
|
+
if ('string' != typeof executablePath || !external_node_fs_default().existsSync(executablePath)) throw new Error('Executable not found');
|
|
3740
|
+
return executablePath;
|
|
3741
|
+
}
|
|
3742
|
+
async function resolveTypeScriptGoBinPath(config) {
|
|
3743
|
+
const packageJsonPath = resolveTypeScriptGoPackageJsonPath(config);
|
|
3744
|
+
if ("typescript" === config.tsgoPackage) return resolveTypeScriptGoNativeExecutablePath(packageJsonPath, TYPESCRIPT_PACKAGE);
|
|
3745
|
+
return resolveTypeScriptGoNativeExecutablePath(packageJsonPath, TYPESCRIPT_PREVIEW_PACKAGE);
|
|
3746
|
+
}
|
|
3747
|
+
async function resolveTypeScriptGoExecutable(config) {
|
|
3748
|
+
const binPath = await resolveTypeScriptGoBinPath(config);
|
|
3749
|
+
return {
|
|
3750
|
+
command: binPath,
|
|
3751
|
+
args: []
|
|
3752
|
+
};
|
|
3735
3753
|
}
|
|
3736
3754
|
function createTypeScriptGoArgs(config) {
|
|
3737
3755
|
const args = config.build ? [
|
|
@@ -3840,12 +3858,15 @@ var __webpack_exports__ = {};
|
|
|
3840
3858
|
}
|
|
3841
3859
|
async function runTypeScriptGo(config, logger, defaultSeverity = 'auto', signal) {
|
|
3842
3860
|
AbortError.throwIfAborted(signal);
|
|
3843
|
-
const
|
|
3861
|
+
const executable = await resolveTypeScriptGoExecutable(config);
|
|
3844
3862
|
const args = createTypeScriptGoArgs(config);
|
|
3845
3863
|
return new Promise((resolve, reject)=>{
|
|
3846
3864
|
let settled = false;
|
|
3847
3865
|
let output = '';
|
|
3848
|
-
const childProcess = (0, external_node_child_process_namespaceObject.spawn)(
|
|
3866
|
+
const childProcess = (0, external_node_child_process_namespaceObject.spawn)(executable.command, [
|
|
3867
|
+
...executable.args,
|
|
3868
|
+
...args
|
|
3869
|
+
], {
|
|
3849
3870
|
cwd: config.context,
|
|
3850
3871
|
stdio: [
|
|
3851
3872
|
'inherit',
|
|
@@ -4127,23 +4148,47 @@ var __webpack_exports__ = {};
|
|
|
4127
4148
|
});
|
|
4128
4149
|
});
|
|
4129
4150
|
}
|
|
4130
|
-
|
|
4131
|
-
|
|
4151
|
+
function readTsgoPackageJson(packageJsonPath) {
|
|
4152
|
+
return require(packageJsonPath);
|
|
4153
|
+
}
|
|
4154
|
+
function getTsgoPackage(packageJson) {
|
|
4155
|
+
if (packageJson.name === TYPESCRIPT_PACKAGE) {
|
|
4156
|
+
const versionMatch = packageJson.version?.match(/^(\d+)\.(\d+)(?:\.|$|-)/);
|
|
4157
|
+
if (versionMatch && Number(versionMatch[1]) >= 7) return "typescript";
|
|
4158
|
+
}
|
|
4159
|
+
if (packageJson.name === TYPESCRIPT_PREVIEW_PACKAGE) return 'preview';
|
|
4160
|
+
}
|
|
4161
|
+
function resolveTypeScriptGoPackage(packageJsonPath) {
|
|
4162
|
+
if (!external_node_path_default().isAbsolute(packageJsonPath) || 'package.json' !== external_node_path_default().basename(packageJsonPath)) return;
|
|
4163
|
+
try {
|
|
4164
|
+
const tsgoPackage = getTsgoPackage(readTsgoPackageJson(packageJsonPath));
|
|
4165
|
+
return tsgoPackage ? {
|
|
4166
|
+
packageJsonPath,
|
|
4167
|
+
tsgoPackage
|
|
4168
|
+
} : void 0;
|
|
4169
|
+
} catch {
|
|
4170
|
+
return;
|
|
4171
|
+
}
|
|
4172
|
+
}
|
|
4132
4173
|
function isDefaultTypeScriptGoPath(typescriptPath) {
|
|
4133
|
-
if (typescriptPath ===
|
|
4174
|
+
if (typescriptPath === TYPESCRIPT_PREVIEW_PACKAGE_JSON) return true;
|
|
4175
|
+
try {
|
|
4176
|
+
if (typescriptPath === require.resolve(TYPESCRIPT_PREVIEW_PACKAGE_JSON)) return true;
|
|
4177
|
+
} catch {}
|
|
4178
|
+
if (!external_node_path_default().isAbsolute(typescriptPath) || 'package.json' !== external_node_path_default().basename(typescriptPath)) return false;
|
|
4134
4179
|
try {
|
|
4135
|
-
return typescriptPath
|
|
4180
|
+
return Boolean(getTsgoPackage(readTsgoPackageJson(typescriptPath)));
|
|
4136
4181
|
} catch {
|
|
4137
4182
|
return false;
|
|
4138
4183
|
}
|
|
4139
4184
|
}
|
|
4140
4185
|
function createTypeScriptGoSupportError(config, error) {
|
|
4141
4186
|
const message = [
|
|
4142
|
-
`When you enable TsCheckerRspackPlugin with \`typescript.tsgo\`, you must install \`${
|
|
4187
|
+
`When you enable TsCheckerRspackPlugin with \`typescript.tsgo\`, you must install \`${TYPESCRIPT_PACKAGE}@rc\` or \`${TYPESCRIPT_PREVIEW_PACKAGE}\` package.`
|
|
4143
4188
|
];
|
|
4144
|
-
if (!isDefaultTypeScriptGoPath(config.typescriptPath)) message.push(`If you set \`typescript.typescriptPath\`, it must be an absolute path to \`${
|
|
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}\`.`);
|
|
4145
4190
|
if (error instanceof Error && error.message) message.push(`Failed to resolve the tsgo executable: ${error.message}`);
|
|
4146
|
-
message.push(`You can install it with \`npm add ${
|
|
4191
|
+
message.push(`You can install it with \`npm add ${TYPESCRIPT_PACKAGE}@rc -D\` or \`npm add ${TYPESCRIPT_PREVIEW_PACKAGE} -D\`.`);
|
|
4147
4192
|
return new Error(message.join(external_node_os_default().EOL));
|
|
4148
4193
|
}
|
|
4149
4194
|
function assertTypeScriptGoSupport(config) {
|
|
@@ -4165,6 +4210,7 @@ var __webpack_exports__ = {};
|
|
|
4165
4210
|
function assertTypeScriptSupport(config) {
|
|
4166
4211
|
if (config.tsgo) assertTypeScriptGoSupport(config);
|
|
4167
4212
|
else {
|
|
4213
|
+
if ('package.json' === external_node_path_default().basename(config.typescriptPath)) throw new Error("When you use TsCheckerRspackPlugin without `typescript.tsgo`, `typescript.typescriptPath` should point to a path like `require.resolve('typescript')`.");
|
|
4168
4214
|
let typescriptVersion;
|
|
4169
4215
|
try {
|
|
4170
4216
|
typescriptVersion = require(config.typescriptPath).version;
|
|
@@ -4398,37 +4444,90 @@ var __webpack_exports__ = {};
|
|
|
4398
4444
|
defaultSeverity
|
|
4399
4445
|
};
|
|
4400
4446
|
}
|
|
4401
|
-
function
|
|
4402
|
-
|
|
4403
|
-
|
|
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) {
|
|
4455
|
+
try {
|
|
4456
|
+
const packageJsonPath = resolveModule(TYPESCRIPT_PACKAGE_JSON, resolveRoot);
|
|
4457
|
+
const tsgoPackage = resolveTypeScriptGoPackage(packageJsonPath);
|
|
4458
|
+
if (tsgoPackage?.tsgoPackage === "typescript") return tsgoPackage;
|
|
4459
|
+
} catch {}
|
|
4460
|
+
}
|
|
4461
|
+
function resolveDefaultPreviewPackageJsonPath(resolveRoot) {
|
|
4462
|
+
try {
|
|
4463
|
+
return resolveModule(TYPESCRIPT_PREVIEW_PACKAGE_JSON, resolveRoot);
|
|
4404
4464
|
} catch {
|
|
4405
|
-
return
|
|
4465
|
+
return TYPESCRIPT_PREVIEW_PACKAGE_JSON;
|
|
4406
4466
|
}
|
|
4407
|
-
|
|
4467
|
+
}
|
|
4468
|
+
function resolveTypeScriptRuntimeConfig(options) {
|
|
4469
|
+
if (options.typescriptPath) {
|
|
4470
|
+
const tsgoPackage = resolveTypeScriptGoPackage(options.typescriptPath);
|
|
4471
|
+
const tsgo = void 0 === options.tsgo && tsgoPackage?.tsgoPackage === "typescript" ? true : options.tsgo;
|
|
4472
|
+
return {
|
|
4473
|
+
typescriptPath: options.typescriptPath,
|
|
4474
|
+
...void 0 === tsgo ? {} : {
|
|
4475
|
+
tsgo
|
|
4476
|
+
},
|
|
4477
|
+
...true === tsgo && tsgoPackage ? {
|
|
4478
|
+
tsgoPackage: tsgoPackage.tsgoPackage
|
|
4479
|
+
} : {}
|
|
4480
|
+
};
|
|
4481
|
+
}
|
|
4482
|
+
if (false === options.tsgo) return {
|
|
4483
|
+
typescriptPath: resolveModule("typescript", options.resolveRoot),
|
|
4484
|
+
tsgo: false
|
|
4485
|
+
};
|
|
4486
|
+
const installedTsgoPackage = resolveInstalledTsgoPackage(options.resolveRoot);
|
|
4487
|
+
if (installedTsgoPackage) return {
|
|
4488
|
+
typescriptPath: installedTsgoPackage.packageJsonPath,
|
|
4489
|
+
tsgo: true,
|
|
4490
|
+
tsgoPackage: "typescript"
|
|
4491
|
+
};
|
|
4492
|
+
if (true === options.tsgo) return {
|
|
4493
|
+
typescriptPath: resolveDefaultPreviewPackageJsonPath(options.resolveRoot),
|
|
4494
|
+
tsgo: true,
|
|
4495
|
+
tsgoPackage: 'preview'
|
|
4496
|
+
};
|
|
4497
|
+
return {
|
|
4498
|
+
typescriptPath: resolveModule("typescript", options.resolveRoot)
|
|
4499
|
+
};
|
|
4408
4500
|
}
|
|
4409
4501
|
function createTypeScriptWorkerConfig(compiler, options) {
|
|
4410
4502
|
let configFile = 'object' == typeof options ? options.configFile || 'tsconfig.json' : 'tsconfig.json';
|
|
4411
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));
|
|
4412
4504
|
const optionsAsObject = 'object' == typeof options ? options : {};
|
|
4413
|
-
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);
|
|
4414
4513
|
return {
|
|
4415
4514
|
enabled: Boolean(options) || void 0 === options,
|
|
4416
4515
|
memoryLimit: 8192,
|
|
4417
4516
|
build: false,
|
|
4418
4517
|
mode: optionsAsObject.build ? 'write-tsbuildinfo' : 'readonly',
|
|
4419
4518
|
profile: false,
|
|
4420
|
-
...
|
|
4519
|
+
...normalizedOptions,
|
|
4520
|
+
...typescriptRuntimeConfig,
|
|
4421
4521
|
configFile: configFile,
|
|
4422
|
-
configOverwrite:
|
|
4423
|
-
context:
|
|
4522
|
+
configOverwrite: normalizedOptions.configOverwrite || {},
|
|
4523
|
+
context: normalizedOptions.context || external_node_path_default().dirname(configFile),
|
|
4424
4524
|
diagnosticOptions: {
|
|
4425
4525
|
syntactic: false,
|
|
4426
4526
|
semantic: true,
|
|
4427
4527
|
declaration: false,
|
|
4428
4528
|
global: false,
|
|
4429
|
-
...
|
|
4430
|
-
}
|
|
4431
|
-
typescriptPath
|
|
4529
|
+
...normalizedOptions.diagnosticOptions || {}
|
|
4530
|
+
}
|
|
4432
4531
|
};
|
|
4433
4532
|
}
|
|
4434
4533
|
function createPluginConfig(compiler, options = {}) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
declare const
|
|
1
|
+
declare const TYPESCRIPT_PACKAGE = "typescript";
|
|
2
|
+
declare const TYPESCRIPT_PACKAGE_JSON = "typescript/package.json";
|
|
3
|
+
declare const TYPESCRIPT_PREVIEW_PACKAGE = "@typescript/native-preview";
|
|
4
|
+
declare const TYPESCRIPT_PREVIEW_PACKAGE_JSON = "@typescript/native-preview/package.json";
|
|
3
5
|
declare const TYPESCRIPT_GO_ISSUE_CODE = "TSGO";
|
|
4
|
-
export {
|
|
6
|
+
export { TYPESCRIPT_GO_ISSUE_CODE, TYPESCRIPT_PACKAGE, TYPESCRIPT_PACKAGE_JSON, TYPESCRIPT_PREVIEW_PACKAGE, TYPESCRIPT_PREVIEW_PACKAGE_JSON, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type TypeScriptGoPackage = 'typescript' | 'preview';
|
|
2
|
+
type TypeScriptGoPackageJson = {
|
|
3
|
+
name?: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
bin?: string | Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
type ResolvedTypeScriptGoPackage = {
|
|
8
|
+
packageJsonPath: string;
|
|
9
|
+
tsgoPackage: TypeScriptGoPackage;
|
|
10
|
+
};
|
|
11
|
+
declare function readTsgoPackageJson(packageJsonPath: string): TypeScriptGoPackageJson;
|
|
12
|
+
declare function getTsgoPackage(packageJson: TypeScriptGoPackageJson): TypeScriptGoPackage | undefined;
|
|
13
|
+
declare function resolveTypeScriptGoPackage(packageJsonPath: string): ResolvedTypeScriptGoPackage | undefined;
|
|
14
|
+
export { getTsgoPackage, readTsgoPackageJson, resolveTypeScriptGoPackage, };
|
|
15
|
+
export type { ResolvedTypeScriptGoPackage, TypeScriptGoPackage, TypeScriptGoPackageJson, };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Issue, IssueDefaultSeverity } from '../issue';
|
|
2
2
|
import type { Logger } from '../logger';
|
|
3
3
|
import type { TypeScriptWorkerConfig } from './type-script-worker-config';
|
|
4
|
+
type TypeScriptGoExecutable = {
|
|
5
|
+
command: string;
|
|
6
|
+
args: string[];
|
|
7
|
+
};
|
|
4
8
|
declare function resolveTypeScriptGoPackageJsonPath(config: TypeScriptWorkerConfig): string;
|
|
5
9
|
declare function resolveTypeScriptGoBinPath(config: TypeScriptWorkerConfig): Promise<string>;
|
|
10
|
+
declare function resolveTypeScriptGoExecutable(config: TypeScriptWorkerConfig): Promise<TypeScriptGoExecutable>;
|
|
6
11
|
declare function createTypeScriptGoArgs(config: TypeScriptWorkerConfig): string[];
|
|
7
12
|
declare function getTypeScriptGoErrorCount(output: string): number | undefined;
|
|
8
13
|
declare function parseTypeScriptGoIssues(output: string, config: TypeScriptWorkerConfig, defaultSeverity?: IssueDefaultSeverity): Issue[];
|
|
@@ -16,4 +21,4 @@ declare function getTypeScriptGoDependencies(config: TypeScriptWorkerConfig): {
|
|
|
16
21
|
excluded: string[];
|
|
17
22
|
extensions: string[];
|
|
18
23
|
};
|
|
19
|
-
export { createTypeScriptGoArgs, createTypeScriptGoExitIssues, getTypeScriptGoDependencies, getTypeScriptGoErrorCount, isTypeScriptGoIssue, isTypeScriptGoStatsError, parseTypeScriptGoIssues, resolveTypeScriptGoBinPath, resolveTypeScriptGoPackageJsonPath, runTypeScriptGo, };
|
|
24
|
+
export { createTypeScriptGoArgs, createTypeScriptGoExitIssues, getTypeScriptGoDependencies, getTypeScriptGoErrorCount, isTypeScriptGoIssue, isTypeScriptGoStatsError, parseTypeScriptGoIssues, resolveTypeScriptGoExecutable, resolveTypeScriptGoBinPath, resolveTypeScriptGoPackageJsonPath, runTypeScriptGo, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as rspack from '@rspack/core';
|
|
2
2
|
import type { TypeScriptConfigOverwrite } from './type-script-config-overwrite';
|
|
3
3
|
import type { TypeScriptDiagnosticsOptions } from './type-script-diagnostics-options';
|
|
4
|
+
import { type TypeScriptGoPackage } from './type-script-go-package';
|
|
4
5
|
import type { TypeScriptWorkerOptions } from './type-script-worker-options';
|
|
5
6
|
interface TypeScriptWorkerConfig {
|
|
6
7
|
enabled: boolean;
|
|
@@ -12,9 +13,11 @@ interface TypeScriptWorkerConfig {
|
|
|
12
13
|
mode: 'readonly' | 'write-dts' | 'write-tsbuildinfo' | 'write-references';
|
|
13
14
|
diagnosticOptions: TypeScriptDiagnosticsOptions;
|
|
14
15
|
profile: boolean;
|
|
16
|
+
resolveRoot?: string;
|
|
15
17
|
typescriptPath: string;
|
|
16
18
|
tsgo?: boolean;
|
|
19
|
+
tsgoPackage?: TypeScriptGoPackage;
|
|
17
20
|
}
|
|
18
21
|
declare function createTypeScriptWorkerConfig(compiler: rspack.Compiler, options: TypeScriptWorkerOptions | undefined): TypeScriptWorkerConfig;
|
|
19
|
-
export { createTypeScriptWorkerConfig };
|
|
22
|
+
export { createTypeScriptWorkerConfig, };
|
|
20
23
|
export type { TypeScriptWorkerConfig };
|
|
@@ -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.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rspack",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/rstackjs/ts-checker-rspack-plugin.git"
|
|
17
17
|
},
|
|
18
|
+
"homepage": "https://github.com/rstackjs/ts-checker-rspack-plugin#readme",
|
|
18
19
|
"license": "MIT",
|
|
19
20
|
"main": "lib/index.js",
|
|
20
21
|
"types": "lib/index.d.ts",
|
|
@@ -22,28 +23,28 @@
|
|
|
22
23
|
"lib"
|
|
23
24
|
],
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@rspack/lite-tapable": "^1.1.
|
|
26
|
+
"@rspack/lite-tapable": "^1.1.2",
|
|
26
27
|
"chokidar": "^3.6.0",
|
|
27
|
-
"memfs": "^4.57.
|
|
28
|
+
"memfs": "^4.57.7",
|
|
28
29
|
"picocolors": "^1.1.1"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@babel/code-frame": "^7.29.7",
|
|
32
|
-
"@rslib/core": "^0.22.
|
|
33
|
-
"@rslint/core": "^0.
|
|
34
|
-
"@rspack/core": "^2.0.
|
|
35
|
-
"@rstest/core": "^0.10.
|
|
33
|
+
"@rslib/core": "^0.22.1",
|
|
34
|
+
"@rslint/core": "^0.6.1",
|
|
35
|
+
"@rspack/core": "^2.0.8",
|
|
36
|
+
"@rstest/core": "^0.10.4",
|
|
36
37
|
"@types/babel__code-frame": "^7.27.0",
|
|
37
38
|
"@types/is-glob": "^4.0.4",
|
|
38
39
|
"@types/mock-fs": "^4.13.4",
|
|
39
|
-
"@types/node": "^24.
|
|
40
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
40
|
+
"@types/node": "^24.13.2",
|
|
41
|
+
"@typescript/native-preview": "7.0.0-dev.20260613.1",
|
|
41
42
|
"cross-env": "^10.1.0",
|
|
42
43
|
"husky": "^9.1.7",
|
|
43
44
|
"is-glob": "^4.0.3",
|
|
44
45
|
"minimatch": "^10.2.5",
|
|
45
46
|
"mock-fs": "^5.5.0",
|
|
46
|
-
"prettier": "^3.8.
|
|
47
|
+
"prettier": "^3.8.4",
|
|
47
48
|
"strip-ansi": "^7.2.0",
|
|
48
49
|
"typescript": "^6.0.3"
|
|
49
50
|
},
|