fix: Add `.core` build.

This commit is contained in:
Sidharth Vinod 2022-09-09 17:32:13 +05:30
parent ffcb73ad5f
commit 1029ce4527
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 15 additions and 3 deletions

View File

@ -7,8 +7,15 @@ const handler = (e) => {
};
const watch = process.argv.includes('--watch');
// mermaid.js
build(umdBuild({ minify: false, watch })).catch(handler);
// mermaid.esm.mjs
build(esmBuild({ minify: false, watch })).catch(handler);
// mermaid.core.js
build(umdBuild({ minify: false, core: true })).catch(handler);
// mermaid.min.js
build(esmBuild()).catch(handler);
// mermaid.esm.min.mjs
build(umdBuild()).catch(handler);

View File

@ -39,12 +39,17 @@ exports.esmBuild = (override = { minify: true }) => {
};
/**
* @param {Options} override
* @param {Options & { core?: boolean }} override
* @returns {Options}
*/
exports.umdBuild = (override = { minify: true }) => {
exports.umdBuild = (override = { minify: true, core: false }) => {
const core = override.core;
if (core && override.minify) {
throw new Error('Cannot minify core build');
}
delete override.core;
return buildOptions({
outfile: `dist/mermaid${override.minify ? '.min' : ''}.js`,
outfile: `dist/mermaid${override.minify ? '.min' : core ? '.core' : ''}.js`,
...override,
});
};