wix-incubator / mjml-react

React component library to generate the HTML emails on the fly
MIT License
993 stars 50 forks source link

Module not found : Can't resolve 'fs' #84

Closed MrArun005 closed 2 years ago

MrArun005 commented 2 years ago

After installing npm mjml-react and when i try to import any element such as import {mjml} from 'mjml-react'. it is throwing an error which says "Module not found : Can't resolve 'fs' ". Please guide me through on how to render in inside my NGINX web application.

daliusd commented 2 years ago

You should give more context. Is your application working in other environments?

MrArun005 commented 2 years ago

should i have developed a NGINX web application, where i have email gateway which is now basically supports HTML emails and plain emails. Now keeping an eye on future i want to implement mjml-react library also in my project after installing npm mjml-react. when i try to use any elements from that library im facing a problem, Module not found : can't resolve 'fs' and My application is working completely fine.

daliusd commented 2 years ago

Have you followed instructions and installed both mjml-react and mjml ? Do you have minimal reproducible case where mjml-react is not working for you?

MrArun005 commented 2 years ago

Yes, I have installed both the library namely mjml-react and mjml. I am writing a component that, I can export (named export) into my main index.js as a result its throwing errors, which are

Can't resolve 'url' Can't resolve 'fs' Can't resolve 'path' Can't resolve 'crypto' Can't resolve 'os'

daliusd commented 2 years ago

This is core node libraries. I assume they can be unresolved only if you are doing something for browser. Then look for ideas https://github.com/wix-incubator/mjml-react/issues/52

In the end it is not problem with the library. I am closing this issue now. Please return with working reproducible example if you want to reopen it.

pachuka commented 2 years ago

@daliusd - I know you've closed this ticket as resolved due to core node libraries being used and I get that, but I do think its worth a discussion.

Being able to use react-mjml in a browser enviornment only breaks after the minify changes were introduced in the latest release (fine in 2.0.7, doesn't work in 2.0.8) as part of https://github.com/wix-incubator/mjml-react/pull/75.

In my opinion, leave minification up to the consumers of the application, if folks are working with React they most likely have some sort of bundling tooling in place already such as rollup/webpack/etc. where they can minify the output however they want.

Otherwise at least make it opt-in, update it to be a peer dep and as of NPM7 we can annotate those to optional, then enable minification if that peer dep is included. That allows you to have minifcation and still continue to support those browser use cases.

Thanks!

EDIT: This did end up being a breaking change for us so it coming through as a patch semver change wasn't great for automatic dependency management