Skip to content

Commit 43d2dc9

Browse files
committed
feat: swcCacheDir option
1 parent 6db7e7c commit 43d2dc9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/plugin-react-swc/src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ type Options = {
4747
* @default undefined
4848
*/
4949
plugins?: [string, Record<string, any>][]
50+
/**
51+
* Specify the location where SWC stores its intermediate cache files.
52+
* @default '.swc'
53+
*/
54+
swcCacheDir?: string
5055
/**
5156
* Set the target for SWC in dev. This can avoid to down-transpile private class method for example.
5257
* For production target, see https://vite.dev/config/build-options.html#build-target
@@ -88,6 +93,7 @@ const react = (_options?: Options): PluginOption[] => {
8893
const options = {
8994
jsxImportSource: _options?.jsxImportSource ?? 'react',
9095
tsDecorators: _options?.tsDecorators,
96+
swcCacheDir: _options?.swcCacheDir,
9197
plugins: _options?.plugins
9298
? _options?.plugins.map((el): typeof el => [resolve(el[0]), el[1]])
9399
: undefined,
@@ -264,7 +270,7 @@ const transformWithOptions = async (
264270
jsc: {
265271
target,
266272
parser,
267-
experimental: { plugins: options.plugins },
273+
experimental: { plugins: options.plugins, cacheRoot: options.swcCacheDir },
268274
transform: {
269275
useDefineForClassFields: true,
270276
react: reactConfig,

0 commit comments

Comments
 (0)