@@ -13,13 +13,17 @@ const {
1313 showDirStats,
1414} = require ( './utils.js' ) ;
1515
16- const entryPoints = [
17- 'index.ts' ,
18- 'execution/execute.ts' ,
19- 'jsutils/instanceOf.ts' ,
20- 'language/parser.ts' ,
21- 'language/ast.ts' ,
22- ] ;
16+ const entryPoints = fs
17+ . readdirSync ( './src' , { recursive : true } )
18+ . filter ( ( f ) => f . endsWith ( 'index.ts' ) )
19+ . map ( ( f ) => f . replace ( / ^ s r c / , '' ) )
20+ . reverse ( )
21+ . concat ( [
22+ 'execution/execute.ts' ,
23+ 'jsutils/instanceOf.ts' ,
24+ 'language/parser.ts' ,
25+ 'language/ast.ts' ,
26+ ] ) ;
2327
2428if ( require . main === module ) {
2529 fs . rmSync ( './npmDist' , { recursive : true , force : true } ) ;
@@ -127,6 +131,27 @@ function buildPackageJSON() {
127131
128132 packageJSON . type = 'commonjs' ;
129133
134+ for ( const entryPoint of entryPoints ) {
135+ if ( ! entryPoint . endsWith ( 'index.ts' ) ) {
136+ continue ;
137+ }
138+ const base = ( './' + path . dirname ( entryPoint ) ) . replace ( / \/ .? $ / , '' ) ;
139+ const generated = { } ;
140+ generated [ base ] = {
141+ types : {
142+ import : base + '/index.js.d.mts' ,
143+ default : base + '/index.d.ts' ,
144+ } ,
145+ module : base + '/index.mjs' ,
146+ import : base + '/index.js.mjs' ,
147+ default : base + '/index.js' ,
148+ } ;
149+ packageJSON . exports = {
150+ ...generated ,
151+ ...packageJSON . exports ,
152+ } ;
153+ }
154+
130155 // TODO: move to integration tests
131156 const publishTag = packageJSON . publishConfig ?. tag ;
132157 assert ( publishTag != null , 'Should have packageJSON.publishConfig defined!' ) ;
0 commit comments