Skip to content

feat(react): add react + vite + vitest + playwright example - #35921

Merged
FrozenPandaz merged 27 commits into
masterfrom
feature/nxc-4540-add-react-vite-vitest-playwright-example
Jul 17, 2026
Merged

feat(react): add react + vite + vitest + playwright example#35921
FrozenPandaz merged 27 commits into
masterfrom
feature/nxc-4540-add-react-vite-vitest-playwright-example

Conversation

@FrozenPandaz

Copy link
Copy Markdown
Contributor

Current Behavior

There's no React example in the repo that dogfoods the local @nx/vite / @nx/react / @nx/playwright / @nx/eslint packages end-to-end.

Separately, the global test targetDefault applied jest-only options to every test target — including @nx/vitest ones: --detectOpenHandles, --forceExit, and NODE_OPTIONS=--experimental-vm-modules. vitest rejects those jest flags (CACError: Unknown option '--detectOpenHandles'), so every vitest project had to carry a per-project test override to strip them.

Expected Behavior

This PR has two commits:

chore(repo): scope test target defaults by plugin (jest vs vitest)

  • Scope the jest flags to @nx/jest/plugin targets, and add a @nx/vitest-scoped default that supplies just --passWithNoTests.
  • Vitest test targets now resolve correct args with no per-project override, so the redundant overrides are removed from @nx/angular-rspack and @nx/angular-rspack-compiler (their tests still pass — 25 and 80 specs respectively; the only real dependency, ^build-native, comes from the targetDefault).
  • Consolidate the @nx/vite/plugin and @nx/vitest plugin declarations (drop the dead angular-rspack* vite include).

feat(react): add react + vite + vitest + playwright example

  • Add examples/react/basic — a React app built with Vite, unit-tested with Vitest, e2e-tested with Playwright, and linted with ESLint — all linked to the local workspace packages via workspace:*, so it dogfoods the in-repo builds.
  • Targets verified: build, test (2 specs), pw-e2e (chromium, 1 spec), lint, typecheck. Workspace nx sync:check clean.

Related Issue(s)

Tracked in NXC-4540 (linked via branch name).

@FrozenPandaz
FrozenPandaz requested a review from a team as a code owner June 9, 2026 21:09
@FrozenPandaz
FrozenPandaz requested a review from JamesHenry June 9, 2026 21:09
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 15112a9
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a5a9452a45cc60008b44ae9
😎 Deploy Preview https://deploy-preview-35921--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 15112a9
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a5a9452ea0eda0008bd386a
😎 Deploy Preview https://deploy-preview-35921--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 565f66a

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 10m 25s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 2s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 18s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 7s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-17 21:00:05 UTC

@FrozenPandaz
FrozenPandaz marked this pull request as draft June 9, 2026 21:39
@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch 3 times, most recently from 062e90d to 2610f8f Compare June 11, 2026 20:47
@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch from 2610f8f to 0792735 Compare July 3, 2026 19:36
@socket-security

socket-security Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm @emnapi/runtime is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: examples/angular-rspack/ssr-css/pnpm-lock.yamlnpm/@rspack/core@2.1.2npm/@emnapi/runtime@1.11.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@emnapi/runtime@1.11.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm js-yaml is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: examples/react/basic/pnpm-lock.yamlnpm/eslint@9.39.4npm/js-yaml@4.2.0

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/js-yaml@4.2.0. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch from 15c0ce5 to 84a2fab Compare July 6, 2026 14:56
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch 2 times, most recently from 0bfeb2b to fb023eb Compare July 10, 2026 17:55
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch from 4807bef to 1f2a189 Compare July 13, 2026 14:22
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch 2 times, most recently from e7386a2 to 561f1ad Compare July 13, 2026 19:59
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch from 272310b to f749c39 Compare July 17, 2026 14:18
nx-cloud[bot]

This comment was marked as outdated.

…lone workspaces

Applies the csr-css template to the other 11 single-app examples: own
nx.json registering the local @nx/rspack/plugin, pnpm-workspace.yaml and
committed lockfile, link: dependencies on @nx/angular-rspack and @nx/rspack,
per-example Angular dependencies (platform-server/ssr for the ssr and ssg
variants, localize for i18n, express for ssr servers, no zone.js for the
zoneless ones), duplicated shared/ fixtures where referenced, and rebased
config paths (including the i18n translation files, which were repo-root
relative).
…dalone workspace

Host and remote stay in one workspace (the host loads the remote at
runtime, so they must share a graph): one pnpm-workspace.yaml with the two
members, one nx.json registering the local @nx/rspack/plugin, link:
dependencies on @nx/angular-rspack, @nx/module-federation and @nx/rspack,
and per-member Angular dependencies.
The examples are their own pnpm workspaces now: exclude them from the root
workspace, remove the root @nx/rspack/plugin registration and the examples'
root tsconfig references, and delete the shared/ fixtures and
tsconfig.base.json originals that were duplicated into the examples. The
examples-plugin picks each one up (13 handles with a validate target and
link-derived implicit dependencies).
The examples are standalone pnpm workspaces with their own generated
pnpm-lock.yaml files; unanchor the existing root-only ignore so prettier
skips all of them.
The dep object's type property widened to the DependencyType enum, which
does not satisfy the RawProjectGraphDependency union under tsgo.
The js plugin only enables analyzeSourceFiles when the workspace root
package.json depends on an allowlisted plugin (@nx/workspace, @nx/js,
@nx/node, @nx/next, @nx/react, @nx/angular, @nx/web). The examples depend
on @nx/angular-rspack and @nx/rspack, which are not on the list, so their
projects had no dependency edges. Set pluginsConfig['@nx/js'] explicitly.
The NX_GRAPH_CREATION guard returned an empty config while the graph was
being created, so the @nx/rspack plugin had nothing to derive target
configuration from. The guard was only needed when the examples lived in
the repo's own graph; in the standalone workspaces createConfig computes
cleanly, and the plugin now derives precise configuration from it — e.g.
the dist/browser and dist/server outputs of the ssr and app-shell examples.

The manual build target blocks in the examples' package.json files are
redundant with the derived configuration (shared/ now lives inside each
workspace root, so the default production input covers it) and are removed.
…kspace

examples/*/* only matched directories that the exclusions removed again;
everything under examples/ is a standalone pnpm workspace now.
The examples are standalone workspaces with no Nx Cloud workspace of their
own, but child nx processes inherited the repo's CI access token and
aborted with a 401. The validate-example wrapper now sets NX_NO_CLOUD for
the nested runs, and each example nx.json sets neverConnectToCloud.
…te wrapper

The validate-example wrapper wrote the examples' inner dist without
declaring it; it now declares {projectRoot}/dist (and {projectRoot}/*/dist
for the module-federation members) as outputs.

It also ran the examples' postinstall, which builds the linked packages
through a root-workspace nx invocation whose graph and hash computation
reads root config inside the sandbox. dependsOn ^build already guarantees
those builds here, so the wrapper installs with --ignore-scripts; the
postinstall remains for the manual fresh-clone flow.
Every example now declares nx as a link: devDependency and builds it in its
postinstall, so commands inside the examples run the local nx build instead
of resolving up to the repo root. The react example's playwright webServer
now uses an nx command so the @nx/playwright plugin derives the e2e
dependsOn on serve (and restores parallelism).
Playwright's transform follows the linked packages' tsconfig references
(tsconfig.spec.json is excluded from ^production), and esbuild reads the
repo-root tsconfig.json while walking ancestor directories, so use ^default
and declare the root tsconfig as inputs of validate-example.
@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch from 2e3c3a1 to 9a46ca9 Compare July 17, 2026 16:15
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feature/nxc-4540-add-react-vite-vitest-playwright-example branch 2 times, most recently from 54107e0 to 13682ef Compare July 17, 2026 19:45
FrozenPandaz and others added 2 commits July 17, 2026 15:53
Give the example its own tsconfig.base.json instead of extending the repo
root's. Without the root base's composite flag, the typescript-sync
generator no longer wires the example into the root TS solution, matching
how the angular-rspack examples work.

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

@FrozenPandaz
FrozenPandaz merged commit 71436fb into master Jul 17, 2026
18 checks passed
@FrozenPandaz
FrozenPandaz deleted the feature/nxc-4540-add-react-vite-vitest-playwright-example branch July 17, 2026 21:04
FrozenPandaz added a commit that referenced this pull request Jul 20, 2026
## Current Behavior

There's no React example in the repo that dogfoods the local `@nx/vite`
/ `@nx/react` / `@nx/playwright` / `@nx/eslint` packages end-to-end.

Separately, the global `test` targetDefault applied jest-only options to
**every** `test` target — including `@nx/vitest` ones:
`--detectOpenHandles`, `--forceExit`, and
`NODE_OPTIONS=--experimental-vm-modules`. vitest rejects those jest
flags (`CACError: Unknown option '--detectOpenHandles'`), so every
vitest project had to carry a per-project `test` override to strip them.

## Expected Behavior

This PR has two commits:

**`chore(repo)`: scope test target defaults by plugin (jest vs vitest)**
- Scope the jest flags to `@nx/jest/plugin` targets, and add a
`@nx/vitest`-scoped default that supplies just `--passWithNoTests`.
- Vitest `test` targets now resolve correct args with no per-project
override, so the redundant overrides are removed from
`@nx/angular-rspack` and `@nx/angular-rspack-compiler` (their tests
still pass — 25 and 80 specs respectively; the only real dependency,
`^build-native`, comes from the targetDefault).
- Consolidate the `@nx/vite/plugin` and `@nx/vitest` plugin declarations
(drop the dead `angular-rspack*` vite include).

**`feat(react)`: add react + vite + vitest + playwright example**
- Add `examples/react/basic` — a React app built with **Vite**,
unit-tested with **Vitest**, e2e-tested with **Playwright**, and linted
with **ESLint** — all linked to the local workspace packages via
`workspace:*`, so it dogfoods the in-repo builds.
- Targets verified: `build`, `test` (2 specs), `pw-e2e` (chromium, 1
spec), `lint`, `typecheck`. Workspace `nx sync:check` clean.

## Related Issue(s)

Tracked in NXC-4540 (linked via branch name).

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
Co-authored-by: FrozenPandaz <FrozenPandaz@users.noreply.github.com>
(cherry picked from commit 71436fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants