Skip to content

Commit

Permalink
feat: support for direct (global) browser import (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel authored Aug 22, 2024
1 parent 21385a0 commit d4c1c8e
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 87 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.DS_Store
deno.lock
/lib
/browser
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/lib
/CHANGELOG.md
/browser
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ bun run test:bun
deno task test:deno
```

Also, run `npm run build` to compile and run _E2E_ tests in the virtual browser.

---

### Lint
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![GitHub Workflow Status (Bun)](https://img.shields.io/github/actions/workflow/status/wellwelwel/jsonc.min/ci_bun.yml?event=push&label=&branch=main&logo=bun&logoColor=ffffff&color=f368e0)](https://github.com/wellwelwel/jsonc.min/actions/workflows/ci_bun.yml?query=branch%3Amain)
[![GitHub Workflow Status (Deno)](https://img.shields.io/github/actions/workflow/status/wellwelwel/jsonc.min/ci_deno.yml?event=push&label=&branch=main&logo=deno&logoColor=ffffff&color=079992)](https://github.com/wellwelwel/jsonc.min/actions/workflows/ci_deno.yml?query=branch%3Amain)

✨ Faster and safer <strong>JSON</strong> and <strong>JSONC</strong> minify, parse and stringify for <strong>JavaScript</strong> (<strong>Browser</strong> compatible) — **2.6kB**.
✨ Faster and safer <strong>JSON</strong> and <strong>JSONC</strong> minify, parse and stringify for <strong>JavaScript</strong> (<strong>Browser</strong> compatible) — **2.3kB**.

</div>

Expand All @@ -31,8 +31,6 @@

## Install

[![Install Size](https://packagephobia.com/badge?p=jsonc.min)](https://pkg-size.dev/jsonc.min)

```bash
# Node.js
npm i jsonc.min
Expand All @@ -54,14 +52,24 @@ deno add npm:jsonc.min

### Import

#### ES Modules

```js
import { JSONC } from 'jsonc.min';
```

#### CommonJS

```js
const { JSONC } = require('jsonc.min');
```

#### Browser

```html
<script src="https://cdn.jsdelivr.net/npm/jsonc.min/browser/jsonc.min.js"></script>
```

---

### `toJSON`
Expand Down
68 changes: 68 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jsonc.min",
"version": "1.0.1",
"description": "✨ Faster and safer JSON and JSONC minify, parse and stringify for JavaScript (Browser compatible) — 2.6kB.",
"description": "✨ Faster and safer JSON and JSONC minify, parse and stringify for JavaScript (Browser compatible) — 2.3kB.",
"main": "./lib/index.js",
"license": "MIT",
"repository": {
Expand All @@ -17,6 +17,7 @@
"url": "https://github.com/sponsors/wellwelwel"
},
"files": [
"browser",
"lib"
],
"engines": {
Expand All @@ -25,17 +26,23 @@
"deno": ">=1.30.0"
},
"scripts": {
"build": "tsc",
"prebuild": "rm -rf ./browser ./lib",
"build:browser": "tsx tools/browserfy.ts",
"build": "tsc && npm run build:browser",
"test:node": "poku --node -p",
"test:bun": "poku --bun -p",
"test:deno": "poku --deno -p",
"lint": "npx @biomejs/biome lint && prettier --check .",
"lint:fix": "npx @biomejs/biome lint --write && prettier --write .github/workflows/*.yml .",
"update": "pu minor && npm i && npm audit fix",
"postupdate": "npm run lint:fix"
"postupdate": "npm run lint:fix",
"size": "ls -lh lib/index.js | awk '{print $5}'"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@types/node": "^22.5.0",
"esbuild": "^0.23.1",
"happy-dom": "^15.0.0",
"packages-update": "^2.0.0",
"poku": "^2.5.0",
"prettier": "^3.3.3",
Expand All @@ -50,6 +57,12 @@
"parse",
"parser",
"stringify",
"jsonc-to-json"
"jsonc-to-json",
"node",
"nodejs",
"bun",
"deno",
"typescript",
"browser"
]
}
Loading

0 comments on commit d4c1c8e

Please sign in to comment.