Webpack fails to compile after importing mjml2html
See original GitHub issueHey there,
I’m running into an issue using mjml2html
in a local Vue CLI 3 project (Vue CLI 3 runs on webpack). I’ve installed mjml - "mjml": "^4.2.0-beta.3"
- and I’m importing the function as such - import mjml2html from 'mjml'
. Once I’ve imported, my app breaks with the following warnings:
Warnings generated in terminal:
warning in ./node_modules/mjml-core/lib/index.js
Critical dependency: the request of a dependency is an expression
warning in ./node_modules/mjml-core/lib/helpers/mjmlconfig.js
Critical dependency: the request of a dependency is an expression
warning in ./node_modules/mjml-core/lib/helpers/mjmlconfig.js
Critical dependency: the request of a dependency is an expression
warning in ./node_modules/mjml-core/lib/helpers/mjmlconfig.js
Critical dependency: the request of a dependency is an expression
warning in ./node_modules/uglify-js/tools/node.js
Critical dependency: the request of a dependency is an expression
Warnings/error generated by the browser console:

I’ve also tried this using react (create-react-app), and I’m running into the same issue. Is anyone else experiencing this?
Any help would be greatly appreciated.
Reproduction Steps:
- Generate a create-react-app, or Vue CLI 3 project
- Install mjml -
yarn add mjml
- Import
mjml2html
anywhere in the project -import mjml2html from 'mjml'
MJML version:
"mjml": "^4.2.0-beta.3"
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:14 (4 by maintainers)
Top Results From Across the Web
Webpack suddenly fails to compile due to "Module not ...
To do this, we import our webpack config and then plug various values into the Karma webpack config. Building the scripts directly using...
Read more >Building a Webpack plugin to generate localized emails
After some initial prototyping, we landed on using MJML, ... Webpack will drive compilation and take that React code and data to build...
Read more >How to use the mjml.mjml2html function in mjml
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >Issue with 4.9.0 + webpack + typescript
I'm not such a webpack specialist, but it seems to me that webpack does not compile node_modules content and this causes later errors....
Read more >webpack/webpack - Gitter
However, when I wrap it all in a webpack build and use postcss-loader it appears that postcss-loader runs ... webpack serve [webpack-cli] Failed...
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 Free
Top 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
MJML uses html-minifier, which uses uglify-js, and uglify-js is not compatible with Webpack.
Related issue: https://github.com/mishoo/UglifyJS2/issues/3312
[Edit]: And I’ve finally found a workaround, thanks to this post: https://github.com/kangax/html-minifier/issues/727
@ShanakaNCG what is your problem exactly ? from what i read here, the problem was that he was trying to import
mjml2html
on the client side. This is not possible because mjml uses node libs, i.e.fs
to handle mj-include. You have to use it server side, if you don’t have a node server you could use the api https://mjml.io/api