facebook / facebook/stylex

[babel-plugin] Module resolution Yarn PnP support

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

Description

### Describe the feature request

Hello. First of all, thank you for the great library!

Currently `@stylexjs/babel-plugin` uses [@dual-bundle/import-meta-resolve](https://github.com/un-es/import-meta-resolve) (a fork of [import-meta-resolve](https://github.com/wooorm/import-meta-resolve)) to resolve module paths ([code range](https://github.com/facebook/stylex/blob/0ae7448e7ddecbb68f0ff9e5e6933fc2cd04343d/packages/%40stylexjs/babel-plugin/src/utils/state-manager.js#L702-L725)).

However `import-meta-resolve` ponyfill [does not support Yarn PnP environment](https://github.com/wooorm/import-meta-resolve/issues/10). As a result, when using StyleX with Yarn PnP, it isn't possible to import styles from external packages.

---

As an alternative there is [oxc-resolver](https://github.com/oxc-project/oxc-resolver), a port of webpack's `enhanced-resolve`. It implements the CJS/ESM resolution algorithms and supports Yarn PnP.

I'm currently maintaining a fork of the StyleX babel-plugin that uses `oxc-resolver` for module resolution instead of `import-meta-resolve`:

- https://github.com/suhdonghwi/stylex/tree/oxc-resolver
- Diff: https://github.com/facebook/stylex/compare/main...suhdonghwi:stylex:oxc-resolver?expand=1

I've verified that it works in Yarn PnP mode and that all tests pass. Would you be open to accepting this change upstream? Thank you!

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.