Skip to content

Commit

Permalink
feat: support parallel builds
Browse files Browse the repository at this point in the history
Co-authored-by: Pooya Parsa <[email protected]>
  • Loading branch information
Sunny-117 and pi0 committed Dec 27, 2024
1 parent bf8de6b commit af19b1b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ async function _build(
respectExternal: true,
},
},
parallel: false,
},
) as BuildOptions;

Expand Down Expand Up @@ -273,17 +274,20 @@ async function _build(
// await symlink(resolve(ctx.rootDir), nodemodulesDir).catch(() => {})
// }

// untyped
await typesBuild(ctx);

// mkdist
await mkdistBuild(ctx);

// rollup
await rollupBuild(ctx);

// copy
await copyBuild(ctx);
const buildTasks = [
typesBuild, // untyped
mkdistBuild, // mkdist
rollupBuild, // rollup
copyBuild, // copy
] as const;

if (options.parallel) {
await Promise.all(buildTasks.map((task) => task(ctx)));
} else {
for (const task of buildTasks) {
await task(ctx);
}
}

// Skip rest for stub and watch mode
if (options.stub || options.watch) {
Expand Down
5 changes: 5 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const main = defineCommand({
type: "boolean",
description: "Generate sourcemaps (experimental)",
},
parallel: {
type: "boolean",
description:
"Run different types of builds (untyped, mkdist, Rollup, copy) simultaneously.",
},
},
async run({ args }) {
const rootDir = resolve(process.cwd(), args.dir || ".");
Expand Down
5 changes: 5 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ export interface BuildOptions {
* [Rollup](https://rollupjs.org/configuration-options) Build Options
*/
rollup: RollupBuildOptions;

/**
* Run different types of builds (untyped, mkdist, Rollup, copy) simultaneously.
*/
parallel: boolean;
}

export interface BuildContext {
Expand Down

0 comments on commit af19b1b

Please sign in to comment.