mermaid/.esbuild/esbuild.cjs
Alois Klink 37aaca0090
build: convert core build to unbundled ESM
The `mermaid.core.js` build was previously a UMD build that did not
have `node_modules` bundled.

This was designed for users to add `mermaid` to their own apps,
then bundle with Webpack/ESBuild.
Hence the bundle test in `cypress/platform/bundle-test.js`.

As ESBuild does not support UMD, I've switched the `mermaid.core.js`
to instead use ESM, as Mermaid now requires ESM
(due to d3 requiring ESM). All modern bundlers also support ESM.
2022-09-11 21:56:30 +01:00

21 lines
568 B
JavaScript

const { esmBuild, esmCoreBuild, iifeBuild } = require('./util.cjs');
const { build } = require('esbuild');
const handler = (e) => {
console.error(e);
process.exit(1);
};
const watch = process.argv.includes('--watch');
// mermaid.js
build(iifeBuild({ minify: false, watch })).catch(handler);
// mermaid.esm.mjs
build(esmBuild({ minify: false, watch })).catch(handler);
// mermaid.min.js
build(esmBuild()).catch(handler);
// mermaid.esm.min.mjs
build(iifeBuild()).catch(handler);
// mermaid.core.mjs (node_modules unbundled)
build(esmCoreBuild()).catch(handler);