Giter Club home page Giter Club logo

unplugin-inline-enum's Introduction

unplugin-inline-enum npm jsr

Unit Test

Inline enum values to optimize bundle size.

Features

  • 🚀 Inline enum values to reduce the size of the bundle.
  • 🧹 Simplify generated enums in JavaScript.
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

# npm
npm i -D unplugin-inline-enum

# jsr
npx jsr add -D @unplugin/inline-enum
Vite
// vite.config.ts
import InlineEnum from 'unplugin-inline-enum/vite'

export default defineConfig({
  plugins: [InlineEnum()],
})


Rollup
// rollup.config.js
import InlineEnum from 'unplugin-inline-enum/rollup'

export default {
  plugins: [InlineEnum()],
}


esbuild
// esbuild.config.js
import { build } from 'esbuild'

build({
  plugins: [require('unplugin-inline-enum/esbuild')()],
})


Webpack
// webpack.config.js
module.exports = {
  /* ... */
  plugins: [require('unplugin-inline-enum/webpack')()],
}


Options

Refer to docs.

Credits

Thanks to @xiaoxiangmoe and @yangmingshan for their contributions in the PR.

Sponsors

License

MIT License © 2024-PRESENT 三咲智子

unplugin-inline-enum's People

Contributors

sxzz avatar renovate[bot] avatar cloydlau avatar

Stargazers

Svenit avatar Hung Hoang avatar waset avatar Denis avatar Samuel Burkhard avatar Vadim Chetkov avatar Matoz avatar Makoto Tateno avatar Denis avatar Wyatt Stanke avatar Florian Hofmann avatar Daniel Bannert avatar  avatar Adam Haglund avatar  avatar Vitalij Ryndin avatar  avatar Chris avatar HappyWood avatar Tim W. avatar BackRunner avatar Rintaro Itokawa avatar Jonny Gamba avatar jonz94 avatar Robert Soriano avatar Heitor Ramon Ribeiro avatar Anthony Fu avatar The web walker avatar wfly avatar kirin avatar Halil avatar Zhazha_JiaYiZhen avatar  avatar

Watchers

 avatar Anthony Fu avatar

unplugin-inline-enum's Issues

是否可以支持更低版本的node

Clear and concise description of the problem

目前package.json的engines node字段版本是>=18。

Suggested solution

支持更低版本的node,相关语法特性调整。

Alternative

No response

Additional context

No response

Validations

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • fix(deps): update all non-major dependencies (execa, tsx)

Detected dependencies

github-actions
.github/workflows/release.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/unit-test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @rollup/pluginutils ^5.1.0
  • ast-kit ^0.12.1
  • execa ^9.0.2
  • fast-glob ^3.3.2
  • magic-string ^0.30.10
  • picomatch ^4.0.2
  • unplugin ^1.10.1
  • unplugin-replace ^0.3.1
  • @babel/types ^7.24.5
  • @sxzz/eslint-config ^3.11.0
  • @sxzz/prettier-config ^2.0.2
  • @types/node ^20.12.11
  • @types/picomatch ^2.3.3
  • @vue-macros/test-utils ^1.4.0
  • bumpp ^9.4.1
  • esbuild ^0.21.2
  • eslint ^9.2.0
  • prettier ^3.2.5
  • rollup ^4.17.2
  • tsup ^8.0.2
  • tsx ^4.10.1
  • typescript ^5.4.5
  • vite ^5.2.11
  • vitest ^1.6.0
  • webpack ^5.91.0
  • pnpm 9.1.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.