Mermaid 9.2.0 triggers webpack import warning
See original GitHub issueDescription
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
-
Use Mermaid 9.2.0 in a project that uses Webpack 5.7.0
-
Build in development mode
-
See the issue or
-
Install Backstage with Yarn 3 and up-to-date packages
-
Install plug-in https://github.com/johanneswuerbach/backstage-plugin-techdocs-addon-mermaid but set MermaidJS version to 9.2.0
-
run yarn dev
-
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:
- Created a year ago
- Reactions:2
- Comments:8 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
9.2.2 works for me.
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
I am guessing PR #3591 broke Webpack being able to import Mermaid