All Projects → lin-xi → Babel Plugin Import Fix

lin-xi / Babel Plugin Import Fix

alter import module to certain module file path for smaller bundle and better performance

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Babel Plugin Import Fix

Ts Nameof
nameof in TypeScript
Stars: ✭ 349 (+926.47%)
Mutual labels:  babel-plugin
Glam
crazy good css in your js
Stars: ✭ 485 (+1326.47%)
Mutual labels:  babel-plugin
Babel Plugin Transform React Remove Prop Types
Remove unnecessary React propTypes from the production build. 🎈
Stars: ✭ 890 (+2517.65%)
Mutual labels:  babel-plugin
I18nize React
Internationalize react apps within a lunch break
Stars: ✭ 389 (+1044.12%)
Mutual labels:  babel-plugin
Babel Plugin Sitrep
Log all assignments and the return value of a function with a simple comment
Stars: ✭ 442 (+1200%)
Mutual labels:  babel-plugin
React Svg Loader
A loader for webpack, rollup, babel that loads svg as a React Component
Stars: ✭ 570 (+1576.47%)
Mutual labels:  babel-plugin
Babel Plugin Tailwind Components
Use Tailwind with any CSS-in-JS library
Stars: ✭ 320 (+841.18%)
Mutual labels:  babel-plugin
Babel Plugin Jsx Two Way Binding
🍺 A two-way data binding solution for React
Stars: ✭ 15 (-55.88%)
Mutual labels:  babel-plugin
Webpack Closure Compiler
[DEPRECATED] Google Closure Compiler plugin for Webpack
Stars: ✭ 467 (+1273.53%)
Mutual labels:  tree-shaking
Htm
Hyperscript Tagged Markup: JSX alternative using standard tagged templates, with compiler support.
Stars: ✭ 7,299 (+21367.65%)
Mutual labels:  babel-plugin
Tinyify
a browserify plugin that runs various optimizations, so you don't have to install them all manually. makes your bundles tiny!
Stars: ✭ 392 (+1052.94%)
Mutual labels:  tree-shaking
Babel Plugin React Intl
Extracts string messages from React components that use React Intl.
Stars: ✭ 430 (+1164.71%)
Mutual labels:  babel-plugin
Babel Plugin Add Module Exports
【v0.2 no longer maintained】 Fix babel/babel#2212 - Follow the [email protected] behavior for [email protected]
Stars: ✭ 729 (+2044.12%)
Mutual labels:  babel-plugin
Reflective Bind
Eliminate wasteful re-rendering in React components caused by inline functions
Stars: ✭ 366 (+976.47%)
Mutual labels:  babel-plugin
Webpack Common Shake
CommonJS Tree Shaker plugin for WebPack
Stars: ✭ 875 (+2473.53%)
Mutual labels:  tree-shaking
Babel Plugin React Remove Properties
Babel plugin for removing React properties. 💨
Stars: ✭ 327 (+861.76%)
Mutual labels:  babel-plugin
Kneden
Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
Stars: ✭ 517 (+1420.59%)
Mutual labels:  babel-plugin
That React App You Want
That react app you always wanted: [email protected], [email protected], postCSS, purifycss, dll's and code splitting examples, bregh. Highly opinionated but you better like it.
Stars: ✭ 27 (-20.59%)
Mutual labels:  tree-shaking
Babel Plugin Styled Components
Improve the debugging experience and add server-side rendering support to styled-components
Stars: ✭ 878 (+2482.35%)
Mutual labels:  babel-plugin
Flow Runtime
A runtime type system for JavaScript with full Flow compatibility.
Stars: ✭ 813 (+2291.18%)
Mutual labels:  babel-plugin

babel-plugin-import-fix

Build Status Coverage Status npm package NPM downloads

alter import module to certain module file path for smaller bundle file and better performance

主要功能是修改import,缩小import的范围,减少bundle文件大小,提升性能


import {Button} from 'antd';

after fix:

import {Button} from 'antd/lib/button';
import 'antd/lib/button/style'

these fixies are made on ast. bundle file size decrease from 1.5Mb to 286Kb.


how to use

npm install babel-plugin-import-fix -D

config it in your .babelrc

在.babelrc里进行配置

.babelrc

{
  "presets": [
    ["es2015", { "modules": false }], "react"
  ],
  "plugins": ["import-fix"]
}

supported framework

framework status
xcui
antd
elementUI
material-ui
d3

more library will be supported increasingly

默认直接支持这些库,不需要配置,会不断增加支持的类型

extend usage:

you can overwrite the config or add new config like this:

扩展支持的库,如果没有css,可以不写cssPath,或设置为空

.babelrc

{
  "presets": [
    ["es2015", { "modules": false }], "react"
  ],
  "plugins": [["import-fix", [
    {
      'libraryName': 'xcui',
      'libraryPath': 'xcui/lib/${name}.js',
      'namePolicy': 'dash',
      'cssPath': ['xcui/lib/css/common.css', 'xcui/lib/css/${name}.css']
    },
    {
      'libraryName': 'antd',
      'libraryPath': 'antd/lib/${name}/index.js',
      'namePolicy': 'dash',
      'cssPath': 'antd/lib/${name}/style/index.css'
    }
  ]]]
}

cssPath can be a string or an array or an empty string, if you hava multiple css files to import, use an array. you may igonre cssPath if you don't need.

cssPath可以是字符或数组


name policy

three policy are supported

namePolicy选项

  • dash, date-picker
  • camel, DatePicker
  • underline, date_picker

default config:

默认配置

[
  {
    'libraryName': 'antd',
    'libraryPath': 'antd/lib/${name}/index.js',
    'namePolicy': 'dash',
    'cssPath': 'antd/lib/${name}/style/index.css'
  },
  {
    'libraryName': 'material-ui',
    'libraryPath': 'material-ui/${name}/index.js',
    'namePolicy': 'camel',
    'cssPath': ''
  },
  {
    'libraryName': 'xcui',
    'libraryPath': 'xcui/lib/${name}.js',
    'namePolicy': 'dash',
    'cssPath': ['xcui/lib/css/common.css', 'xcui/lib/css/${name}.css']
  },
  {
    'libraryName': 'element-ui',
    'libraryPath': 'element-ui/lib/${name}.js',
    'namePolicy': 'dash',
    'cssPath': ['element-ui/lib/theme-default/base.css', 'element-ui/lib/theme-default/${name}.css']
  },
  {
    'libraryName': 'd3',
    'libraryPath': 'd3-${name}/index.js',
    'namePolicy': 'dash',
    'cssPath': ''
  }
]

thanks:

https://github.com/ant-design/babel-plugin-import

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].