@@ -75,6 +75,7 @@ const ssrClientGlobby = {
7575} ;
7676const ssrClientSrcDir = nodePath . resolve ( ecDir , 'ssr/client/src' ) ;
7777const ssrClientESMDir = nodePath . resolve ( ecDir , 'ssr/client/lib' ) ;
78+ const ssrClientTypeDir = nodePath . resolve ( ecDir , 'ssr/client/types' ) ;
7879
7980const typesDir = nodePath . resolve ( ecDir , 'types' ) ;
8081const esmDir = 'lib' ;
@@ -148,9 +149,10 @@ const compileWorkList = [
148149 logLabel : 'ssr client ts -> js-esm' ,
149150 compilerOptionsOverride : {
150151 module : 'ES2015' ,
151- declaration : false ,
152+ declaration : true ,
152153 rootDir : ssrClientSrcDir ,
153- outDir : ssrClientESMDir
154+ outDir : ssrClientESMDir ,
155+ declarationDir : ssrClientTypeDir
154156 } ,
155157 srcGlobby : ssrClientGlobby ,
156158 transformOptions : {
@@ -372,6 +374,7 @@ async function readFilePaths({patterns, cwd}) {
372374 ) ;
373375}
374376
377+ // Bundle can be used in echarts-examples.
375378async function bundleDTS ( ) {
376379
377380 const outDir = nodePath . resolve ( __dirname , '../types/dist' ) ;
@@ -442,14 +445,16 @@ function readTSConfig() {
442445
443446
444447function generateEntries ( ) {
445- [ 'charts' , 'components' , 'renderers' , 'core' , 'features' ] . forEach ( entryName => {
446- if ( entryName !== 'option' ) {
447- const jsCode = fs . readFileSync ( nodePath . join ( __dirname , `template/${ entryName } .js` ) , 'utf-8' ) ;
448- fs . writeFileSync ( nodePath . join ( __dirname , `../${ entryName } .js` ) , jsCode , 'utf-8' ) ;
448+ [ 'charts' , 'components' , 'renderers' , 'core' , 'features' , 'ssr/client/index' ] . forEach ( entryPath => {
449+ if ( entryPath !== 'option' ) {
450+ const jsCode = fs . readFileSync ( nodePath . join ( __dirname , `template/${ entryPath } .js` ) , 'utf-8' ) ;
451+ fs . writeFileSync ( nodePath . join ( __dirname , `../${ entryPath } .js` ) , jsCode , 'utf-8' ) ;
449452 }
450453
451- const dtsCode = fs . readFileSync ( nodePath . join ( __dirname , `/template/${ entryName } .d.ts` ) , 'utf-8' ) ;
452- fs . writeFileSync ( nodePath . join ( __dirname , `../${ entryName } .d.ts` ) , dtsCode , 'utf-8' ) ;
454+ // Make the d.ts in the same dir as .js, so that the can be found by tsc.
455+ // package.json "types" in "exports" does not always seam to work.
456+ const dtsCode = fs . readFileSync ( nodePath . join ( __dirname , `/template/${ entryPath } .d.ts` ) , 'utf-8' ) ;
457+ fs . writeFileSync ( nodePath . join ( __dirname , `../${ entryPath } .d.ts` ) , dtsCode , 'utf-8' ) ;
453458 } ) ;
454459}
455460
0 commit comments