diff --git a/package.json b/package.json index 9f1a2a3..7c3e863 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ }, "devDependencies": { "@babel/core": "^7.26.7", + "@prettier/plugin-oxc": "^0.1.3", "@types/babel__core": "^7.20.5", "@types/babel__generator": "^7.27.0", "@types/babel__traverse": "^7.20.7", @@ -61,6 +62,7 @@ "vitest": "^3.2.4" }, "peerDependencies": { + "@prettier/plugin-oxc": ">= 0.1.0", "@vue/compiler-sfc": "3.x", "prettier": "2.x - 3.x", "prettier-plugin-ember-template-tag": ">= 2.0.0", @@ -71,6 +73,9 @@ "node": ">= 20" }, "peerDependenciesMeta": { + "@prettier/plugin-oxc": { + "optional": true + }, "@vue/compiler-sfc": { "optional": true }, diff --git a/src/index.ts b/src/index.ts index b449bfd..cdc33b4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,11 @@ import { createSvelteParsers } from './utils/create-svelte-parsers.js'; const emberParsers = await createEmberParsers(); const svelteParsers = await createSvelteParsers(); +let oxcParsers: Record = {}; +try { + oxcParsers = (await import('@prettier/plugin-oxc')).parsers; +} catch {} + const options: Options = { importOrderExclude: { type: 'path', @@ -129,6 +134,18 @@ export default { }, } : {}), + ...(oxcParsers.oxc + ? { + oxc: { + ...oxcParsers.oxc, + preprocess: defaultPreprocessor, + }, + 'oxc-ts': { + ...oxcParsers['oxc-ts'], + preprocess: defaultPreprocessor, + }, + } + : {}), }, options, };