
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
vite-plugin-swc-react-refresh
Advanced tools
Use the versatility of SWC for development and the maturity of esbuild for production
Use the versatility of SWC for development and the maturity of esbuild for production.
npm i -D vite-plugin-swc-react-refresh
With the automatic JSX runtime (requires esbuild => 0.14.51):
import { defineConfig } from "vite";
import { swcReactRefresh } from "vite-plugin-swc-react-refresh";
export default defineConfig({
plugins: [swcReactRefresh()],
esbuild: { jsx: "automatic" },
});
Without the automatic JSX runtime, but still omitting the React default import:
import { defineConfig } from "vite";
import { swcReactRefresh } from "vite-plugin-swc-react-refresh";
export default defineConfig({
plugins: [swcReactRefresh()],
esbuild: { jsxInject: `import React from "react"` },
});
For React refresh to work, your file should only export React components. The best explanation I've read is the one from the Gatsby docs.
However, having some components being hot updated and not others is a very frustrating experience as a developer, and I think this rule should be enforced by a linter, so I made an eslint rule to go along with this plugin.
This plugin expects this rule to be respected and will always fast refresh components. If a file export something that is not a React component (TS types are ok), update to this export would not propagate and require a manual reload.
FAQs
Use the versatility of SWC for development and the maturity of esbuild for production
The npm package vite-plugin-swc-react-refresh receives a total of 125 weekly downloads. As such, vite-plugin-swc-react-refresh popularity was classified as not popular.
We found that vite-plugin-swc-react-refresh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.