Skip to content

Commit

Permalink
Added some temporarily-disabled code for lazy-loading buil-tin plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiospampinato committed Apr 19, 2024
1 parent 4f6afb0 commit 6478420
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/prettier_serial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import prettierYaml from "prettier/plugins/yaml";
import { getPlugins, resolve } from "./utils.js";
import type { ContextOptions, LazyFormatOptions, PluginsOptions } from "./types.js";

//TODO: Avoid loading plugins until they are actually needed
//TODO: Avoid loading plugins until they are actually needed (https://github.com/prettier/prettier/blob/main/src/main/plugins/load-builtin-plugins.js)

async function check(filePath: string, fileContent: string, formatOptions: LazyFormatOptions, contextOptions: ContextOptions, pluginsOptions: PluginsOptions ): Promise<boolean> {
const fileContentFormatted = await format(filePath, fileContent, formatOptions, contextOptions, pluginsOptions);
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ function getPlugins(names: string[]): PromiseMaybe<PrettierPlugin[]> {
return Promise.all(names.map(getPlugin));
}

// const getPluginsBuiltin = once(async (): Promise<PrettierPlugin[]> => {
// return (await import("prettier/src/main/plugins/load-builtin-plugins.js")).default;
// });

function getPluginsPaths(names: string[]): string[] {
const pluginsPaths = names.map(getPluginPath);
return pluginsPaths;
Expand Down Expand Up @@ -642,6 +646,7 @@ export {
getPluginPath,
getPluginVersion,
getPlugins,
// getPluginsBuiltin,
getPluginsPaths,
getPluginsVersions,
getProjectPath,
Expand Down

0 comments on commit 6478420

Please sign in to comment.