# vite-sloppy-mode

> Compatible with sloppy mode

Latest version **1.0.3** (published 2023-05-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install vite-sloppy-mode
pnpm add vite-sloppy-mode
yarn add vite-sloppy-mode
bun add vite-sloppy-mode
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-05-06 |
| First published | 2023-05-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 11.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | goblin-pitcher |
| Keywords | vite, sloppy mode |

## Links

- npm: https://www.npmjs.com/package/vite-sloppy-mode
- Repository: https://github.com/goblin-pitcher/vite-sloppy-mode.git#main
- Homepage: https://github.com/goblin-pitcher/vite-sloppy-mode/tree/main#readme
- Issues: https://github.com/goblin-pitcher/vite-sloppy-mode/issues
- npm.io page: https://npm.io/package/vite-sloppy-mode

## Dependencies (5)

- [@babel/types](https://npm.io/package/@babel/types.md) ^7.21.5
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.21.8
- [@babel/traverse](https://npm.io/package/@babel/traverse.md) ^7.21.5
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.21.5
- [@types/babel__traverse](https://npm.io/package/@types/babel__traverse.md) ^7.18.5

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2023-05-06
- 1.0.2 — 2023-05-06
- 1.0.1 — 2023-05-06
- 1.0.0 — 2023-05-06

## README

## vite-sloppy-mode

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

```js
import { glob } from "glob"

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

该插件转换后代码如下：

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



### 用法

```typescript
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;

```

---
_Source: https://npm.io/package/vite-sloppy-mode · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
