Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Suggestion
Overview
There are several issues related to inferred plugin options, unexpected overrides, and missing configuration context in the current setup. This issue summarizes and clarifies those points while referencingthis video made by@JamesHenry.
1. Plugin Option Overriding
- Some inferred plugins provide default options that unintentionally override explicitly set options from other plugins.
For example,@nx/vite/plugin
has a defaulttypecheckTargetName
of"typecheck"
, which overrides thetargetName
we explicitly set for@nx/js/typescript
.
Initially, this was mitigated by explicitly overriding the value:
{"plugin":"@nx/vite/plugin","include": ["packages/*"],"options": {"typecheckTargetName":"vite:typecheck" }}
However, the current config no longer specifies that override:
{"plugin":"@nx/js/typescript","options": {"typecheck": {"targetName":"typecheck" } }},{"plugin":"@nx/vite/plugin","options": {// Implicit: "typecheckTargetName": "typecheck" }}
This results in the@nx/vite/plugin
inferring atypecheck
target by detectingvitest.config.mts
, whichoverrides the one from@nx/js/typescript
.
You can clearly see this misalignment in the output fromnx graph
:
Current (Incorrect):
Expected (Correct):
This is a serious issue since runningtsc -p tsconfig.json --noEmit
ends uptype-checking nothing, because ourtsconfig.json
uses emptyfiles
andinclude
arrays, relying instead on project references. You can confirm this by introducing a type error and rerunningtypecheck
.
2.@nx/eslint:lint
– Config Path Was Correct
- In the video (14:13), it's mentioned that the value of
options.eslintConfig
(set to{workspaceRoot}/eslint.config.mjs
) is incorrect. However, this was in factcorrect. We only have a singleeslint.config.mjs
file, and it's at the root of the workspace.
3. Type Tests and Whyutils:test
Depends onbuild
andtypecheck
- At 19:45, the video questions why
utils:test
depends on^build
. This dependency, along withtypecheck
, was actuallyintentional and necessary for runningtype-tests usingvitest
. These tests require the workspace's dependencies to be built beforehand, hence the original configuration:
"test": {"dependsOn": ["^build","typecheck"]}
Currently, only a few packages (e.g.,ast-spec
,utils
) include type tests. In those workspaces:
typecheck.enabled
was previously set totrue
invitest.config.mts
.- The
typecheck.tsconfig
was previously set to the localtsconfig.spec.json
.
Whilevitest
's type-checker is essentially a wrapper aroundtsc
, there are some differences, which is why the scope of files to check was narrowed in the rootvitest.config.base.mts
file.
4. Missing--config=vitest.config.mts
Flag
- In the PR that simplified the configuration, the
--config=vitest.config.mts
flag was not carried over into the updatednx.json
. While not strictly required, re-adding it would avoidvitest
's config file lookup and offer a slight performance improvement.
Additional Info
I will submit a PR for this shortly.