Skip to content

Commit 3d5312d

Browse files
authored
fix: type missing when set moduleResolution node16+ (#568)
1 parent 4469918 commit 3d5312d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

packages/core/rslib.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import type { RsbuildPlugin } from '@rsbuild/core';
14
import { defineConfig } from 'rslib';
25

6+
const pluginFixDtsTypes: RsbuildPlugin = {
7+
name: 'fix-dts-types',
8+
setup(api) {
9+
api.onAfterBuild(() => {
10+
const typesDir = path.join(process.cwd(), 'dist-types');
11+
const pkgPath = path.join(typesDir, 'package.json');
12+
if (!fs.existsSync(typesDir)) {
13+
fs.mkdirSync(typesDir);
14+
}
15+
fs.writeFileSync(
16+
pkgPath,
17+
JSON.stringify({
18+
'//': 'This file is for making TypeScript work with moduleResolution node16+.',
19+
version: '1.0.0',
20+
}),
21+
'utf8',
22+
);
23+
});
24+
},
25+
};
26+
327
export default defineConfig({
428
lib: [
529
{
@@ -11,6 +35,7 @@ export default defineConfig({
1135
},
1236
},
1337
],
38+
plugins: [pluginFixDtsTypes],
1439
source: {
1540
entry: {
1641
index: './src/index.ts',

0 commit comments

Comments
 (0)