Skip to content

Commit dc72eec

Browse files
committed
[build] Split out prod build function
1 parent fb3d8c4 commit dc72eec

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

gulpfile.mjs

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,41 @@ const test = async (
639639
}
640640
};
641641

642+
const compileModulesForProd = async (fast = false) => {
643+
await clearDir(DIST_DIR);
644+
await copyPackageFiles(true);
645+
await copyDefinitions(DIST_DIR);
646+
647+
await allOf(
648+
[undefined, 'umd', ...(fast ? [] : ['cjs'])],
649+
async (format) =>
650+
await allOf(
651+
[undefined, ...(fast ? [] : ['es6'])],
652+
async (target) =>
653+
await allModules(
654+
async (module) =>
655+
await allOf(
656+
[undefined, 'min'],
657+
async (min) =>
658+
await compileModule(
659+
module,
660+
`${DIST_DIR}/` +
661+
[format, target, min]
662+
.filter((part) => part != null)
663+
.join('/'),
664+
format,
665+
target,
666+
min,
667+
),
668+
),
669+
),
670+
),
671+
);
672+
673+
await compileModule('cli', DIST_DIR, undefined, undefined, undefined, true);
674+
await execute(`chmod +x ${DIST_DIR}/cli/index.js`);
675+
};
676+
642677
const compileDocsAndAssets = async (api = true, pages = true) => {
643678
const {default: esbuild} = await import('esbuild');
644679
const {default: esbuildPlugin} = await import('rollup-plugin-esbuild');
@@ -720,42 +755,9 @@ export const ts = async () => {
720755
await tsCheck('site');
721756
};
722757

723-
export const compileForProdFast = async () => await compileForProd(true);
758+
export const compileForProd = async () => await compileModulesForProd();
724759

725-
export const compileForProd = async (fast = false) => {
726-
await clearDir(DIST_DIR);
727-
await copyPackageFiles(true);
728-
await copyDefinitions(DIST_DIR);
729-
730-
await allOf(
731-
[undefined, 'umd', ...(fast ? [] : ['cjs'])],
732-
async (format) =>
733-
await allOf(
734-
[undefined, ...(fast ? [] : ['es6'])],
735-
async (target) =>
736-
await allModules(
737-
async (module) =>
738-
await allOf(
739-
[undefined, 'min'],
740-
async (min) =>
741-
await compileModule(
742-
module,
743-
`${DIST_DIR}/` +
744-
[format, target, min]
745-
.filter((part) => part != null)
746-
.join('/'),
747-
format,
748-
target,
749-
min,
750-
),
751-
),
752-
),
753-
),
754-
);
755-
756-
await compileModule('cli', DIST_DIR, undefined, undefined, undefined, true);
757-
await execute(`chmod +x ${DIST_DIR}/cli/index.js`);
758-
};
760+
export const compileForProdFast = async () => await compileModulesForProd(true);
759761

760762
export const testUnit = async () => {
761763
await test(['test/unit'], {coverageMode: 1, serialTests: true});

0 commit comments

Comments
 (0)