Faire / mjml-react

React component library to generate the HTML emails on the fly
https://www.npmjs.com/package/@faire/mjml-react
MIT License
375 stars 16 forks source link

ReferenceError: require is not defined - after building the project #96

Closed viktorkasap closed 1 year ago

viktorkasap commented 1 year ago

This issue is continuation of previews #93

Google Chrome2023-02-24 at 11 04 10

So, we've solved 'process' problem, and after building the project and running the via browser-sync from ./dist I get new error

Uncaught ReferenceError: require is not defined
    at index-058953bb.js:40:57774

Actually to get this error you can just add this import and nothing else

PhpStorm2023-02-24 at 11 22 47@2x

First Screen - npm run dev Second Screen - browser-sync ./dist

Google Chrome2023-02-24 at 12 39 11

IanEdington commented 1 year ago

~html-entries is exported from utils/index are you using @faire/mjml-react/utils anywhere in your package? Otherwise your build might be picking it up from the utils index.~

~You could also try importing from the esm folder and see if that helps @faire/mjml-react/esm/...~

see below

emmclaughlin commented 1 year ago

Every component uses @faire/mjml-react/utils as they rely on this function: https://github.com/Faire/mjml-react/blob/main/src/utils/mjml-component-utils.ts#L9 and then the re-export includes html-entities https://github.com/Faire/mjml-react/blob/main/src/utils/index.ts#L1

I think we need to fix this line to be an import statement instead of require. Right now it compiles to require in esm. I'll look at putting up a fix today.

emmclaughlin commented 1 year ago

@kasapvictor this PR should fix the issue. Please upgrade to v3.1.2 and try again

viktorkasap commented 1 year ago

@emmclaughlin Oh my God, you made it so fast, it's unbelievable =) Thank you again.

viktorkasap commented 1 year ago

@kasapvictor this PR should fix the issue. Please upgrade to v3.1.2 and try again

Yes! It works! 🙏🙏🙏