Skip to content

Commit 9c05431

Browse files
committed
chore: add oxlint and oxfmt
1 parent 5e5c9e2 commit 9c05431

11 files changed

Lines changed: 408 additions & 229 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'test'
1+
name: "test"
22
on: push
33

44
jobs:
@@ -13,9 +13,11 @@ jobs:
1313
- name: Install Node.js
1414
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
1515
with:
16-
node-version-file: '.node-version'
17-
cache: 'pnpm'
16+
node-version-file: ".node-version"
17+
cache: "pnpm"
1818

1919
- run: pnpm install
20+
- run: pnpm lint
21+
- run: pnpm format --check
2022
- run: pnpm build
2123
- run: pnpm test

.oxfmtrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"ignorePatterns": ["polyfills", "test/examples", "src/polyfills.ts"]
4+
}

.oxlintrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"categories": {
4+
"correctness": "deny",
5+
"suspicious": "deny"
6+
},
7+
"ignorePatterns": ["polyfills", "test/examples"]
8+
}

README.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,38 @@ npm install --save-dev @rolldown/plugin-node-polyfills
1111
```
1212

1313
```js
14-
import { rolldown } from 'rolldown'
15-
import nodePolyfills from '@rolldown/plugin-node-polyfills'
14+
import { rolldown } from "rolldown";
15+
import nodePolyfills from "@rolldown/plugin-node-polyfills";
1616

1717
rolldown({
18-
entry: 'main.js',
19-
plugins: [nodePolyfills()]
20-
})
18+
entry: "main.js",
19+
plugins: [nodePolyfills()],
20+
});
2121
```
2222

2323
## Node.js Builtin Support Table
2424

2525
The following modules include ES6 specific version which allow you to do named imports in addition to the default import and should work fine if you only use this plugin.
2626

27-
- process*
27+
- process\*
2828
- events
29-
- stream*
30-
- util*
29+
- stream\*
30+
- util\*
3131
- path
32-
- buffer*
32+
- buffer\*
3333
- querystring
34-
- url*
35-
- string_decoder*
34+
- url\*
35+
- string_decoder\*
3636
- punycode
37-
- http*
38-
- https*
39-
- os*
40-
- assert*
37+
- http\*
38+
- https\*
39+
- os\*
40+
- assert\*
4141
- constants
42-
- timers*
43-
- console*
44-
- vm*§
45-
- zlib*
42+
- timers\*
43+
- console\*
44+
- vm\*§
45+
- zlib\*
4646
- tty
4747
- domain
4848
- dns∆
@@ -56,8 +56,7 @@ The following modules include ES6 specific version which allow you to do named i
5656
- tls∆
5757
- fs˚
5858
- crypto˚
59-
- perf_hooks˚ - **New:* just an empty shim for now, but would love help building a true polyfill!*
60-
59+
- perf*hooks˚ - \*\_New:* just an empty shim for now, but would love help building a true polyfill!\*
6160

6261
† the http and https modules are actually the same and don't differentiate based on protocol
6362

@@ -67,6 +66,6 @@ The following modules include ES6 specific version which allow you to do named i
6766

6867
∆ not shimmed, just returns mock
6968

70-
˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected.
69+
˚ shimmed, but too complex to polyfill fully. Avoid if at all possible. Some bugs and partial support expected.
7170

7271
Not all included modules bundle equally, streams (and by extension anything that requires it like http) are a mess of circular references that are pretty much impossible to tree-shake out, similarly url methods are actually a shortcut to a url object so those methods don't tree shake out very well, punycode, path, querystring, events, util, and process tree shake very well especially if you do named imports.

package.json

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,44 @@
22
"name": "@rolldown/plugin-node-polyfills",
33
"version": "1.0.0",
44
"description": "node polyfills for Rolldown",
5-
"main": "dist/index.cjs",
6-
"types": "dist/index.d.ts",
7-
"type": "module",
5+
"keywords": [
6+
"rolldown",
7+
"rolldown-plugin"
8+
],
9+
"homepage": "https://github.com/rolldown/rolldown-plugin-node-polyfills#readme",
10+
"bugs": {
11+
"url": "https://github.com/rolldown/rolldown-plugin-node-polyfills/issues"
12+
},
13+
"license": "MIT",
14+
"author": "Evan You",
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/rolldown/rolldown-plugin-node-polyfills.git"
18+
},
819
"files": [
920
"dist/index.cjs",
1021
"dist/index.d.ts"
1122
],
23+
"type": "module",
24+
"main": "dist/index.cjs",
25+
"types": "dist/index.d.ts",
1226
"scripts": {
1327
"test": "vitest --run",
1428
"prebuild": "rm -rf dist",
1529
"build": "node scripts/build.js && tsc -p . && rolldown -c rolldown.config.mjs",
16-
"prepublishOnly": "npm build"
17-
},
18-
"repository": {
19-
"type": "git",
20-
"url": "git+https://github.com/rolldown/rolldown-plugin-node-polyfills.git"
21-
},
22-
"keywords": [
23-
"rolldown",
24-
"rolldown-plugin"
25-
],
26-
"author": "Evan You",
27-
"license": "MIT",
28-
"bugs": {
29-
"url": "https://github.com/rolldown/rolldown-plugin-node-polyfills/issues"
30+
"prepublishOnly": "npm build",
31+
"lint": "oxlint",
32+
"format": "oxfmt"
3033
},
31-
"homepage": "https://github.com/rolldown/rolldown-plugin-node-polyfills#readme",
32-
"packageManager": "pnpm@10.28.1",
3334
"devDependencies": {
3435
"@types/node": "^22.2.0",
36+
"oxfmt": "^0.27.0",
37+
"oxlint": "^1.42.0",
3538
"rolldown": "^1.0.0-rc.1",
3639
"typescript": "^5.5.4",
3740
"vitest": "^4.0.0"
3841
},
42+
"packageManager": "pnpm@10.28.1",
3943
"compatiblePackages": {
4044
"schemaVersion": 1,
4145
"rollup": {

0 commit comments

Comments
 (0)