File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed
Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change 1+ #### Fix ` prettier.getFileInfo() ` change that breaks VSCode extension (#18375 by @fisker )
2+
3+ An internal refactor accidentally broke the VSCode extension plugin loading.
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ async function logFileInfoOrDie(context) {
1616 const fileInfo = await getFileInfo ( path . resolve ( file ) , {
1717 ignorePath,
1818 withNodeModules,
19- plugins,
19+ plugins : plugins . length > 0 ? plugins : undefined ,
2020 resolveConfig : config !== false ,
2121 } ) ;
2222
Original file line number Diff line number Diff line change 11import { resolveConfig } from "../config/resolve-config.js" ;
2- import { loadPlugins } from "../main/plugins/index.js" ;
2+ import { loadBuiltinPlugins , loadPlugins } from "../main/plugins/index.js" ;
33import { isIgnored } from "../utils/ignore.js" ;
44import inferParser from "../utils/infer-parser.js" ;
55
@@ -54,10 +54,14 @@ async function getParser(file, options) {
5454 return config . parser ;
5555 }
5656
57- const plugins = [
58- ...options . plugins ,
59- ...( await loadPlugins ( config ?. plugins ?? [ ] ) ) ,
60- ] ;
57+ let plugins = options . plugins ?? config ?. plugins ?? [ ] ;
58+
59+ // We should wrap this funciton with `withPlugins` and use `options.plugins` directly instead of loading plugins here
60+ // See #18375 #18081
61+ // But somehow it breaks VSCode extension, see #18353
62+ plugins = (
63+ await Promise . all ( [ loadBuiltinPlugins ( ) , loadPlugins ( plugins ) ] )
64+ ) . flat ( ) ;
6165
6266 return inferParser ( { plugins } , { physicalFile : file } ) ;
6367}
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import { closestMatch as closetLevenshteinMatch } from "leven";
1111import picocolors from "picocolors" ;
1212import * as vnopts from "vnopts" ;
1313import * as errors from "./common/errors.js" ;
14- import getFileInfoWithoutPlugins from "./common/get-file-info.js" ;
1514import { mockable } from "./common/mockable.js" ;
1615import {
1716 clearCache as clearConfigCache ,
@@ -91,8 +90,6 @@ const inferParser = withPlugins((file, options) =>
9190 inferParserWithoutPlugins ( options , { physicalFile : file } ) ,
9291) ;
9392
94- const getFileInfo = withPlugins ( getFileInfoWithoutPlugins ) ;
95-
9693// Internal shared with cli
9794const sharedWithCli = {
9895 errors,
@@ -135,11 +132,11 @@ export {
135132 clearCache as clearConfigCache ,
136133 format ,
137134 formatWithCursor ,
138- getFileInfo ,
139135 getSupportInfo ,
140136 resolveConfig ,
141137 resolveConfigFile ,
142138} ;
139+ export { default as getFileInfo } from "./common/get-file-info.js" ;
143140export * as doc from "./document/public.js" ;
144141export { default as version } from "./main/version.evaluate.js" ;
145142export * as util from "./utils/public.js" ;
You can’t perform that action at this time.
0 commit comments