diff --git a/src/build.ts b/src/build.ts index 92dd95a6..94aa026d 100644 --- a/src/build.ts +++ b/src/build.ts @@ -155,6 +155,7 @@ async function _build( respectExternal: true, }, }, + parallel: false, }, ) as BuildOptions; @@ -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) { diff --git a/src/cli.ts b/src/cli.ts index 47f0ae17..8c6c8960 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -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 || "."); diff --git a/src/types.ts b/src/types.ts index 1e5cb3f1..40de9a8a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -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 {