question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mermaid 9.2.0 triggers webpack import warning

See original GitHub issue

Description

When I import Mermaid in my Webpack project (based on backstage with plugin techdocs-addon-mermaid, 9.2.0 triggers a warning.

Compiled with problems:X

WARNING in ../../node_modules/mermaid/dist/mermaid.core.mjs 27645:52-67

Critical dependency: the request of a dependency is an expression


WARNING in ../../node_modules/mermaid/dist/mermaid.core.mjs 27659:52-63

Critical dependency: the request of a dependency is an expression

After investigating, it seems this is due to uses of await import(url) and await import(diagram), url and diagram being dynamic. Webpack sees that as bad.

I would recommend

Steps to reproduce

  1. Use Mermaid 9.2.0 in a project that uses Webpack 5.7.0

  2. Build in development mode

  3. See the issue or

  4. Install Backstage with Yarn 3 and up-to-date packages

  5. Install plug-in https://github.com/johanneswuerbach/backstage-plugin-techdocs-addon-mermaid but set MermaidJS version to 9.2.0

  6. run yarn dev

  7. see the error in the web UI.

Screenshots

No response

Code Sample

No response

Setup

Desktop

  • OS and Version: ArchLinux x86_64
  • Browser and Version: Chrome 106
  • Built with NodeJS 16, Webpack 5.7.0, Yarn 3.

Additional Context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
boldtcommented, Nov 9, 2022

9.2.2 works for me.

1reaction
Just-Siebcommented, Nov 4, 2022

I was having the same problem with our Backstage instance and trying to add that plugin in. I resolved the issue for now by setting the resolution in the top level package.json to lock it to Mermaid v9.1.1. It seems that this change

{
  ...
  "resolutions": {
    "mermaid": "9.1.1"
  },
  ...
}

I am guessing PR #3591 broke Webpack being able to import Mermaid

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mermaid 9.2.0 fails to require properly with Webpack #3754
We're utilizing webpack to bundle our application and requiring and initializing ... Mermaid 9.2.0 triggers webpack import warning #3757.
Read more >
Module Methods - webpack
It's used in conjunction with import() which takes over when user navigation triggers additional imports. warning. If the module source contains a require...
Read more >
ts-loader - npm
These calls import a module and return a promise to that module. This is also supported in webpack - details on usage can...
Read more >
ESLint - Error: Must use import to load ES Module
I am currently setting up a boilerplate with React, TypeScript, styled components, Webpack, etc., and I ...
Read more >
rollup.js
json file also has a module field, ES-module-aware tools like Rollup and webpack 2+ will import the ES module version directly. Command Line...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found