Skip to content

🚀 Feature: Use in-memory API for Prettier if available #114

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Feature Request Checklist

Overview

Over in changesets/changesets#1639, @bluwy noted:

One caveat I notice is that since it calls a child process, it can take around 300-800ms after confirming the changeset in the CLI.

That is an unfortunate performance penalty to add - especially for a project that was previously importing from Prettier in-memory / in the same process. The way Prettier's runner is defined right now is just as a process exec string:

runner: "npx prettier --write",

Proposal: how we change Prettier's runner to:

  1. Try to await import('prettier') and format that way
  2. If that fails to resolve (e.g. from a global Prettier installation) then fall back to the string exec

cc @Andarist @bluwy does that seem right to you as a strategy that would help?

Additional Info

Filing this issue for just Prettier at the moment since I think it's probably the easiest to do (doesn't need a Deno runtime, etc.). But if this works I don't see any reason not to try to add support for the other formatters.

https://github.com/JoshuaKGoldberg/formatly/issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsPlease, send a pull request to resolve this! 🙏type: featureNew enhancement or request 🚀

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions