Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mermaid 9.2.0 fails to require properly with Webpack #3754

Closed
sgerace opened this issue Nov 3, 2022 · 4 comments · Fixed by #3774
Closed

Mermaid 9.2.0 fails to require properly with Webpack #3754

sgerace opened this issue Nov 3, 2022 · 4 comments · Fixed by #3774
Assignees
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@sgerace
Copy link

sgerace commented Nov 3, 2022

Description

We've been using Mermaid without issue for some time now and the latest version (9.2.0) breaks our application. We're utilizing webpack to bundle our application and requiring and initializing mermaid with:

// Initialize mermaid renderer
const mermaid = require('mermaid');
mermaid.initialize({
    startOnLoad: false
});

After updating to 9.2.0, we are getting the following warnings from webpack:

WARNING in ./node_modules/mermaid/dist/mermaid.min.js 1277:3945-3954
Critical dependency: the request of a dependency is an expression

And mermaid.initialize fails with the following error in the browser:

Uncaught TypeError: mermaid.initialize is not a function

It seems like there may have been changes to the bundled artifact as part of the 9.2.0 release, however, I would not expected any breaking changes as a result of a minor version change.

Steps to reproduce

Require Mermaid 9.2.0 with Webpack using CommonJS syntax.

Screenshots

No response

Code Sample

No response

Setup

Desktop

  • OS and Version: Mac
  • Browser and Version: Chrome

Additional Context

No response

@sgerace sgerace added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Nov 3, 2022
@sgerace sgerace changed the title Mermaid 9.2.0 fails to require properly in webpack build Mermaid 9.2.0 fails to require properly with Webpack Nov 3, 2022
@sidharthv96
Copy link
Member

sidharthv96 commented Nov 4, 2022

We are doing a lazy load internally, wonder if it's related.
https://stackoverflow.com/a/73359606/2212355

Is this possible?

- const mermaid = require('mermaid');
+ import mermaid from 'mermaid';

#3590 (comment) mentions that require has been broken for a while.

@sidharthv96
Copy link
Member

Can you please test 9.2.2-rc.2

@sidharthv96 sidharthv96 self-assigned this Nov 10, 2022
@sidharthv96 sidharthv96 linked a pull request Nov 10, 2022 that will close this issue
3 tasks
@sidharthv96
Copy link
Member

Fixed in 9.2.2

@sgerace
Copy link
Author

sgerace commented Nov 10, 2022

Hi @sidharthv96, sorry I wasn't able to confirm the fix yesterday. I can confirm that the fixed published in 9.2.2 does indeed fix the issue for us. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants