Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler option for react library generator not adding SWC plugin import when specified #27433

Closed
1 of 4 tasks
pongells opened this issue Aug 14, 2024 · 2 comments
Closed
1 of 4 tasks
Assignees
Labels
scope: react Issues related to React support for Nx type: bug

Comments

@pongells
Copy link
Contributor

Current Behavior

When generating a library with SWC compiler, the option is ignored if the test runner is vitest.

This happens because of https://github.com/nrwl/nx/blob/master/packages/react/src/generators/library/library.ts#L176

Expected Behavior

import react from "@vitejs/plugin-react-swc";

should be added to vite.config.ts instead of

import react from "@vitejs/plugin-react";

GitHub Repo

No response

Steps to Reproduce

1.nx g @nx/react:library --verbose --name swclib --bundler none --linter none --unit-test-runner vitest --compiler swc
2. in vite.config.ts the import is import react from "@vitejs/plugin-react"; instead of import react from "@vitejs/plugin-react-swc";

Nx Report

Node           : 20.11.0
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 4.4.0

nx                 : 19.5.7
@nx/js             : 19.5.7
@nx/jest           : 19.5.7
@nx/linter         : 19.5.7
@nx/eslint         : 19.5.7
@nx/workspace      : 19.5.7
@nx/devkit         : 19.5.7
@nx/eslint-plugin  : 19.5.7
@nx/playwright     : 19.5.7
@nx/plugin         : 19.5.7
@nx/react          : 19.5.7
@nx/rollup         : 19.5.7
@nrwl/tao          : 19.5.7
@nx/vite           : 19.5.7
@nx/web            : 19.5.7
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
-------------------

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@ghost
Copy link

ghost commented Aug 15, 2024

Hi, I've pushed a small fix for it. I am not 100% sure this is how it should get fixed but I feel it this way

@FrozenPandaz FrozenPandaz added the scope: react Issues related to React support for Nx label Aug 15, 2024
xiongemi added a commit that referenced this issue Aug 16, 2024
## Current Behavior
see #27433 

## Expected Behavior
see #27433 

## Related Issue(s)
see #27433 

Fixes #
- if compiler is `swc`, `@vitejs/plugin-react-swc` is being imported;
otherwise `@vitejs/plugin-react` is being imported

Co-authored-by: Emily Xiong <xiongemi@gmail.com>
FrozenPandaz pushed a commit that referenced this issue Aug 19, 2024
## Current Behavior
see #27433

## Expected Behavior
see #27433

## Related Issue(s)
see #27433

Fixes #
- if compiler is `swc`, `@vitejs/plugin-react-swc` is being imported;
otherwise `@vitejs/plugin-react` is being imported

Co-authored-by: Emily Xiong <xiongemi@gmail.com>
(cherry picked from commit 7f2c556)
@ndcunningham
Copy link
Contributor

Closing as this has been fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react Issues related to React support for Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants