@@ -74,19 +74,31 @@ 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 = null , checkout = false ) {
78+ async function bundlePackage ( esModules ) {
79+ await exec ( `npm run bundle-package${ esModules ? ' esmodules' : '' } ` , { cwd : srcDir } ) ;
80+ const bundleName = `core-js-bundle${ esModules ? '-esmodules' : '' } .js` ;
81+ const srcPath = join ( srcDir , 'packages/core-js-bundle/minified.js' ) ;
82+ const destPath = join ( srcDir , 'website/src/public/bundles/' , target , bundleName ) ;
83+ await cp ( srcPath , destPath ) ;
84+ if ( cacheDir !== null ) {
85+ const cachePath = join ( cacheDir , target , bundleName ) ;
86+ await cp ( srcPath , cachePath ) ;
87+ }
88+ }
89+
7890 const target = version . branch ?? version . tag ;
79- const name = version . path ?? version . label ;
8091 console . log ( `Building and copying core-js for ${ target } ` ) ;
81- const targetBundlePath = ` ${ destDir } / ${ target } /` ;
92+ const targetBundlePath = join ( cacheDir ?? '' , target ) ;
8293
83- if ( cache && await isExists ( targetBundlePath ) ) {
94+ if ( cacheDir !== null && await isExists ( targetBundlePath ) ) {
8495 console . time ( 'Core JS bundles copied' ) ;
8596 const bundlePath = join ( targetBundlePath , 'core-js-bundle.js' ) ;
86- const destBundlePath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle.js' ) ;
87- const esmodulesBundlePath = join ( targetBundlePath , 'core-js-bundle-esmodules.js' ) ;
88- const esmodulesDestBundlePath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle-esmodules.js' ) ;
97+ const destBundlePath = join ( srcDir , 'website/src/public/bundles/' , target , 'core-js-bundle.js' ) ;
8998 await cp ( bundlePath , destBundlePath ) ;
99+
100+ const esmodulesBundlePath = join ( targetBundlePath , 'core-js-bundle-esmodules.js' ) ;
101+ const esmodulesDestBundlePath = join ( srcDir , 'website/src/public/bundles/' , target , 'core-js-bundle-esmodules.js' ) ;
90102 await cp ( esmodulesBundlePath , esmodulesDestBundlePath ) ;
91103 console . timeEnd ( 'Core JS bundles copied' ) ;
92104 return ;
@@ -97,19 +109,10 @@ export async function buildAndCopyCoreJS(version, srcDir, destDir, checkout = fa
97109 await checkoutVersion ( version , srcDir ) ;
98110 }
99111 await installDependencies ( srcDir ) ;
100- await exec ( 'npm run bundle-package' , { cwd : srcDir } ) ;
101- const bundlePath = join ( srcDir , 'packages/core-js-bundle/minified.js' ) ;
102- const destPath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle.js' ) ;
103- const destBundlePath = join ( targetBundlePath , 'core-js-bundle.js' ) ;
104- await cp ( bundlePath , destPath ) ;
105- await cp ( bundlePath , destBundlePath ) ;
106-
107- await exec ( 'npm run bundle-package esmodules' , { cwd : srcDir } ) ;
108- const esmodulesBundlePath = join ( srcDir , 'packages/core-js-bundle/minified.js' ) ;
109- const esmodulesDestBundlePath = join ( srcDir , 'website/src/public/bundles/' , name , 'core-js-bundle-esmodules.js' ) ;
110- const destEsmodulesBundlePath = join ( targetBundlePath , 'core-js-bundle-esmodules.js' ) ;
111- await cp ( esmodulesBundlePath , esmodulesDestBundlePath ) ;
112- await cp ( esmodulesBundlePath , destEsmodulesBundlePath ) ;
112+
113+ await bundlePackage ( false ) ;
114+ await bundlePackage ( true ) ;
115+
113116 console . timeEnd ( 'Core JS bundles built' ) ;
114117}
115118
0 commit comments