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 referencing this 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 default typecheckTargetName
of "typecheck"
, which overrides the targetName
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 a typecheck
target by detecting vitest.config.mts
, which overrides the one from @nx/js/typescript
.
You can clearly see this misalignment in the output from nx graph
:
Current (Incorrect):
Expected (Correct):
This is a serious issue since running tsc -p tsconfig.json --noEmit
ends up type-checking nothing, because our tsconfig.json
uses empty files
and include
arrays, relying instead on project references. You can confirm this by introducing a type error and rerunning typecheck
.
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 fact correct. We only have a singleeslint.config.mjs
file, and it's at the root of the workspace.
3. Type Tests and Why utils:test
Depends on build
and typecheck
- At 19:45, the video questions why
utils:test
depends on^build
. This dependency, along withtypecheck
, was actually intentional and necessary for running type-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
.
While vitest
's type-checker is essentially a wrapper around tsc
, there are some differences, which is why the scope of files to check was narrowed in the root vitest.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.