You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Vite.js, the conversion of yield* to yield performed by typed-redux-saga/macro can fail when the vite-plugin-babel-macros is placed after @vitejs/plugin-react in the project's configuration.
This issue arises in particular when a yield* expression is used in conjunction with the as TypeScript operator, as in the following example:
Set up a minimal Vite.js project with the provided configuration.
Observe the order of plugins in the vite.config.js file.
Run the project using npx vite.
Expected Behavior:
The project should execute successfully, maintaining proper conversion of yield* to yield with the use of the typed-redux-saga/macro library.
Actual Behavior:
When the vite-plugin-babel-macros is placed after @vitejs/plugin-react in the Vite.js configuration, the yield* conversion is not performed as expected. This leads to runtime errors, such as:
TypeError: yield* (intermediate value) is not iterable
at index.tsx:9:11
...
This issue affects the correct functioning of the typed-redux-saga macro when used in combination with vite-plugin-babel-macros and @vitejs/plugin-react.
When @vitejs/plugin-react runs first, the AST seems to be transformed incorrectly. For instance, (yield* call(alert, 'it works')) as void becomes yield* (call(alert, 'it works') as void). The extra TSAsExpression node inside the YieldExpression node breaks the simple scheme used by typed-redux-saga/macro.
While the actual issue seems to be with @vitejs/plugin-react, a simple work-around is to place vite-plugin-babel-macros before @vitejs/plugin-react in the configuration.
The text was updated successfully, but these errors were encountered:
Description:
When using Vite.js, the conversion of
yield*
toyield
performed bytyped-redux-saga/macro
can fail when thevite-plugin-babel-macros
is placed after@vitejs/plugin-react
in the project's configuration.This issue arises in particular when a
yield*
expression is used in conjunction with theas
TypeScript operator, as in the following example:Reproduction Steps:
vite.config.js
file.npx vite
.Expected Behavior:
The project should execute successfully, maintaining proper conversion of
yield*
toyield
with the use of thetyped-redux-saga/macro
library.Actual Behavior:
When the
vite-plugin-babel-macros
is placed after@vitejs/plugin-react
in the Vite.js configuration, theyield*
conversion is not performed as expected. This leads to runtime errors, such as:Example Project Configuration:
vite.config.js
Environment:
Additional Context:
This issue affects the correct functioning of the
typed-redux-saga
macro when used in combination withvite-plugin-babel-macros
and@vitejs/plugin-react
.When
@vitejs/plugin-react
runs first, the AST seems to be transformed incorrectly. For instance,(yield* call(alert, 'it works')) as void
becomesyield* (call(alert, 'it works') as void)
. The extraTSAsExpression
node inside theYieldExpression
node breaks the simple scheme used bytyped-redux-saga/macro
.While the actual issue seems to be with
@vitejs/plugin-react
, a simple work-around is to placevite-plugin-babel-macros
before@vitejs/plugin-react
in the configuration.The text was updated successfully, but these errors were encountered: