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;

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'
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.