facebook / facebook/stylex

StyleX unplugin corrupts WASM files

Open
#1,470 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
10.3k
Forks
481
Avg merge
3d 8h
Merged PRs (30d)
13

Description

### Describe the issue

The problem is pretty obscure, but when I include the Stylex unplugin to my RSBuild project all of my WASM files are getting corrupted.

I narrowed it down to a missing `transformInclude` which forces unplugin to read all the files before we can filter some for transform. Somehow this process corrupts the WASM files (which are very large output binary files).

If I include `transformInclude` to the unplugin code everything seems to be working fine by preventing unplugin to read the sources of these WASM files.

```
transformInclude(id) {
const JS_LIKE_RE =
/\.[cm]?[jt]sx?(\?|$)/;
return JS_LIKE_RE.test(id);
},
async transform(code, id) { ...
```

I can follow up with a PR to add this if this makes sense to the maintainers.

### Expected behavior

WASM files should not be affected by StyleX

### Steps to reproduce

Include StyleX unplugin to any Rsbuild project with WASM files

### Test case

_No response_

### Additional comments

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.