Skip to content

[babel-plugin] Support ESM module resolution #1051

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

Open
sergiocarneiro opened this issue May 7, 2025 · 2 comments
Open

[babel-plugin] Support ESM module resolution #1051

sergiocarneiro opened this issue May 7, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@sergiocarneiro
Copy link

Describe the feature request

The web is moving away from CommonJS, and StyleX is currently the only reason I still need to distribute my libraries in CommonJS.

Tooling gets significantly simpler once I can drop CommonJS support, so I’m hoping you can support ESM soon—if it doesn’t introduce too much complexity on your side.

[
  "@stylexjs/babel-plugin",
  {
    unstable_moduleResolution: {
      type: "ESM"
    }
  }
]

Looking forward, thanks!

@sergiocarneiro sergiocarneiro added the enhancement New feature or request label May 7, 2025
@necolas
Copy link
Contributor

necolas commented May 7, 2025

Are you encountering a specific issue?

The docs - https://stylexjs.com/docs/api/configuration/babel-plugin/ - are confusing because they say to use commonJS for ESModules. So I think it already works, but the API is confusing. It will get refactored at some point

@sergiocarneiro
Copy link
Author

Are you encountering a specific issue?

I'm not able to get the babel/postcss plugins to work with my Vite setup, and since this developer mentioned issues as well until he split the configuration into dedicated cjs files .babelrc.cjs and postcss.config.cjs, and I've had other issues in the past integrating commonjs packages in this setup, so I thought it could be a potential cause.

But the issue does not directly mention commonjs, so you may be right, it may be already working with ESM. The issue is the typical:

Unexpected 'stylex.create' call at runtime. Styles must be compiled by '@stylexjs/babel-plugin'.

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

No branches or pull requests

2 participants