File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ import fs from 'node:fs' ;
2
+ import path from 'node:path' ;
3
+ import type { RsbuildPlugin } from '@rsbuild/core' ;
1
4
import { defineConfig } from 'rslib' ;
2
5
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
+
3
27
export default defineConfig ( {
4
28
lib : [
5
29
{
@@ -11,6 +35,7 @@ export default defineConfig({
11
35
} ,
12
36
} ,
13
37
] ,
38
+ plugins : [ pluginFixDtsTypes ] ,
14
39
source : {
15
40
entry : {
16
41
index : './src/index.ts' ,
You can’t perform that action at this time.
0 commit comments