Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for evanw/esbuild#1101 #16

Closed

Conversation

timostamm
Copy link
Contributor

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.

esbuild is unable to find the file, even though it does exist. This only happens for files in a directory with several other entries, so by creating a unique directory name per file on every build, we guarantee that there will only every be a single file present within the directory, circumventing the esbuild issue.
@martonlederer
Copy link
Owner

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

@martpie
Copy link

martpie commented Aug 14, 2021

Awesome, looking forward!

@martpie martpie mentioned this pull request Aug 16, 2021
4 tasks
@martonlederer
Copy link
Owner

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

@martpie
Copy link

martpie commented Aug 23, 2021

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
Copy link
Owner

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

@martpie
Copy link

martpie commented Aug 23, 2021

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
Copy link
Owner

You're probably right 🤔

@timostamm
Copy link
Contributor Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants