I am working in a Webpack + React + TypeScript + StyleX environment.
In Webpack, both [babel-loader, ts-loader] are configured.
When running Webpack in development mode, the following error appears in the browser:
Uncaught Error: 'stylex.create' should never be called at runtime. It should be compiled away by '@stylexjs/babel-plugin'
at eval (App.tsx:40:23)
at ./src/App.tsx (main.js:503:1)
at __webpack_require__ (main.js:993:32)
at fn (main.js:1200:21)
at eval (index.tsx:22:15)
at ./src/index.tsx (main.js:514:1)
at __webpack_require__ (main.js:993:32)
at main.js:2071:37
This error occurs when using ts-loader as the file loader.
※ The issue does not occur when using babel-loader.
We need to use ts-loader for strong type-checking.
Please investigate and resolve this error so that StyleX can work with ts-loader.
Expected behavior
The web page should work correctly without errors.
Describe the issue
※ I couldn’t find a solution from the following discussion: https://github.com/facebook/stylex/discussions/427
I am working in a Webpack + React + TypeScript + StyleX environment. In Webpack, both [babel-loader, ts-loader] are configured.
When running Webpack in development mode, the following error appears in the browser:
This error occurs when using ts-loader as the file loader. ※ The issue does not occur when using babel-loader.
We need to use ts-loader for strong type-checking.
Please investigate and resolve this error so that StyleX can work with ts-loader.
Expected behavior
The web page should work correctly without errors.
Steps to reproduce
I have attached a project that can be tested as follows. stylex-ts-loader-test.zip
package.json
webpack.config.js
index.tsx
App.tsx
The following is the execution result screen.
Please resolve the issue.
Test case
No response
Additional comments
No response