@@ -74,11 +74,12 @@ export async function copyCommonFiles(srcDir) {
7474 console . timeEnd ( 'Copied common files' ) ;
7575}
7676
77- export async function buildAndCopyCoreJS ( version , srcDir , destDir , checkout = false , cache = false ) {
77+ export async function buildAndCopyCoreJS ( version , srcDir , cacheDir = '' , checkout = false ) {
7878 const target = version . branch ?? version . tag ;
7979 const name = version . path ?? version . label ;
80+ const cache = cacheDir !== '' ;
8081 console . log ( `Building and copying core-js for ${ target } ` ) ;
81- const targetBundlePath = `${ destDir } /${ target } /` ;
82+ const targetBundlePath = `${ cacheDir } /${ target } /` ;
8283
8384 if ( cache && await isExists ( targetBundlePath ) ) {
8485 console . time ( 'Core JS bundles copied' ) ;
@@ -100,16 +101,23 @@ export async function buildAndCopyCoreJS(version, srcDir, destDir, checkout = fa
100101 await exec ( 'npm run bundle-package' , { cwd : srcDir } ) ;
101102 const bundlePath = join ( srcDir , 'packages/core-js-bundle/minified.js' ) ;
102103 const destPath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle.js' ) ;
103- const destBundlePath = join ( targetBundlePath , 'core-js-bundle.js' ) ;
104104 await cp ( bundlePath , destPath ) ;
105- await cp ( bundlePath , destBundlePath ) ;
105+
106+ if ( cache ) {
107+ const cacheBundlePath = join ( targetBundlePath , 'core-js-bundle.js' ) ;
108+ await cp ( bundlePath , cacheBundlePath ) ;
109+ }
106110
107111 await exec ( 'npm run bundle-package esmodules' , { cwd : srcDir } ) ;
108112 const esmodulesBundlePath = join ( srcDir , 'packages/core-js-bundle/minified.js' ) ;
109113 const esmodulesDestBundlePath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle-esmodules.js' ) ;
110- const destEsmodulesBundlePath = join ( targetBundlePath , 'core-js-bundle-esmodules.js' ) ;
111114 await cp ( esmodulesBundlePath , esmodulesDestBundlePath ) ;
112- await cp ( esmodulesBundlePath , destEsmodulesBundlePath ) ;
115+
116+ if ( cache ) {
117+ const cacheEsmodulesBundlePath = join ( targetBundlePath , 'core-js-bundle-esmodules.js' ) ;
118+ await cp ( esmodulesBundlePath , cacheEsmodulesBundlePath ) ;
119+ }
120+
113121 console . timeEnd ( 'Core JS bundles built' ) ;
114122}
115123
0 commit comments