prettier / prettier/prettier

Use Yarn workspaces & Lerna?

Open
#3,623 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status:needs discussion type:infra type:meta
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

There was some discussion of this way back in https://github.com/prettier/prettier/issues/769, but since the plugin API was built and the code was modularized into "internal plugins", it's starting to make sense to switch to more of a monorepo approach.

Proposed packages:

Current Dir New Dir npm Package Name Dependencies
src/common, src/config packages/core @prettier/core
src/cli packages/cli @prettier/cli @prettier/core
src/doc packages/doc @prettier/doc @prettier/core
src/language-* packages/plugin-* @prettier/plugin-* @prettier/core, @prettier/doc
src/main packages/prettier prettier @prettier/* (including plugins)
(original plan)
Current Dir New Dir npm Package Name Dependencies
src/common, src/config packages/core @prettier/core
src/cli packages/cli @prettier/cli @prettier/core
src/doc packages/doc @prettier/doc @prettier/core
src/language-* packages/language-* @prettier/language-* @prettier/core
src/main packages/prettier prettier @prettier/* (including languages)

Each package would produce (via Rollup) one CommonJS bundle shipped to npm.

Advantages:

  • External plugins would only need to depend on @prettier/doc, which would remove the current circular dependency (@prettier/python require('prettier') which require('@prettier/python')).
  • Using dependency (package.json) validation, we're able to enforce that parsers and printers are represented using the public API, which means we could easily extract them into their own repositories, and vice versa.
  • People can use the @prettier/doc package as a standalone module.

Disadvantages:

  • Can no longer do npm install prettier/prettier (https://github.com/npm/npm/issues/2974). Perhaps we could do an automated push to a bundled branch that is pre-bundled so that npm install prettier/prettier#bundled works? Alternatively publish every merge to npm under a next dist-tag?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the proposed mappings from src/common, src/config, src/cli, src/doc, src/language-* and src/main to packages/*, along with the package dependencies. Then inspect the Rollup bundling and package.json validation implications. Done would require an agreed monorepo structure and a migration plan that preserves the listed package and plugin relationships.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.