Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rspack-contrib/browserslist-load-config
The `browserslist.loadConfig` method exported as a module.
https://github.com/rspack-contrib/browserslist-load-config
browserslist
Last synced: about 1 month ago
JSON representation
The `browserslist.loadConfig` method exported as a module.
- Host: GitHub
- URL: https://github.com/rspack-contrib/browserslist-load-config
- Owner: rspack-contrib
- License: mit
- Created: 2024-09-28T02:08:53.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-12-01T01:40:31.000Z (about 1 month ago)
- Last Synced: 2024-12-01T02:28:59.621Z (about 1 month ago)
- Topics: browserslist
- Language: TypeScript
- Homepage:
- Size: 85 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# browserslist-load-config
## Introduction
This package is a fork of [browserslist.loadConfig](https://github.com/browserslist/browserslist) 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](https://bundlephobia.com/package/browserslist-load-config) vs [bundlephobia - browserslist](https://bundlephobia.com/package/browserslist) for bundle size comparison.
> See [packagephobia - browserslist-load-config](https://packagephobia.com/result?p=browserslist-load-config) vs [packagephobia - browserslist](https://packagephobia.com/result?p=browserslist) for install size comparison.
## Credits
Thanks [Andrey Sitnik](https://github.com/ai) for creating the [Browserslist](https://github.com/browserslist/browserslist) which is under [MIT License](https://github.com/browserslist/browserslist/blob/main/LICENSE).
## Usage
Install:
```bash
npm add browserslist-load-config -D
```### loadConfig
```ts
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
```ts
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](./LICENSE).