1.0.3 • Published 1 year ago

vite-sloppy-mode v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

vite-sloppy-mode

一些很老的库采用宽松模式的写法,vite不兼容宽松模式,从而报错

import { glob } from "glob"

var a;
a = 7;
b = 9;
function f() {
  a = 10;
  b = 7;
  c = 12;
}

该插件转换后代码如下:

import { glob } from "glob";
var b, c;
var a;
a = 7;
b = 9;
function f() {
  a = 10;
  b = 7;
  c = 12;
}

用法

import { defineConfig } from "vite";
import viteSloppyMode from "vite-sloppy-mode";

const config = defineConfig({
  plugins: [
    viteSloppyMode({
      // 假设只针对node_modules下的xxx库
      // include、exclude传入格式为: RegExp[]
      include: [/node_modules(.+?)xxx/],
      exclude: []
    })
  ]
})

export default config;