mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-28 04:36:45 +02:00
Merge pull request #6465 from aloisklink/build/fix-mermaid-zenuml
build: fix `mermaid-zenuml` IIFE build and add changesets
This commit is contained in:
7
.changeset/honest-trees-dress.md
Normal file
7
.changeset/honest-trees-dress.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
'@mermaid-js/mermaid-zenuml': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chore: bump minimum ZenUML version to 3.23.28
|
||||||
|
|
||||||
|
commit: 9d06d8f31e7f12af9e9e092214f907f2dc93ad75
|
7
.changeset/yellow-mirrors-change.md
Normal file
7
.changeset/yellow-mirrors-change.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
'@mermaid-js/mermaid-zenuml': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(zenuml): limit `peerDependencies` to Mermaid v10 and v11
|
||||||
|
|
||||||
|
commit: 0ad44c12feead9d20c6a870a49327ada58d6e657
|
@@ -34,6 +34,19 @@ const buildPackage = async (entryName: keyof typeof packageOptions) => {
|
|||||||
{ ...iifeOptions, minify: true, metafile: shouldVisualize }
|
{ ...iifeOptions, minify: true, metafile: shouldVisualize }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (entryName === 'mermaid-zenuml') {
|
||||||
|
const iifeOptions: MermaidBuildOptions = {
|
||||||
|
...commonOptions,
|
||||||
|
format: 'iife',
|
||||||
|
globalName: 'mermaid-zenuml',
|
||||||
|
};
|
||||||
|
buildConfigs.push(
|
||||||
|
// mermaid-zenuml.js
|
||||||
|
{ ...iifeOptions },
|
||||||
|
// mermaid-zenuml.min.js
|
||||||
|
{ ...iifeOptions, minify: true, metafile: shouldVisualize }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const results = await Promise.all(buildConfigs.map((option) => build(getBuildConfig(option))));
|
const results = await Promise.all(buildConfigs.map((option) => build(getBuildConfig(option))));
|
||||||
|
|
||||||
|
@@ -58,6 +58,7 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
|
|||||||
format,
|
format,
|
||||||
minify,
|
minify,
|
||||||
options: { name, file, packageName },
|
options: { name, file, packageName },
|
||||||
|
globalName = 'mermaid',
|
||||||
} = options;
|
} = options;
|
||||||
const external: string[] = ['require', 'fs', 'path'];
|
const external: string[] = ['require', 'fs', 'path'];
|
||||||
const outFileName = getFileName(name, options);
|
const outFileName = getFileName(name, options);
|
||||||
@@ -68,6 +69,7 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
|
|||||||
},
|
},
|
||||||
metafile,
|
metafile,
|
||||||
minify,
|
minify,
|
||||||
|
globalName,
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
chunkNames: `chunks/${outFileName}/[name]-[hash]`,
|
chunkNames: `chunks/${outFileName}/[name]-[hash]`,
|
||||||
define: {
|
define: {
|
||||||
@@ -89,11 +91,12 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => {
|
|||||||
if (format === 'iife') {
|
if (format === 'iife') {
|
||||||
output.format = 'iife';
|
output.format = 'iife';
|
||||||
output.splitting = false;
|
output.splitting = false;
|
||||||
output.globalName = '__esbuild_esm_mermaid';
|
const originalGlobalName = output.globalName ?? 'mermaid';
|
||||||
|
output.globalName = `__esbuild_esm_mermaid_nm[${JSON.stringify(originalGlobalName)}]`;
|
||||||
// Workaround for removing the .default access in esbuild IIFE.
|
// Workaround for removing the .default access in esbuild IIFE.
|
||||||
// https://github.com/mermaid-js/mermaid/pull/4109#discussion_r1292317396
|
// https://github.com/mermaid-js/mermaid/pull/4109#discussion_r1292317396
|
||||||
output.footer = {
|
output.footer = {
|
||||||
js: 'globalThis.mermaid = globalThis.__esbuild_esm_mermaid.default;',
|
js: `globalThis[${JSON.stringify(originalGlobalName)}] = globalThis.${output.globalName}.default;`,
|
||||||
};
|
};
|
||||||
output.outExtension = { '.js': '.js' };
|
output.outExtension = { '.js': '.js' };
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user