Skip to content

Commit 53a9666

Browse files
danielroeCopilot
andauthored
feat: support using rolldown/utils for parsing (#537)
* feat: support using `rolldown/utils` * fix: reorder imports and catalog keys for lint Agent-Logs-Url: https://github.com/unjs/unimport/sessions/c34b71d6-1326-4748-aa01-f64e78f5463a Co-authored-by: danielroe <28706372+danielroe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: danielroe <28706372+danielroe@users.noreply.github.com>
1 parent 68572cf commit 53a9666

6 files changed

Lines changed: 249 additions & 82 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,19 @@ By default, `unimport` uses RegExp to detect unimport entries. In some cases, Re
312312
For a more accurate result, you can switch to an AST-based parser:
313313

314314
- `acorn` — powered by [acorn](https://github.com/acornjs/acorn). Assumes the input is valid vanilla JavaScript, so it should usually be used after transformations and transpilation.
315-
- `oxc` — powered by [oxc-parser](https://github.com/oxc-project/oxc). Much faster than `acorn` and accepts TypeScript and JSX. Requires installing `oxc-parser` as an optional peer dependency.
315+
- `oxc` — powered by [oxc-parser](https://github.com/oxc-project/oxc). Much faster than `acorn` and accepts TypeScript and JSX. Requires installing either `rolldown` or `oxc-parser` as an optional peer dependency. (If both are installed, `rolldown` is preferred.)
316316

317317
```ts
318318
Unimport.vite({
319319
parser: 'oxc' // or 'acorn' or 'regex' (default)
320320
})
321321
```
322322

323-
To use the `oxc` parser, install `oxc-parser` alongside `unimport`:
323+
To use the `oxc` parser, install `rolldown` or `oxc-parser` alongside `unimport`:
324324

325325
```sh
326+
npm install rolldown
327+
# or
326328
npm install oxc-parser
327329
```
328330

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@
3535
"test": "vitest --coverage"
3636
},
3737
"peerDependencies": {
38-
"oxc-parser": "*"
38+
"oxc-parser": "*",
39+
"rolldown": "^1.0.0"
3940
},
4041
"peerDependenciesMeta": {
4142
"oxc-parser": {
4243
"optional": true
44+
},
45+
"rolldown": {
46+
"optional": true
4347
}
4448
},
4549
"dependencies": {
@@ -70,6 +74,7 @@
7074
"jquery": "catalog:test",
7175
"lit": "catalog:test",
7276
"oxc-parser": "catalog:prod",
77+
"rolldown": "catalog:prod",
7378
"typescript": "catalog:dev",
7479
"unbuild": "catalog:dev",
7580
"vitest": "catalog:test",

0 commit comments

Comments
 (0)