shellscape / jsx-email

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

Does not build on windows #41

Closed Yaro77 closed 10 months ago

Yaro77 commented 10 months ago

Expected Behavior

Build works on Windows

Actual Behavior

It doesn't

Additional Information

Can't create PR now Build command uses globby, which returns empty arrays on windows paths. You should use globby([slash(join(temp, "*.js")]) everywhere in CLI. Thanks

shellscape commented 10 months ago

no need for reproduction

Sorry, but that's not true. If you're not willing to help demonstrate the issue, I'm afraid there's nothing we can do to help.

None of the current maintainers are Windows users, so I'd recommend using WSL for the time being.

bhuynhdev commented 10 months ago

Hi, just want to let the team know that I am experiencing the same issue in Windows. The Development server works fine, but when I run pnpm run build, it says found 0 files, even though my templates folder contains one file "jsx-email-starter". This is for a brand-new project just created using the cli (version 1.1.0).

email build ./templates

Found 0 files:

Starting build...

Build complete. Files written to: ...

I understand that none of the current maintainers are Windows users, so I am just communicating here to raise some awareness to the issue. Will try to make a PR if possible

shellscape commented 10 months ago

A PR would be great. Appreciate the additional info. This issue is more than likely the result of the older version of globby that we're using at the moment. I still don't know what exact fix the OP was referencing, but it probably has to do with path normalization.

bhuynhdev commented 10 months ago

I dug around for a bit, and per this issue https://github.com/sindresorhus/globby/issues/179, it seems that the glob pattern must only contain forward slashes, but the path functions on Windows return backslashes.

Therefore, I replaced globby([glob]) with globby([glob.replace(/\\/g, '/')]) in the build function, and then globby([path.join(outDir, '*.js').replace(/\\/g, '/')]) in the compile function. The CLI now successfully detected the files and build and output correct HTML. I did run into "cannot find modules react/jsx-runtime" but solved it by running pnpm add react

I am trying to make a PR but the steps in the CONTRIBUTING.md doc seems to not work on both my Windows and my WSL. I have Nodejs 18.18.2, and have ran pnpm boostrap successfully. But when I run moon run repo:build.packages, I got error

Error: project_graph::unknown_project

  × No project has been configured with the name or alias jsx-email.
shellscape commented 10 months ago

Thanks for the heads up, I'll get the doc updated. In place of jsx-email use repo for moon commands.

shellscape commented 10 months ago

Also here's rollup's path normalization routine that's very proven, for reference https://github.com/rollup/plugins/blob/master/packages/pluginutils/src/normalizePath.ts#L5

shellscape commented 10 months ago

Attempted to setup a workflow matrix so we could use github actions to try and debug, but unfortunately there's an issue between pnpm and vue-demi that needs to be resolved before things will work correctly https://github.com/pnpm/pnpm/issues/6696#issuecomment-1784177984

bhuynhdev commented 10 months ago

Oh it was my bad, as I didn't name my folder jsx-email (Moon tried to decipher the project name from folder name). I renamed the folder name correctly and am now using WSL (since the command rm -rf doesn't work on Windows), but ran into Cannot find module '@jsx-email/render' error after running moon repo:build.packages.

Never mind, I solved this by running moon run repo:build.critical before moon run repo:build.packages, and then moon run repo:build.last after; everything seem to have built successfully

Successfully created https://github.com/shellscape/jsx-email/pull/44 after confirming that moon run repo:lint and moon run repo:test.packages work successfully (repo:lint actually has errors about Unable to resolve path to module '@jsx-email/all' in the apps/demo/emails/... .tsx files, but I don't think that was my fault)

shellscape commented 10 months ago

Thanks for working through that. We'll get that doc updated 👍