Skip to content

Commit 2188073

Browse files
authored
Revert "fix: conditionally register ember and oxc parsers when depend… (#237)
…encies available (#234)" This reverts commit 593fe17. Closes #235 Reference #234 (comment)
1 parent af7af0e commit 2188073

1 file changed

Lines changed: 26 additions & 34 deletions

File tree

src/index.ts

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@ const getEmberPlugin = () => {
6767
}
6868
};
6969

70-
const isEmberPluginAvailable = () => {
71-
try {
72-
getEmberPlugin();
73-
return true;
74-
} catch {
75-
return false;
76-
}
77-
};
78-
7970
const getOxcPlugin = () => {
8071
try {
8172
const oxcPlugin = require('@prettier/plugin-oxc');
@@ -88,15 +79,6 @@ const getOxcPlugin = () => {
8879
}
8980
};
9081

91-
const isOxcPluginAvailable = () => {
92-
try {
93-
getOxcPlugin();
94-
return true;
95-
} catch {
96-
return false;
97-
}
98-
};
99-
10082
export const parsers = {
10183
babel: {
10284
...babelParsers.babel,
@@ -106,26 +88,34 @@ export const parsers = {
10688
...babelParsers['babel-ts'],
10789
preprocess: defaultPreprocessor,
10890
},
109-
...(isEmberPluginAvailable() && {
110-
'ember-template-tag': {
111-
...getEmberPlugin().parsers['ember-template-tag'],
91+
get 'ember-template-tag'() {
92+
const emberPlugin = getEmberPlugin();
93+
94+
return {
95+
...emberPlugin.parsers['ember-template-tag'],
11296
preprocess: emberPreprocessor,
113-
},
114-
}),
97+
};
98+
},
11599
flow: {
116100
...flowParsers.flow,
117101
preprocess: defaultPreprocessor,
118102
},
119-
...(isOxcPluginAvailable() && {
120-
oxc: {
121-
...getOxcPlugin().parsers.oxc,
103+
get oxc() {
104+
const oxcPlugin = getOxcPlugin();
105+
106+
return {
107+
...oxcPlugin.parsers.oxc,
122108
preprocess: defaultPreprocessor,
123-
},
124-
'oxc-ts': {
125-
...getOxcPlugin().parsers['oxc-ts'],
109+
};
110+
},
111+
get 'oxc-ts'() {
112+
const oxcPlugin = getOxcPlugin();
113+
114+
return {
115+
...oxcPlugin.parsers['oxc-ts'],
126116
preprocess: defaultPreprocessor,
127-
},
128-
}),
117+
};
118+
},
129119
typescript: {
130120
...typescriptParsers.typescript,
131121
preprocess: defaultPreprocessor,
@@ -137,7 +127,9 @@ export const parsers = {
137127
};
138128

139129
export const printers = {
140-
...(isOxcPluginAvailable() && {
141-
'estree-oxc': getOxcPlugin().printers['estree-oxc'],
142-
}),
130+
get 'estree-oxc'() {
131+
const oxcPlugin = getOxcPlugin();
132+
133+
return oxcPlugin.printers['estree-oxc'];
134+
},
143135
};

0 commit comments

Comments
 (0)