mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
chore: Remove mermaid.default
Co-authored-by: Alois Klink <alois@aloisklink.com>
This commit is contained in:
@@ -49,6 +49,7 @@ export const getBuildConfig = ({
|
||||
}`]: `src/${file}`,
|
||||
},
|
||||
metafile,
|
||||
logLevel: 'info',
|
||||
});
|
||||
|
||||
if (core) {
|
||||
@@ -65,7 +66,10 @@ export const getBuildConfig = ({
|
||||
if (format === 'iife') {
|
||||
output.format = 'iife';
|
||||
output.splitting = false;
|
||||
output.globalName = 'mermaid';
|
||||
output.globalName = '__esbuild_esm_mermaid';
|
||||
output.footer = {
|
||||
js: 'globalThis.mermaid = globalThis.__esbuild_esm_mermaid.default;',
|
||||
};
|
||||
output.outExtension = { '.js': '.js' };
|
||||
} else {
|
||||
output.format = 'esm';
|
||||
|
@@ -12,12 +12,12 @@ graph TB
|
||||
|
||||
<script src="/mermaid.min.js"></script>
|
||||
<script>
|
||||
mermaid.default.initialize({
|
||||
mermaid.initialize({
|
||||
startOnLoad: true,
|
||||
});
|
||||
const value = `graph TD\nHello --> World`;
|
||||
const el = document.getElementById('d2');
|
||||
mermaid.default.render('did', value).then(({ svg }) => {
|
||||
mermaid.render('did', value).then(({ svg }) => {
|
||||
console.log(svg);
|
||||
el.innerHTML = svg;
|
||||
if (window.Cypress) {
|
||||
|
@@ -270,23 +270,6 @@ if (typeof document !== 'undefined') {
|
||||
* Wait for document loaded before starting the execution
|
||||
*/
|
||||
window.addEventListener('load', contentLoaded, false);
|
||||
window.addEventListener('error', ({ message }) => {
|
||||
// Get mermaid function called from error message with regex
|
||||
const match = message.match(/mermaid\.(\w+) is not a function/);
|
||||
if (match) {
|
||||
const notify = () =>
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`------------------------------
|
||||
Breaking change in Mermaid v11
|
||||
------------------------------
|
||||
Use mermaid.default.${match[1]}() instead of mermaid.${match[1]}()
|
||||
Read more: https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0
|
||||
`);
|
||||
notify();
|
||||
// Log again after a delay to ensure it's the last message
|
||||
setTimeout(notify, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user