Skip to content

Commit a4eeed4

Browse files
authored
fix: type error with the pre-bundled watchpack package (#10933)
* fix: ensure the type of graceful-fs is imported from correct path * fix: ignore * fix: ignore * fix
1 parent bc8d053 commit a4eeed4

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

.prettierignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package.json
2-
31
# Ignore generated
42
dist/
5-
packages/rspack/src/config/schema.check.js
3+
compiled/
64

75
# Ignore lock files
86
pnpm-lock.yaml
Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
// @ts-check
2+
import { readFileSync, writeFileSync } from "node:fs";
3+
import { join } from "node:path";
4+
25
/** @type {import('prebundle').Config} */
36
export default {
47
dependencies: [
8+
"@swc/types",
9+
"graceful-fs",
10+
"browserslist-load-config",
511
{
612
name: "webpack-sources",
713
copyDts: true
814
},
9-
"graceful-fs",
10-
"browserslist-load-config",
1115
{
1216
name: "watchpack",
1317
externals: {
1418
"graceful-fs": "../graceful-fs/index.js"
19+
},
20+
afterBundle(task) {
21+
const importStatement = "import fs from 'graceful-fs';";
22+
const dtsPath = join(task.distPath, "index.d.ts");
23+
const content = readFileSync(dtsPath, "utf-8");
24+
writeFileSync(
25+
dtsPath,
26+
content.replace(importStatement, `// @ts-ignore\n${importStatement}`)
27+
);
1528
}
16-
},
17-
{
18-
name: "@swc/types"
1929
}
2030
]
2131
};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "./tsconfig.build.json",
33
"compilerOptions": {
4-
"paths": {}
4+
"paths": {}
55
}
66
}

0 commit comments

Comments
 (0)