For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt, and this page is available as Markdown at /next/zh/api/packages/react-rsbuild-plugin/interfaces/ShakeVisitorConfig.md.
Lynx
  • 简体中文
  • 接口: ShakeVisitorConfig

    主线程代码的 shake 方式。

    属性

    pkgName

    pkgName: string[]

    用于识别需要处理的运行时导入的包名

    示例

    import { defineConfig } from '@lynx-js/rspeedy'
    import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
    
    export default defineConfig({
      plugins: [
        pluginReactLynx({
          shake: {
            pkgName: ['@lynx-js/react-runtime']
          }
        })
      ]
    })

    默认值

    ['@lynx-js/react-runtime']

    备注

    传入的值会与默认值合并,而不是替换默认值。


    removeCall

    removeCall: string[]

    在转换过程中,其调用会被替换为 undefined 的函数名

    示例

    import { defineConfig } from '@lynx-js/rspeedy'
    import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
    
    export default defineConfig({
      plugins: [
        pluginReactLynx({
          shake: {
            removeCall: ['useMyCustomEffect']
          }
        })
      ]
    })

    默认值

    ['useEffect', 'useLayoutEffect', '__runInJS', 'useLynxGlobalEventListener', 'useImperativeHandle']

    备注

    传入的值会与默认值合并,而不是替换默认值。


    removeCallParams

    removeCallParams: string[]

    在转换过程中,需要移除其参数的函数名

    示例

    import { defineConfig } from '@lynx-js/rspeedy'
    import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
    
    export default defineConfig({
      plugins: [
        pluginReactLynx({
          shake: {
            removeCallParams: ['useMyCustomEffect']
          }
        })
      ]
    })

    默认值

    []

    备注

    传入的值会与默认值合并,而不是替换默认值。


    retainProp

    retainProp: string[]

    需要在组件类中保留的属性

    示例

    import { defineConfig } from '@lynx-js/rspeedy'
    import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
    
    export default defineConfig({
      plugins: [
        pluginReactLynx({
          shake: {
            retainProp: ['myCustomMethod']
          }
        })
      ]
    })

    默认值

    ['constructor', 'render', 'getDerivedStateFromProps', 'state', 'defaultDataProcessor', 'dataProcessors', 'contextType', 'defaultProps']

    备注

    传入的值会与默认值合并,而不是替换默认值。

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。