npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ui-component-loader

v1.4.4

Published

[![Npm Package](https://img.shields.io/npm/v/ui-component-loader.svg?style=flat-square)](https://www.npmjs.com/package/ui-component-loader) [![Build Status](https://img.shields.io/travis/gwuhaolin/ui-component-loader.svg?style=flat-square)](https://travis

Downloads

68

Readme

Npm Package Build Status Npm Downloads

ui-component-loader

Modular UI component loader for webpack, a good alternative for babel-plugin-import.

Compatible with antd, antd-mobile, and so on.

Example

| description | options | source | output | | --- | --- | --- | --- | | replace one | lib: 'antd' | import {Button} from 'antd' | import Button from 'antd/lib/Button' | | replace many | lib: 'antd' | import {Button,Icon} from 'antd' | import Button from 'antd/lib/Button' import Icon from 'antd/lib/Icon' | | set libDir | lib: 'antd', libDir: 'es' | import {Button} from 'antd' | import Button from 'antd/es/Button' | | use style | lib: 'antd', style: 'index.css' | import {Button} from 'antd' | import Button from 'antd/lib/Button' import 'antd/lib/Button/index.css' | | translate camel | lib: 'antd', camel2: '-' | import {MyComponent} from 'antd' | import MyComponent from 'antd/lib/my-component' | | componentDirMap | lib: 'antd', camel2: '-',componentDirMap: {MyComponent: 'YourComponent'} | import {MyComponent} from 'antd' | import MyComponent from 'antd/lib/YourComponent' |

Usage

Install by:

npm install ui-component-loader -D

Edit webpack.config.js:

module.exports = {
  module: {
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          'ts-loader',
          {
            loader: 'ui-component-loader',
            options: {
              'lib': 'antd',
              'camel2': '-',
              'style': 'style/css.js',
            }
          },
        ],
        // the path you import antd
        include: path.resolve('src/client'),
      },
    ]
  },
};

The order of loaders has no require, but the source code pass to ui-component-loader must use ES6 module syntax.

If you have mutil package need to be spilt, can get options as a array like:

{
    loader: 'ui-component-loader',
    options: {
         antd: {
              'camel2': '-',
              'style': 'style/css.js',
         },
         mui: {
         },
    }
}

Options

  • lib: library want to replace,value is name in npm.
  • libDir: library directory path which store will use code, default it lib
  • style: should append style file to a component? value is relative path to style file.
  • camel2: should translate MyComponent to my-component, value is the join string.
  • existCheck: should check if import file exist, only import file when exits, default will check. To close this check set existCheck to (componentDirPath)=> true.
  • componentDirMap: a map to store Component Entry Dir in lib by ComponentName, it's structure should be {ComponentName:ComponentDir},default is {}.

Diff with babel-plugin-import

  1. babel-plugin-import is a babel plugin, which means must be used in project with babel. But in some project, like project use TypeScript, ui-component-loader is useful, ui-component-loader can be used in any project with webpack.
  2. ui-component-loader has better performance as it's implement by regular expression replace string, but babel-plugin-import base on AST.