Skip to content

Commit

Permalink
chore: improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Mar 4, 2024
1 parent 4bc90ae commit a0aa3a7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 10 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,37 @@

[![Unit Test](https://github.com/unplugin/unplugin-inline-enum/actions/workflows/unit-test.yml/badge.svg)](https://github.com/unplugin/unplugin-inline-enum/actions/workflows/unit-test.yml)

Inline enum value to optimize bundle size.
Inline enum values to optimize bundle size.

## Features

- 🚀 Inline enum values to reduce the size of the bundle.
- 🧹 Simplify generated enums in JavaScript.

```ts
export enum TestEnum {
a = 1,
b = 'foo',
}
console.log(TestEnum.a, TestEnum.b)

// before
export let TestEnum
;(function (TestEnum) {
TestEnum[(TestEnum.a = 1)] = 'a'
TestEnum.b = 'foo'
})(TestEnum || (TestEnum = {}))

console.log(TestEnum.a, TestEnum.b)

// after
const TestEnum = {
a: 1,
'1': 'a',
b: 'foo',
}
console.log(1, 'foo')
```

## Installation

Expand Down Expand Up @@ -65,10 +95,6 @@ module.exports = {

<br></details>

## Usage

> Working in Progress...
## Options

Refer to [docs](https://jsr.io/@unplugin/inline-enum/doc/api/~/Options).
Expand All @@ -89,3 +115,7 @@ Thanks to @xiaoxiangmoe and @yangmingshan for their contributions in the
## License

[MIT](./LICENSE) License © 2024-PRESENT [三咲智子](https://github.com/sxzz)

```
```
9 changes: 8 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
const { sxzz } = require('@sxzz/eslint-config')
module.exports = sxzz()
module.exports = sxzz([
{
files: ['README.md/*.ts'],
rules: {
'import/no-mutable-exports': 'off',
},
},
])
4 changes: 4 additions & 0 deletions src/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export interface Options {
include?: FilterPattern
exclude?: FilterPattern
enforce?: 'pre' | 'post' | undefined
/**
* The mode used to scan for enum files.
* @default 'fs'
*/
scanMode?: 'git' | 'fs'
/**
* The directory to scan for enum files.
Expand Down
4 changes: 2 additions & 2 deletions src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import unplugin from './index'
* @example
* ```ts
* // rollup.config.js
* import Macros from 'unplugin-inline-enum/rollup'
* import InlineEnum from 'unplugin-inline-enum/rollup'
*
* export default {
* plugins: [Macros()],
* plugins: [InlineEnum()],
* }
* ```
*/
Expand Down
4 changes: 2 additions & 2 deletions src/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import unplugin from './index'
* @example
* ```ts
* // vite.config.ts
* import Macros from 'unplugin-inline-enum/vite'
* import InlineEnum from 'unplugin-inline-enum/vite'
*
* export default defineConfig({
* plugins: [Macros()],
* plugins: [InlineEnum()],
* })
* ```
*/
Expand Down

0 comments on commit a0aa3a7

Please sign in to comment.