Skip to content

Commit 89d79bf

Browse files
authored
fix(types): rsdoctor types package change the dependency of @rspack/core (#168)
1 parent 8c016c4 commit 89d79bf

File tree

6 files changed

+58
-44
lines changed

6 files changed

+58
-44
lines changed

.changeset/friendly-years-occur.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rsdoctor/types': patch
3+
---
4+
5+
fix: rsdoctor types package change the dependency of @rspack/core

packages/types/package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"start": "npm run build -- -w"
1919
},
2020
"dependencies": {
21-
"@rspack/core": "0.5.1",
2221
"@types/connect": "3.4.35",
2322
"@types/estree": "1.0.0",
2423
"@types/tapable": "2.2.2",
@@ -31,6 +30,14 @@
3130
"tslib": "2.4.1",
3231
"typescript": "^5.2.2"
3332
},
33+
"peerDependencies": {
34+
"@rspack/core": "^0.5.1"
35+
},
36+
"peerDependenciesMeta": {
37+
"@rspack/core": {
38+
"optional": true
39+
}
40+
},
3441
"publishConfig": {
3542
"access": "public",
3643
"provenance": true,

packages/types/src/plugin/baseCompiler.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,34 @@ import type {
1010
Compilation as RspackCompilation,
1111
Stats as RspackStats,
1212
RuleSetRule as RspackRuleSetRule,
13-
RuleSetRules,
13+
RuleSetRules as RspackRuleSetRules,
1414
} from '@rspack/core';
1515

16-
export type BaseCompiler = (Compiler | RspackCompiler) & { webpack: any };
16+
type RspackCompilerWrapper = any extends RspackCompiler
17+
? never
18+
: RspackCompiler;
1719

18-
export type BaseCompilation = RspackCompilation | Compilation;
20+
type RspackCompilationWrapper = any extends RspackCompilation
21+
? never
22+
: RspackCompilation;
1923

20-
export type BaseStats = Stats | RspackStats;
24+
type RspackStatsWrapper = any extends RspackStats ? never : RspackStats;
25+
26+
type RspackRuleSetRuleWrapper = any extends RspackRuleSetRule
27+
? never
28+
: RspackRuleSetRule;
29+
30+
type RspackRuleSetRulesWrapper = any extends RspackRuleSetRules
31+
? never
32+
: (RspackRuleSetRule | '...')[] | RspackRuleSetRules;
33+
34+
export type BaseCompiler = (Compiler | RspackCompilerWrapper) & {
35+
webpack: any;
36+
};
37+
38+
export type BaseCompilation = RspackCompilationWrapper | Compilation;
39+
40+
export type BaseStats = Stats | RspackStatsWrapper;
2141

2242
export interface JsStatsError {
2343
message: string;
@@ -29,9 +49,10 @@ export interface JsStatsWarning {
2949
message: string;
3050
formatted: string;
3151
}
32-
3352
export type BuildError = JsStatsError | StatsError;
3453
export type BuildWarning = JsStatsWarning | StatsError;
3554

36-
export type BuildRuleSetRules = (RuleSetRule | '...')[] | RuleSetRules;
37-
export type BuildRuleSetRule = RuleSetRule | RspackRuleSetRule;
55+
export type BuildRuleSetRules =
56+
| (RuleSetRule | '...')[]
57+
| RspackRuleSetRulesWrapper;
58+
export type BuildRuleSetRule = RuleSetRule | RspackRuleSetRuleWrapper;

packages/types/src/plugin/baseLoader.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ export interface SourceMap {
1717
names?: string[];
1818
}
1919

20-
export type RuleSetRule = RspackRuleSetRule | WebpackRuleSetRule;
21-
export type Configuration = WebpackConfiguration | RspackConfiguration;
20+
type RspackConfigurationWrapper = any extends RspackConfiguration
21+
? never
22+
: RspackConfiguration;
23+
type RspackRuleSetRuleWrapper = any extends RspackRuleSetRule
24+
? never
25+
: RspackRuleSetRule;
26+
27+
export type RuleSetRule = RspackRuleSetRuleWrapper | WebpackRuleSetRule;
28+
export type Configuration = WebpackConfiguration | RspackConfigurationWrapper;
2229

2330
declare interface AdditionalData {
2431
[index: string]: any;

packages/types/src/sdk/config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import type { Configuration } from 'webpack';
2-
import type { Configuration as RspackConfiguration} from '@rspack/core';
2+
import type { Configuration as RspackConfiguration } from '@rspack/core';
3+
4+
type RspackConfigurationWrapper = any extends RspackConfiguration
5+
? never
6+
: RspackConfiguration;
37

48
export interface WebpackConfigData {
59
name: 'webpack' | 'rspack';
610
version: string | number;
711
bin?: string;
8-
config: Configuration | RspackConfiguration;
12+
config: Configuration | RspackConfigurationWrapper;
913
}
1014

1115
export type ConfigData = WebpackConfigData[];

pnpm-lock.yaml

Lines changed: 2 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)