mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
da7ff777d1
mermaid.min.js and mermaid.js will now be IIFE instead of UMD.
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { build } from 'esbuild';
|
|
import { mkdir, writeFile } from 'node:fs/promises';
|
|
import { getBuildConfig } from './util.js';
|
|
import { packageOptions } from '../.build/common.js';
|
|
|
|
const shouldVisualize = process.argv.includes('--visualize');
|
|
|
|
const buildPackage = async (entryName: keyof typeof packageOptions) => {
|
|
await build(getBuildConfig({ entryName, minify: false }));
|
|
const { metafile } = await build(
|
|
getBuildConfig({ entryName, minify: true, metafile: shouldVisualize })
|
|
);
|
|
if (metafile) {
|
|
// Upload metafile into https://esbuild.github.io/analyze/
|
|
await writeFile(`stats/meta-${entryName}.json`, JSON.stringify(metafile));
|
|
}
|
|
await build(getBuildConfig({ entryName, minify: false, core: true }));
|
|
await build(getBuildConfig({ entryName, minify: true, format: 'iife' }));
|
|
};
|
|
|
|
const handler = (e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
};
|
|
|
|
const main = async () => {
|
|
await mkdir('stats').catch(() => {});
|
|
const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[];
|
|
for (const pkg of packageNames) {
|
|
await buildPackage(pkg).catch(handler);
|
|
}
|
|
};
|
|
|
|
void main();
|