martonlederer / esbuild-plugin-postcss2

Use postcss with esbuild
MIT License
33 stars 19 forks source link

Workaround for evanw/esbuild#1101 #16

Closed timostamm closed 3 years ago

timostamm commented 3 years ago

Hey Marton, thanks for this plugin!

We ran into an issue while using CSS modules. esbuild fails intermittently with an error message like Could not resolve "/var/folders/rw/dlkdb0bn74j4j0wgp_q233qc0000gn/T/xxx/xxx/xxx/1628683474625-xxx.module.css".

esbuild is looking for the build artifact 1628683474625-xxx.module.css by listing directory entries. The file does exist at this point, but esbuild is unable to find it among other directory entries. This appears to be issue evanw/esbuild#1101 (though the mentioned workaround export GODEBUG=asyncpreemptoff=1 did not work for us).

This PR makes sure those artifacts are always the single entry in a unique temp directory, which fixes the issue for us.

martonlederer commented 3 years ago

Amazing, happy to see this fixed. I'll test this today :)

martpie commented 3 years ago

Awesome, looking forward!

martonlederer commented 3 years ago

Sorry for the wait. I messed up some stuff so I'll be merging this from #18

martpie commented 3 years ago

Small question, it seems that in watch mode, [esbuild-css-modules-plugin] Clean temp files... is constantly triggered, any idea what could cause this?

martonlederer commented 3 years ago

Sorry, no, but I'm happy to take a look at a PR if you figure out anything

martpie commented 3 years ago

Thinking out loud: watch mode may be triggered every time a temp file is created in the working directory, so we might need to create them somewhere else, and not just next to their original file.

I will clone the plugin and see if it's that or something else. 👍

martonlederer commented 3 years ago

You're probably right 🤔

timostamm commented 3 years ago

For the example at the top, /var/folders/rw/dlkdb0bn74j4j0wgp_q233qc0000gn/T/xxx/xxx/xxx/1628683474625-xxx.module.css did exist in the file system after the build failure (and contained the expected content).