webpack-plugin includes @babel/plugin-transform-modules-commonjs
#877
Labels
bug
Something isn't working
@babel/plugin-transform-modules-commonjs
#877
Describe the issue
I was debugging an issue with our Webpack build, where some imports of a node_modules package would resolve to the CJS version, and some other imports would resolve to the ESM version.
I root caused this to
@babel/plugin-transform-modules-commonjs
being included in the babel transform. With this plugin, files that contain StyleX imports get converted to commonJS, which Webpack then treats differently.Example:
The presence of the
require
statement causes Webpack to resolve to the CJS version of the package, whereas for the other file, it resolves to the ESM version.I expect this also has ramifications for tree shaking algorithms that operate on the computed dependency graph.
Expected behavior
Running the StyleX loader on source files should not have any additional transforms, other than for StyleX.
Steps to reproduce
jotai
. Add StyleX plugin to the Webpack configurationa. One should import styleX and jotai
b. The other should just import jotai
jotai/index.js
andjotai/esm/vanilla.mjs
Test case
No response
Additional comments
Is the commonJS plugin required to make StyleX functional?
The text was updated successfully, but these errors were encountered: