Skip to content

Commit

Permalink
feat: vitest deps.experimentalOptimizer (fixes #111) (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre authored Jun 3, 2023
1 parent 8e311c0 commit 10db2d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Support [Vitest deps.experimentalOptimizer](https://vitest.dev/config/#deps-experimentaloptimizer)

## 3.3.1

- Add `type: module` to package.json ([#101](https://github.com/vitejs/vite-plugin-react-swc/pull/101)). Because the library already publish `.cjs` & `.mjs` files, the only change is for typing when using the node16 module resolution (fixes [#95](https://github.com/vitejs/vite-plugin-react-swc/issues/95))
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ const react = (_options?: Options): PluginOption[] => {
],
async transform(code, _id, transformOptions) {
const id = _id.split("?")[0];
const refresh = !transformOptions?.ssr && !process.env.TEST;

const result = await transformWithOptions(id, code, "es2020", options, {
refresh: !transformOptions?.ssr,
refresh,
development: true,
runtime: "automatic",
importSource: options.jsxImportSource,
});
if (!result) return;

if (transformOptions?.ssr || !refreshContentRE.test(result.code)) {
if (!refresh || !refreshContentRE.test(result.code)) {
return result;
}

Expand Down

0 comments on commit 10db2d5

Please sign in to comment.