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
If you follow the current @nx/rspack documentation, it's stated that users should execute nx add @nx/rspack to Add Rspack to an existing workspace. However, if you execute nx add @nx/rspackwithoutNX_ADD_PLUGINS=false, then a "crystal" plugin setup will be generated in the user's nx.json file like so:
If a "crystal" plugin setup for @nx/rspack is located in a user's nx.json file then the current implementations of withNx, withReact, and withWeb are guaranteed to fail since they assume context.projectGraph is defined - which it won't be for the initial run of composePlugins's combined function since composePlugin is invoked (indirectly) by readRspackOptionsnotrunExecutor. In other words, withNx, withReact, and withWeb do not have a check for process.env['NX_TASK_TARGET_PROJECT'] to ensure that context.projectGraph is defined by runExecutor.
Expected Behavior
Either:
The @nx/rspack documentation should be updated as to not mention nx add @nx/rspack (not great)
The @nx/rspack generators should be updated to prevent updating the nx.json file (okayish)
The implementations for withNx, withReact, and withWeb should add a basic check for process.env['NX_TASK_TARGET_PROJECT'] and skip their steps until it is safe to do so (better)
The implementations for withNx, withReact, and withWeb should be updated to complete the crystal plugin integration (best)
Proposed Solution
Honestly, the quickest fix for the time being (until the crystal plugin integration is done) would be to something like this to withNx, withReact, and withWeb:
Current Behavior
If you follow the current @nx/rspack documentation, it's stated that users should execute
nx add @nx/rspack
to Add Rspack to an existing workspace. However, if you executenx add @nx/rspack
withoutNX_ADD_PLUGINS=false
, then a "crystal" plugin setup will be generated in the user'snx.json
file like so:If a "crystal" plugin setup for
@nx/rspack
is located in a user'snx.json
file then the current implementations ofwithNx
,withReact
, andwithWeb
are guaranteed to fail since they assumecontext.projectGraph
is defined - which it won't be for the initial run ofcomposePlugins
'scombined
function sincecomposePlugin
is invoked (indirectly) byreadRspackOptions
notrunExecutor
. In other words,withNx
,withReact
, andwithWeb
do not have a check forprocess.env['NX_TASK_TARGET_PROJECT']
to ensure thatcontext.projectGraph
is defined byrunExecutor
.Expected Behavior
Either:
nx add @nx/rspack
(not great)@nx/rspack
generators should be updated to prevent updating thenx.json
file (okayish)withNx
,withReact
, andwithWeb
should add a basic check forprocess.env['NX_TASK_TARGET_PROJECT']
and skip their steps until it is safe to do so (better)withNx
,withReact
, andwithWeb
should be updated to complete the crystal plugin integration (best)Proposed Solution
Honestly, the quickest fix for the time being (until the crystal plugin integration is done) would be to something like this to
withNx
,withReact
, andwithWeb
:The text was updated successfully, but these errors were encountered: