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

legions-rpc-cli

v0.0.9-beta.1

Published

> rollup 打包编译工具命令集

Downloads

11

Readme

legions-rpc-cli

TODO: rollup 打包命令集

Usage

npm i legions-rpc-cli --save

command

legions-rpc rpc -c or lrpc rpc -c

config

external 排除第三方或外部文件

等同于 rollup.external,参考 rollup 配置即可

rollupPlugin

全局常用插件配置信息,包含如下

{
  babel: false,
  replace: false,
  resolve: {},
  commonjs: {},
  typescript: {},
}
  • rollupPlugin.babel 说明
    • 如果值为布尔类型且为 false,表示不开启 babel,默认值为 void 0
    • 如果值为 void 0 或 true,即表示开启 babel 插件通用配置
      const { DEFAULT_EXTENSIONS } = require('@babel/core');
      {
      runtimeHelpers: true,
      // 只转换源代码,不运行外部依赖
      exclude: 'node_modules/**',
      // babel 默认不支持 ts 需要手动添加
      extensions: [...DEFAULT_EXTENSIONS, '.ts'],
      plugins: [
        '@babel/plugin-transform-runtime',
        ['@babel/plugin-proposal-decorators', { legacy: true }],
      ],
      }
    • 如果值为普通对象,表示自定义 babel 插件配置参数,并且会与通用配置进行合并,自定义参数配置文档参照rollup-plugin-babel
  • rollupPlugin.replace 说明
    • 如果值为布尔类型且为 false,表示不开启 replace,默认值为 void 0
    • 如果值为 void 0 或 true,即表示开启 replace 插件通用配置
      // 默认存在配置
      {
      __VERSION__: version,
      }
    • 如果值为普通对象,表示自定义 replace 插件配置参数,并且会与通用配置进行合并,自定义参数配置文档参照rollup-plugin-replace
  • rollupPlugin.resolve 说明

    • 如果值为布尔类型且为 false,表示不开启 resolve,默认值为 void 0
    • 如果值为 void 0 或 true,即表示开启 resolve 插件通用配置
      // 默认存在配置
      {
        jsnext: true,
        main: true,
        browser: true,
      }
    • 如果值为普通对象,表示自定义 resolve 插件配置参数,并且会与通用配置进行合并,自定义参数配置文档参照rollup-plugin-node-resolve
  • rollupPlugin.typescript 说明

    • 如果值为布尔类型且为 false,表示不开启 typescript,默认值为 void 0
    • 如果值为 void 0 或 true,即表示开启 typescript 插件通用配置
      // 默认存在配置
      {
        typescript: require('typescript'),
        include: ['*.ts+(|x)', '**/*.ts+(|x)'],
        clean: true,
        exclude: [
          'dist',
          'node_modules/**',
          '*.test.{js+(|x), ts+(|x)}',
          '**/*.test.{js+(|x), ts+(|x)}',
        ],
        moduleSpecifier:[],// 默认没有数据,如果填入了数据,则会开启  transformers: [transformer], 并填充底层提供的一个插件
        useTsconfigDeclarationDir: true,
      }
    • moduleSpecifier 默认配置项没有包含此数据,如果填入了数据,则会开启 transformers: [transformer], 并填充底层提供的一个插件 transformer
      // 示例
      [
        {
          libraryName: '../antd-toolkit',
          mapLibraryName: 'legions-lunar/antd-toolkit',
        },
        {
          libraryName: '../warning',
          mapLibraryName: 'legions-lunar/warning',
        },
      ];
    • before 你将无法直接配置 transformers 此配置项,配置项数据会插入 transformers。before 数据信息中
    • 如果值为普通对象,表示自定义 typescript 插件配置参数,并且会与通用配置进行合并,自定义参数配置文档参照rollup-plugin-typescript2

extendPlugins 配置自定义插件,将会在所有入口文件生效

entitys 入口文件配置数据,此数据是一个对象数组列表

  • name 入口名称,随意填写,不重复就行
  • input 入口文件路径
  • file 编译输出文件路径
  • format 模块编译类型 包含 es,umd 等,具体可参看 rollup
  • banner 写入编译库的信息,一般直接命名发布包的名称
  • compress 是否启动压缩
    • 如果为布尔类型且值为真,则开启压缩,启用通用配置
      const { terser } = require('rollup-plugin-terser');
      terser({ module: opts.format === 'es' });
    • 如果为普通对象,则参照 rollup-plugin-terser 配置信息填写
  • outputName 此参数一般在打包整体把所有输出信息导出到一个全局变量里面时使用,一般在 umd,min.js,如果没有填写,将会以 name 进行拼接
  • rollupPlugin 参照全局配置说明,如果配置了此信息,则以此信息生效,否则以全局生效

.lrpc-config.js

// .lrpc-config.js
const path = require('path');
const resolves = _path => path.join(process.cwd(), _path);
module.exports = {
  external: [
    'reflect-metadata',
    'antd',
    'react',
    'mobx',
    'prop-types',
    'legions-nprogress',
    'lodash.debounce',
    'lodash',
    'object-hash',
  ], // 对应rollup external  排除指定文件不处理
  rollupPlugin: {
    // cli 工具固定了babel,replace,resolve,commonjs,typescript等插件常用配置,如果不传,默认开启,
    // 值为false 表示该插件不启用
    // 值为对象,表示填入插件其他配置,或覆盖已有配置
    typescript: {
      moduleSpecifier: [
        {
          libraryName: '../antd-toolkit',
          mapLibraryName: 'legions-lunar/antd-toolkit',
        },
        {
          libraryName: '../schedule',
          mapLibraryName: 'legions-lunar/schedule',
        },
        {
          libraryName: '../warning',
          mapLibraryName: 'legions-lunar/warning',
        },
      ],
    },
  },
  extendPlugins: [], // 可添加其他插件放入rollup.plugin
  entitys: [
    {
      name: 'esmvmodel',
      input: resolves('src/model/index.ts'),
      file: resolves('model/index.js'),
      format: 'es',
      banner: 'legions-lunar',
      compress: false, // 如果为布尔类型且值为真,表示启动压缩,压缩插件启用默认配置信息,
      outputName: 'legionsLunar',
      rollupPlugin: {
        // 针对个性化入口文件配置设置,如果设置了,以此处为准,否则以全局属性rollupPlugin 对象值为准 ,如果都不设置,就是默认值
        resolve: false,
        commonjs: false,
        babel: false,
      },
    },
  ],
};

ChangeLog

0.0.8 (2020-09-19)

  • feat: 新增 rollup 打包 cli 工具库

  • feat: 新增支持 ts 打包

  • feat: 新增 babel 编译

0.0.9-beta.1 (2020-09-24)

  • fix: 修复压缩 rollup-plugin-uglify 插件无法编译 es6,替换成 rollup-plugin-terser

  • fix: 修复扩展插件无法生效问题