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/rspeedy/rspeedy.source.transformimport.md.
Rspeedy logo
Rspeedy
  • 简体中文
  • Home > @lynx-js/rspeedy > Source > transformImport

    Source.transformImport property

    The TransformImport option transforms the import paths to enable modular imports from subpaths of third-party packages, similar to the functionality provided by babel-plugin-import.

    Signature:

    transformImport?: TransformImport[] | undefined;

    Default Value

    undefined

    Example

    When using the TUX component library, you can import components on demand with the following config:

    import { defineConfig } from '@lynx-js/rspeedy'
    
    export default defineConfig({
      source: {
        transformImport: [
          {
            libraryName: 'foo',
            customName: 'foo/src/components/{{ member }}/{{ member }}',
          },
        ],
      },
    })

    This will transform the following source code:

    import { Button } from 'foo'

    to:

    import { Button } from 'foo/src/components/Button/Button'
    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。