Skip to content

Commit 64ad171

Browse files
MarsupIanVS
andauthored
feat: add plugin-oxc support (#221)
Fixes #220. I copied the tests for babel/babel-ts, hopefully this is acceptable. --------- Co-authored-by: Ian VanSchooten <ian.vanschooten@gmail.com>
1 parent ddad06c commit 64ad171

20 files changed

Lines changed: 816 additions & 13 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build:
1010
strategy:
1111
matrix:
12-
node: [18.x, 20.x, 22.x]
12+
node: [20.x, 22.x, 24.x]
1313
platform: [ubuntu-latest, windows-latest]
1414
runs-on: ${{ matrix.platform }}
1515
steps:

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.4.1
1+
v24.2.0

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This project is based on [@trivago/prettier-plugin-sort-imports](https://github.
2222
- [Output](#output)
2323
- [Install](#install)
2424
- [Usage](#usage)
25+
- [Usage with @prettier/plugin-oxc](#usage-with-prettierplugin-oxc)
2526
- [How does import sort work?](#how-does-import-sort-work)
2627
- [Options](#options)
2728
- [`importOrder`](#importorder)
@@ -144,6 +145,10 @@ module.exports = {
144145
};
145146
```
146147

148+
### Usage with @prettier/plugin-oxc
149+
150+
This plugin is compatible with the new '@prettier/plugin-oxc' plugin available for Prettier 3.6+, but must be specified _after_ that plugin in the `plugins` configuration array (i.e. `plugins: ['@prettier/plugin-oxc', '@ianvs/prettier-plugin-sort-imports'],`).
151+
147152
### How does import sort work?
148153

149154
The plugin extracts the imports which are defined in `importOrder`. These imports are considered as _local imports_.

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"semver": "^7.5.2"
6161
},
6262
"devDependencies": {
63+
"@prettier/plugin-oxc": "^0.0.4",
6364
"@types/babel__generator": "^7.6.8",
6465
"@types/babel__traverse": "^7.20.5",
6566
"@types/node": "^18.15.13",
@@ -75,10 +76,14 @@
7576
"vite": "^4.0.0"
7677
},
7778
"peerDependencies": {
79+
"@prettier/plugin-oxc": "^0.0.4",
7880
"@vue/compiler-sfc": "2.7.x || 3.x",
7981
"prettier": "2 || 3 || ^4.0.0-0"
8082
},
8183
"peerDependenciesMeta": {
84+
"@prettier/plugin-oxc": {
85+
"optional": true
86+
},
8287
"@vue/compiler-sfc": {
8388
"optional": true
8489
}

pnpm-lock.yaml

Lines changed: 225 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ export const mergeableImportFlavors = [
2525

2626
// NOTE: 'test' is not included in `builtinModules` so explicitly check for "node:test"
2727
// REF: https://github.com/nodejs/node/issues/42785
28-
export const BUILTIN_MODULES_REGEX_STR = `(^(?:node:)?(?:${builtinModules.join(
29-
'|',
30-
)})$)|(^node:test$)`;
28+
// Update: Started being included in node 24 after https://github.com/nodejs/node/pull/56185
29+
export const BUILTIN_MODULES_REGEX_STR = `^(?:${builtinModules
30+
.flatMap((m) => (m.startsWith('node:') ? m : [`node:${m}`, m]))
31+
.join('|')}|node:test)$`;
3132

3233
export const BUILTIN_MODULES_SPECIAL_WORD = '<BUILTIN_MODULES>';
3334
/**

0 commit comments

Comments
 (0)