55const { readFileSync, readdirSync, writeFileSync, copyFileSync } = require ( 'fs' )
66const { copySync } = require ( 'fs-extra' )
77
8- /**
9- * append our api modules to `exports` in `package.json` then write it to `./dist`
10- */
8+ // append our api modules to `exports` in `package.json` then write it to `./dist`
119const pkg = JSON . parse ( readFileSync ( 'package.json' , 'utf8' ) )
12- const modules = readdirSync ( 'src' ) . map ( ( mod ) => mod . replace ( '.ts' , '' ) )
13- if ( ! pkg . exports ) {
14- pkg . exports = { }
15- }
10+ const modules = readdirSync ( 'src' )
11+ . filter ( ( e ) => e !== 'helpers' )
12+ . map ( ( mod ) => mod . replace ( '.ts' , '' ) )
1613
1714const outputPkg = {
1815 ...pkg ,
@@ -33,22 +30,18 @@ const outputPkg = {
3330 } ) ,
3431 // if for some reason in the future we manually add something in the `exports` field
3532 // this will ensure it doesn't get overwritten by the logic above
36- { ...pkg . exports }
33+ { ...( pkg . exports || { } ) }
3734 )
3835}
3936writeFileSync ( 'dist/package.json' , JSON . stringify ( outputPkg , undefined , 2 ) )
4037
41- /**
42- * copy necessary files like `CHANGELOG.md` , `README.md` and Licenses to `./dist`
43- */
38+ // copy necessary files like `CHANGELOG.md` , `README.md` and Licenses to `./dist`
4439const dir = readdirSync ( '.' )
4540const files = [
4641 ...dir . filter ( ( f ) => f . startsWith ( 'LICENSE' ) ) ,
4742 ...dir . filter ( ( f ) => f . endsWith ( '.md' ) )
4843]
4944files . forEach ( ( f ) => copyFileSync ( f , `dist/${ f } ` ) )
5045
51- /**
52- * copy typescript src files to `./dist`
53- */
46+ // copy typescript src files to `./dist`
5447copySync ( 'src' , 'dist' )
0 commit comments