bili
- Version 5.0.5
- Published
- 165 kB
- 23 dependencies
- MIT license
Install
npm i bili
yarn add bili
pnpm add bili
Overview
A zero configuration library bundler.
Index
Classes
Interfaces
Classes
class Bundler
class Bundler {}
constructor
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: ({ source, format, title, context, assets, config,}: 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>;
Interfaces
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') {console.log('debug')}And you can run following command to replace the env variable:
bili --env.NODE_ENV productionBy 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'...you can map the
jquery
module ID to the global$
variable:// bili.config.jsexport 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.jsmodule.exports = {plugins: {svelte: {// Any options for rollup-plugin-svelte}}}You can also use CLI flags to add plugins, e.g.
bili --plugin.svelte# with optionbili --plugin.svelte.foo 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]
incjs
andesm
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)
- @babel/core
- @babel/plugin-proposal-nullish-coalescing-operator
- @babel/plugin-proposal-object-rest-spread
- @babel/plugin-proposal-optional-chaining
- @babel/plugin-transform-react-jsx
- @babel/preset-env
- @babel/preset-typescript
- @rollup/plugin-babel
- @rollup/plugin-buble
- @rollup/plugin-commonjs
- @rollup/plugin-json
- @rollup/plugin-node-resolve
- @rollup/plugin-replace
- babel-plugin-transform-async-to-promises
- cac
- chalk
- joycon
- ora
- rollup
- rollup-plugin-hashbang
- rollup-plugin-postcss
- rollup-plugin-terser
- v8-compile-cache
Dev Dependencies (42)
- @types/babel__core
- @types/babel__generator
- @types/babel__template
- @types/babel__traverse
- @types/elegant-spinner
- @types/jest
- @types/lodash
- @types/node
- @types/pify
- @types/require-from-string
- @types/resolve
- babel-plugin-alter-object-assign
- boxen
- builtin-modules
- commitizen
- cz-conventional-changelog
- gzip-size
- husky
- jest
- lint-staged
- lodash
- nswatch
- p-waterfall
- pify
- prettier
- pretty-bytes
- pretty-ms
- require-from-string
- require-so-slow
- resolve
- resolve-from
- rollup-plugin-typescript2
- semantic-release
- semver
- slash
- string-width
- stringify-author
- text-table
- tinydate
- ts-jest
- typedoc
- typescript
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/bili
.
- Markdown[](https://www.jsdocs.io/package/bili)
- HTML<a href="https://www.jsdocs.io/package/bili"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2113 ms. - Missing or incorrect documentation? Open an issue for this package.