Skip to content

Commit a575a5b

Browse files
committed
Build-local script improvements
1 parent 2d4e1c8 commit a575a5b

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

website/build-local.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
import { join } from 'node:path';
55

66
const BUILD_SRC_DIR = './';
7-
const BUNDLES_DIR = 'bundles';
87

98
async function hasDocsLocal(srcDir) {
109
const target = join(srcDir, 'docs/web/docs');
@@ -20,7 +19,7 @@ try {
2019

2120
const version = { branch: targetBranch, label: targetBranch };
2221
await hasDocsLocal(BUILD_SRC_DIR);
23-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR);
22+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR);
2423

2524
await copyBabelStandalone(BUILD_SRC_DIR);
2625
await copyBlogPosts(BUILD_SRC_DIR);

website/scripts/helpers.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

website/scripts/runner.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ try {
195195
const versions = await getVersions(targetBranch);
196196
for (const version of versions) {
197197
await copyDocsToBuilder(version);
198-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true, true);
198+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true);
199199
}
200200
} else {
201201
const version = { branch: targetBranch, label: targetBranch };
202202
await hasDocs(version, BUILD_SRC_DIR);
203-
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true, true);
203+
await buildAndCopyCoreJS(version, BUILD_SRC_DIR, BUNDLES_DIR, true);
204204
}
205205

206206
await prepareBuilder(targetBranch);

0 commit comments

Comments
 (0)