Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jan 14, 2025
1 parent 4415ff6 commit 35bdaa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ react({
});
```

### useAtYourOwnRiskEditConfig
### useAtYourOwnRisk_mutateSwcOptions

The future of Vite is with OXC, and from the beginning this was a design choice to not exposed too many specialties from SWC so that Vite React users can move to another transformer later.
Also debugging why some specific version of decorators with some other unstable/legacy feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk`.

```ts
react({
useAtYourOwnRiskEditConfig(options) {
useAtYourOwnRisk_mutateSwcOptions(options) {
options.jsc.parser.decorators = true;
options.jsc.transform.decoratorVersion = "2022-03";
},
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Options = {
* Also debugging why some specific version of decorators with some other unstable/legacy
* feature doesn't work is not fun, so we won't provide support for it, hence the name `useAtYourOwnRisk`
*/
useAtYourOwnRiskEditConfig?: (options: SWCOptions) => void;
useAtYourOwnRisk_mutateSwcOptions?: (options: SWCOptions) => void;
};

const isWebContainer = globalThis.process?.versions?.webcontainer;
Expand All @@ -81,7 +81,8 @@ const react = (_options?: Options): PluginOption[] => {
: undefined,
devTarget: _options?.devTarget ?? "es2020",
parserConfig: _options?.parserConfig,
useAtYourOwnRiskEditConfig: _options?.useAtYourOwnRiskEditConfig,
useAtYourOwnRisk_mutateSwcOptions:
_options?.useAtYourOwnRisk_mutateSwcOptions,
};

return [
Expand Down Expand Up @@ -263,8 +264,8 @@ const transformWithOptions = async (
},
},
};
if (options.useAtYourOwnRiskEditConfig) {
options.useAtYourOwnRiskEditConfig(swcOptions);
if (options.useAtYourOwnRisk_mutateSwcOptions) {
options.useAtYourOwnRisk_mutateSwcOptions(swcOptions);
}
result = await transform(code, swcOptions);
} catch (e: any) {
Expand Down

0 comments on commit 35bdaa4

Please sign in to comment.