shellscape / jsx-email

Build emails with a delightful DX
https://jsx.email
MIT License
897 stars 28 forks source link

Build/Check cli commands throw Error: Cannot find module 'jsx-email' #137

Closed tom3rr closed 5 months ago

tom3rr commented 5 months ago

Expected Behavior

Running email build ./templates/Reproduction.tsx should successfully build the template.

Running email check ./templates/Reproduction.tsx should successfully run the compatibility check.

Actual Behavior

Throws and error instead: Error: Cannot find module 'jsx-email'

Additional Information

The behaviour is the same in local Windows environment as in repro link.

shellscape commented 5 months ago

@tom3rr confirmed that your reproduction has the issue. looking into it...

shellscape commented 5 months ago

Alright this is almost certainly related to this change: https://github.com/shellscape/jsx-email/commit/e0a7eb44a96b85fed54d918bd3a05b788606267d#diff-956e216fa7df03ccf64dcfcbe8fdacf5560897b6726255ff29c1c3c8cc757721R124 and the way that pnpm, yarn, and npm differ in how they create binaries in node_modules/.bin

I was able to reproduce this locally with yarn and npm as well. I couldn't reproduce it locally with pnpm, but I could on the stackblitz repro. The preview works locally with all the package managers (this is something I would expect, because Vite is a different animal) but fails on stackblitz.

Under pnpm, the binary file in node_modules/.bin contains path information whereas npm and yarn are just straight up copies of the target file. Under pnpm, the compiled template file has context as to where it's being run, so it can use the local node_modules. Apparently on npm/yarn, this is not the case.

I'll revert that change shortly and publish a fix.

tom3rr commented 5 months ago

@lordelogos same result with yarn run

@shellscape Thanks for the fast response and fix. I can confirm that in 1.7.3 the issue is no longer present.