chore: Remove mermaid.default

Co-authored-by: Alois Klink <alois@aloisklink.com>
This commit is contained in:
Sidharth Vinod
2023-08-12 20:10:51 +05:30
parent dce65c6059
commit d8b91dbcf6
3 changed files with 7 additions and 20 deletions

View File

@@ -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';

View File

@@ -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) {

View File

@@ -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);
}
});
}
/**