Skip to content

Just a hacking tool. Useful when you have to patch some library dependencies.

Notifications You must be signed in to change notification settings

AngusFu/babel-plugin-library-aliases

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-library-aliases

Just a hacking tool. Useful when you have to patch some library dependencies.

Usage

SEE Playground

// in your babel.config.js:

module.exports{
  // ... other fields
  plugins: [
    // ... other plugins
    [
      'babel-plugin-library-aliases',
      {
        'antd': {
          aliases: {
            // NOTE: Relative path is not supported
            Modal: 'src/components/CustomModal',
            message: 'src/components/customMessage',
            Alert: 'src/components/index#CumstomAlert',
          },
          ignore(imported, local) {
            // if you are using `import { AntdModal } from 'antd'`,
            // it will still use the original exported member from the `antd` library
            return /^[aA]ntd/.test(local.name);
          }
        },

        'some-library': {
          aliases: {
            hello: 'src/components/hack_hello',
            world: 'src/components/hack_world#default',
            default: 'src/components/hack_component#NamedExportComponent'
          },
          ignore(imported, local) {
            // imported may be null (case: import default)
            return local.name.startsWith('Original');
          }
        }
      }
    ]
  ];
}

About

Just a hacking tool. Useful when you have to patch some library dependencies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published