Detalhes do pacote

browserslist-load-config

rspack-contrib435.8kMIT1.0.0

readme (leia-me)

browserslist-load-config

npm version license downloads

Introduction

This package is a fork of browserslist.loadConfig with some modifications to make it faster.

Compare to browserslist, this package has the following improvements and differences:

  • 27 times smaller bundle size
  • 140 times smaller install size.
  • Zero dependencies.
  • Written in TypeScript.
  • Smaller and faster.
  • Does not support env variables.

See bundlephobia - browserslist-load-config vs bundlephobia - browserslist for bundle size comparison.

See packagephobia - browserslist-load-config vs packagephobia - browserslist for install size comparison.

Credits

Thanks Andrey Sitnik for creating the Browserslist which is under MIT License.

Usage

Install:

npm add browserslist-load-config -D

loadConfig

import { loadConfig } from "browserslist-load-config";

// Pass a path to the configuration file
const config = loadConfig({
  /**
   * Specify the directory where the configuration file is located
   */
  path: "./path/to/project/root",

  /**
   * Specify the environment to load
   * @default "production"
   */
  env: "production",
});

// Pass a browserslist config directly
const config = loadConfig({
  /**
   * Specify the directory where the configuration file is located
   */
  path: "./path/to/project/root",

  /**
   * Specify the environment to load
   * @default "production"
   */
  env: "production",
});

console.log(config);
/**
 * [
 *   // browserslist config
 * ]
 */

If both config and path are provided, config will be used.

findConfig

import { findConfig } from "browserslist-load-config";

const config = findConfig("./path/to/project/root");

console.log(config);
/**
 * {
 *   defaults: [
 *     // default browserslist config
 *   ],
 *   development: [
 *     // development browserslist config
 *   ],
 *   production: [
 *     // production browserslist config
 *   ],
 * }
 */

License

MIT.