• Version 5.0.5
  • Published
  • 165 kB
  • 23 dependencies
  • MIT license


npm i bili
yarn add bili
pnpm add bili


A zero configuration library bundler.



class Bundler

class Bundler {}


    constructor(config: Config, options?: Options);

      property bundles

      bundles: Set<Assets>;

        property config

        config: NormalizedConfig;

          property configPath

          configPath?: string;

            property options

            options: Options;

              property pkg

              pkg: { path?: string; data?: any };

                property rootDir

                rootDir: string;

                  method build

                  build: (task: Task, context: RunContext, write?: boolean) => Promise<void>;

                    method createRollupConfig

                    createRollupConfig: ({
                    }: RollupConfigInput) => Promise<RollupConfig>;

                      method getBundle

                      getBundle: (index: number) => Assets;

                        method handleError

                        handleError: (err: any) => void;

                          method localRequire

                          localRequire: (
                          name: string,
                          { silent, cwd }?: { silent?: boolean; cwd?: string }
                          ) => any;

                            method normalizeConfig

                            normalizeConfig: (
                            config: Config,
                            userConfig: Config
                            ) => Config & {
                            input: string | ConfigEntryObject | (string | ConfigEntryObject)[];
                            output: ConfigOutput;
                            plugins: { [name: string]: any };
                            babel: { asyncToPromises: boolean } & import('./types').BabelPresetOptions;
                            externals: (
                            | string
                            | RegExp
                            | ((id: string, parentId?: string | undefined) => boolean)

                              method resolveRootDir

                              resolveRootDir: (...args: string[]) => string;

                                method run

                                run: (options?: RunOptions) => Promise<this>;


                                  interface Config

                                  interface Config {}

                                    property babel

                                    babel?: BabelPresetOptions;
                                    • Configure the default babel preset

                                    property banner

                                    banner?: Banner;
                                    • Insert a copyright message to the top of output bundle.

                                    property bundleNodeModules

                                    bundleNodeModules?: boolean | string[];
                                    • Include node modules in the bundle. Note that this is always true for UMD bundle. --bundle-node-modules

                                    property env

                                    env?: Env;
                                    • Define env variables that are only available in your library code. i.e. if you have some code like this in your library.

                                      if (process.env.NODE_ENV === 'development') {

                                      And you can run following command to replace the env variable:

                                      bili --env.NODE_ENV production

                                      By default we don't add any env variables.

                                      --env.<name> value

                                    property extendConfig

                                    extendConfig?: ExtendConfig;
                                    • Extending Bili config

                                    property extendRollupConfig

                                    extendRollupConfig?: ExtendRollupConfig;
                                    • Extending generated rollup config

                                    property externals

                                    externals?: Externals;
                                    • When inlining node modules You can use this option to exclude specific modules

                                    property globals

                                    globals?: {
                                    [k: string]: string;
                                    • Specifies moduleId: variableName pairs necessary for external imports in umd/iife bundles. For example, in a case like this...

                                      import $ from 'jquery'

                             can map the jquery module ID to the global $ variable:

                                      // bili.config.js
                                      export default {
                                      globals: {
                                      jquery: '$'

                                      --global.<moduleId> <variableName

                                    property input

                                    input?: string | ConfigEntryObject | Array<ConfigEntryObject | string>;
                                    • Input files src/index.js bili [...input]

                                    property output

                                    output?: ConfigOutput;

                                      property plugins

                                      plugins?: {
                                      [name: string]: any;
                                      • Use Rollup plugins

                                        // bili.config.js
                                        module.exports = {
                                        plugins: {
                                        svelte: {
                                        // Any options for rollup-plugin-svelte

                                        You can also use CLI flags to add plugins, e.g.

                                        bili --plugin.svelte
                                        # with option
                                        bili bar
                                        # Same as using `svelte: { foo: 'bar' }` in config file

                                        --plugin.<name> [option]

                                      property resolvePlugins

                                      resolvePlugins?: {
                                      [name: string]: any;
                                      • Defines how to resolve a plugin by name This will override the default behavior e.g.

                                        resolvePlugins: {
                                        replace: require('./my-fork-of-rollup-plugin-replace')

                                      interface ConfigOutput

                                      interface ConfigOutput {}

                                        property dir

                                        dir?: string;
                                        • Output directory dist -d, --out-dir <dir>

                                        property extractCSS

                                        extractCSS?: boolean;
                                        • Extract CSS into a single file. true

                                        property fileName

                                        fileName?: string | GetFileName;
                                        • Output file name

                                          Default value: - [name][min][ext] in cjs and esm format. - [name][min].[format].js in other formats.

                                          Placeholders: - [name]: The base name of input file. (without extension) - [format]: The output format. (without -min suffix) - [min]: It will replaced by .min when the format ends with -min, otherwise it's an empty string.

                                          The value can also be a function which returns the fileName template, The placeholders are also available in the return value.

                                          --file-name <fileName>

                                        property format

                                        format?: Format | Format[];
                                        • Output format(s). You can append min to the format to generate minified bundle.

                                          cjs --format <format>

                                        property minify

                                        minify?: boolean;
                                        • Whether to minify output files regardless of format, using this option won't add .min suffix to the output file name.

                                        property moduleName

                                        moduleName?: string;
                                        • Module name for umd bundle

                                        property sourceMap

                                        sourceMap?: boolean;
                                        • Generate source maps true for minified bundle, false otherwise

                                        property sourceMapExcludeSources

                                        sourceMapExcludeSources?: boolean;
                                        • Exclude source code in source maps

                                        property target

                                        target?: OutputTarget;
                                        • Output target node --target <target>

                                        interface NormalizedConfig

                                        interface NormalizedConfig {}

                                          property babel

                                          babel: BabelPresetOptions;

                                            property banner

                                            banner?: Banner;

                                              property bundleNodeModules

                                              bundleNodeModules?: boolean | string[];

                                                property env

                                                env?: Env;

                                                  property extendConfig

                                                  extendConfig?: ExtendConfig;

                                                    property extendRollupConfig

                                                    extendRollupConfig?: ExtendRollupConfig;

                                                      property externals

                                                      externals: Externals;

                                                        property globals

                                                        globals?: {
                                                        [k: string]: string;

                                                          property input

                                                          input?: string | ConfigEntryObject | Array<ConfigEntryObject | string>;

                                                            property output

                                                            output: Overwrite<ConfigOutput, ConfigOutputOverwrite>;

                                                              property plugins

                                                              plugins: {
                                                              [name: string]: any;

                                                                property resolvePlugins

                                                                resolvePlugins?: {
                                                                [name: string]: any;

                                                                  interface Options

                                                                  interface Options {}

                                                                    property configFile

                                                                    configFile?: string | boolean;
                                                                    • Use a custom config file rather than auto-loading bili.config.js

                                                                    property logLevel

                                                                    logLevel?: 'verbose' | 'quiet';
                                                                    • Log level

                                                                    property rootDir

                                                                    rootDir?: string;
                                                                    • The root directory to resolve files from Useful for mono-repo e.g. You can install Bili in root directory and leaf packages can use their own Bili config file: - bili --root-dir packages/foo - bili --root-dir packages/bar

                                                                    property stackTrace

                                                                    stackTrace?: boolean;
                                                                    • Always show stack trace

                                                                    Package Files (2)

                                                                    Dependencies (23)

                                                                    Dev Dependencies (42)

                                                                    Peer Dependencies (0)

                                                                    No peer dependencies.


                                                                    To add a badge like this badgeto your package's README, use the codes available below.

                                                                    You may also use to create a custom badge linking to

                                                                    • Markdown
                                                                    • HTML
                                                                      <a href=""><img src="" alt=""></a>