Skip to content

Commit

Permalink
chore: convert some operations in the build script to asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
lingbopro committed Dec 22, 2024
1 parent df67dff commit ffd9a06
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions dev/scripts/lib/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,24 @@ export async function main(options) {
);
log('compiling TypeScript...');
// This may not seem like standard usage, but it can at least reduce the waiting time by 3s
child_process.spawnSync(
const tscProcess = child_process.spawn(
'node',
[path.join(root, 'node_modules', 'typescript', 'lib', 'tsc.js')],
{ cwd: root },
);
await new Promise((resolve) => tscProcess.once('exit', resolve));
logSuccess('success compiled TypeScript');
log('generating bundles...');
const globedFiles = fs.globSync(
path.resolve(root, '.__compile_cache__', '**', '*.js'),
const globedFiles = await new Promise((resolve) =>
fs.glob(
path.resolve(root, '.__compile_cache__', '**', '*.js'),
(err, matches) => {
if (err) {
throw err;
}
resolve(matches);
},
),
);
debug({ globedFiles });
const generateBundlesResult = await rollup({
Expand Down

0 comments on commit ffd9a06

Please sign in to comment.