Use Yarn workspaces & Lerna?
Nobody has claimed this yet.
- 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/pythonrequire('prettier')whichrequire('@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/docpackage 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 abundledbranch that is pre-bundled so thatnpm install prettier/prettier#bundledworks? Alternatively publish every merge to npm under anextdist-tag? - ❓
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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