@smoothbricks/nx-plugin
v0.2.2
Published
Local Nx plugin for workspace-standard package setup and missing inferred targets.
Downloads
662
Readme
Nx Plugin
Local Nx plugin for workspace-standard package setup and missing inferred targets.
Target Ownership
Official @nx/js/typescript owns TypeScript library inference. A package tsconfig.lib.json becomes the tool-output
target tsc-js; this plugin must not duplicate or rename that target.
@smoothbricks/nx-plugin owns only inferred targets Nx does not provide here:
typecheck-testsandtypecheck-tests:watchfromtsconfig.test.jsontest:watchfrom explicittestcommands for Bun and Vitest packageszig-*targets frombuild.zigsteps such aszig-wasm- aggregate
buildandlinttargets
Nx Target Naming
Target names are {tool}-{output} names. Use names like tsc-js, tsdown-js, and zig-wasm; build and lint are
aggregates.
Concrete targets come from concrete files:
typecheck-testsis inferred fromtsconfig.test.jsonand runstsc --noEmit -p tsconfig.test.json.typecheck-tests:watchis inferred fromtsconfig.test.jsonand runs the same typecheck in watch mode.test:watchis inferred when the package already defines an explicit Bun or Vitesttestcommand. The plugin derives the corresponding watch command and makes it depend ontypecheck-tests.zig-*is inferred frombuild.zig; each explicitb.step("name", ...)becomeszig-name.buildis inferred only when the project has at least one concrete build target to run, such astsc-jsfrom the official TypeScript plugin, a package-local target liketsdown-js, or azig-*target from this plugin. It depends on output-family wildcard targets:*-js,*-web,*-html,*-css,*-ios,*-android,*-native,*-napi,*-bun, and*-wasm.
This is why Zig appears in the convention: the plugin is not guessing from arbitrary Zig source. SmoothBricks requires
build.zig to expose named build steps so Nx can create cacheable, addressable targets from those steps.
Do not use colon-style Nx target names such as build:wasm or lint:fix. Nx CLI syntax already uses colons for
project:target:configuration, so colon target names are hard to read, easy to confuse with configurations, and awkward
to expose through package scripts. Package scripts may still use names like build:wasm; they should delegate to a real
target such as nx run pkg:zig-wasm.
There is no Nx lint:fix target; repository formatting is handled by the root lint:fix script.
typecheck-tests and typecheck-tests:watch are inferred only when tsconfig.test.json exists. Test typechecking must
not emit dist-test. test:watch is continuous and depends on typecheck-tests before entering Bun or Vitest watch
mode. Smoo validation creates/requires this config for test runners that do not typecheck test files by default.
tsconfig.test.json is not a TypeScript build-mode project. It should reference library tsconfigs it needs to typecheck
against, but the package root tsconfig.json should not reference ./tsconfig.test.json. Nx runs test typechecking
through the inferred typecheck-tests target, not through tsc --build.
Zig targets are inferred only when build.zig declares at least one b.step(...). Each step becomes a zig-* target,
so a package build.zig must have at least one step.
Bun Test Tracing Generator
Configure a package for the Bun test tracing + no-emit test typechecking pattern used in this repo.
nx generate ./packages/nx-plugin:bun-test-tracing \
--project @smoothbricks/my-package \
--opContextModule @smoothbricks/lmao \
--opContextExport lmaoOpContext \
--tracerModule @smoothbricks/lmao/testing/bunWhat it wires:
bunfig.tomlpreloads for the LMAO Bun test tracing setupsrc/test-suite-tracer.tstsconfig.test.jsonwithnoEmitfor inferredtypecheck-tests- direct test config references to library tsconfigs; package root
tsconfig.jsonis left out of the test config graph - package
package.jsontest/lint/devDependency wiring needed for the standard pattern
Bounded Test Targets
@smoothbricks/nx-plugin:bounded-exec runs a shell command with a timeout and force-kill grace period. Test targets use
this executor so hung test processes fail predictably instead of blocking Nx indefinitely.
The shared policy API is exported from @smoothbricks/nx-plugin/bounded-test-policy for generators or other workspace
tools that need to normalize package JSON consistently.
nx generate ./packages/nx-plugin:bounded-test-targets --project @smoothbricks/my-packageThe generator rewrites package.json so nx.targets.test uses:
- executor
@smoothbricks/nx-plugin:bounded-exec - command preserved from an existing
nx:run-commandstest target or directscripts.test cwd: "{projectRoot}"timeoutMs: 600000killAfterMs: 10000- package script alias
nx run <project>:test --outputStyle=stream
