Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-demand

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-demand

按需加载babel插件

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-demand

用于公共 js 库按需加载的babel插件

NPM version Build Status

Install

npm i babel-plugin-demand -D

Usage

.babelrc 或者 babel-loader 文件中配置

{
  "plugins": [
    [
      "demand", {
        packageName: 'xx-sdk',
        redirect: 'lib'
        // ...options
      }
    ]
  ]
}

Example

import { foo } from 'xx-sdk'
foo()

上述代码会被转为

import _foo from 'xx-sdk/lib/foo'
_foo()

options

参数名称类型含义是否必填默认值
packageNameStringjs 包的名字
redirectString函数所在的目录'lib'
moreRedirectArrayredirect目录不存在时,自动检索该数组中的路径[]
camel2DashBoolean驼峰文件名是否需要转为'-'连接false

more

  • 编译过程中 ast 的 types 可以参考doc文件下的 ast-types

Keywords

FAQs

Package last updated on 23 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc