Skip to content

Commit d900620

Browse files
committed
feat: support parallel builds
1 parent e6920f4 commit d900620

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/build.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ async function _build(
156156
respectExternal: true,
157157
},
158158
},
159+
parallel: false
159160
},
160161
) as BuildOptions;
161162

@@ -274,7 +275,7 @@ async function _build(
274275
// await symlink(resolve(ctx.rootDir), nodemodulesDir).catch(() => {})
275276
// }
276277

277-
await Promise.all([
278+
const buildTasks = [
278279
// untyped
279280
typesBuild(ctx),
280281
// mkdist
@@ -283,7 +284,16 @@ async function _build(
283284
rollupBuild(ctx),
284285
// copy
285286
copyBuild(ctx),
286-
]);
287+
];
288+
289+
// Run build tasks in parallel
290+
if (options.parallel) {
291+
await Promise.all(buildTasks);
292+
} else {
293+
for (const task of buildTasks) {
294+
await task;
295+
}
296+
}
287297

288298
// Skip rest for stub and watch mode
289299
if (options.stub || options.watch) {

src/cli.ts

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const main = defineCommand({
4141
type: "boolean",
4242
description: "Generate sourcemaps (experimental)",
4343
},
44+
parallel: {
45+
type: "boolean",
46+
description: "Run build in parallel (experimental)",
47+
},
4448
},
4549
async run({ args }) {
4650
const rootDir = resolve(process.cwd(), args.dir || ".");

src/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ export interface BuildOptions {
139139
* [Rollup](https://rollupjs.org/configuration-options) Build Options
140140
*/
141141
rollup: RollupBuildOptions;
142+
143+
/**
144+
* @experimental
145+
* Run build in parallel
146+
*/
147+
parallel: boolean;
142148
}
143149

144150
export interface BuildContext {

0 commit comments

Comments
 (0)