-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support react forget by config
- Loading branch information
Showing
5 changed files
with
151 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { IApi } from '../../types'; | ||
|
||
export default (api: IApi) => { | ||
api.describe({ | ||
key: 'forget', | ||
config: { | ||
schema({ zod }) { | ||
return zod.object({ | ||
ReactCompilerConfig: zod.object({}).optional(), | ||
}); | ||
}, | ||
}, | ||
enableBy: api.EnableBy.config, | ||
}); | ||
|
||
api.onCheckConfig(() => { | ||
if (api.config.mfsu) { | ||
throw new Error( | ||
`forget is not compatible with mfsu, please disable mfsu first.`, | ||
); | ||
} | ||
if (api.config.mako) { | ||
throw new Error( | ||
`forget is not compatible with mako, please disable mako first.`, | ||
); | ||
} | ||
}); | ||
|
||
api.onCheck(() => { | ||
let reactMajorVersion = api.appData.react.version.split('.')[0]; | ||
if (reactMajorVersion < 19) { | ||
throw new Error( | ||
`forget is only compatible with React 19 and above, please upgrade your React version.`, | ||
); | ||
} | ||
}); | ||
|
||
api.modifyConfig((memo) => { | ||
let ReactCompilerConfig = api.userConfig.forget.ReactCompilerConfig || {}; | ||
return { | ||
...memo, | ||
extraBabelPlugins: [ | ||
...(memo.extraBabelPlugins || []), | ||
[require.resolve('babel-plugin-react-compiler'), ReactCompilerConfig], | ||
], | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.