CodeVetter · Repo Unpack · System map
prettier/prettier
The runtime has three public surfaces: the Node ESM/CJS API (src/index.js / src/index.cjs), the CLI (bin/prettier.cjs → src/cli), and a browser standalone bundle (src/standalone.js, no config/plugin autoload). Formatting is owned by src/main/core.js; languages live under src/language-*; plugins are assembled by src/main/plugins and the generated builtin registries. Config search/load lives in src/config; the Doc printer in src/document. Development requires Node >=22 and Yarn 4; production tests still exercise dist/ down to Node 14. The website is a Docusaurus + Vite playground published via Netlify; npm packages are built by scripts/build/build.js into dist/.
- package.json names the project prettier 3.10.0-dev, sets type module, engines.node >=22, bin to ./bin/prettier.cjs, main to ./src/index.cjs, and exports '.' (types src/index.d.ts, require src/index.cjs, default src/index.js), './standalone' to src/standalone.js, and './plugins/*' to src/plugins/*.js.
- The published browser/unpkg entry is standalone.js; package.json also defines #universal import maps that swap src/universal/*.browser.js in browsers versus src/universal/*.js on Node.
- bin/prettier.cjs is the real CLI bootstrap: it optionally enables Node compile cache, rejects Node versions below package.json engines.node, strips --experimental-cli / PRETTIER_EXPERIMENTAL_CLI, then dynamically imports either src/experimental-cli/index.js or src/cli/index.js and calls cli.run().
- src/index.js is the Node API: withPlugins loads builtin plus user plugins, then format/check/formatWithCursor/getSupportInfo/inferParser wrap src/main/core.js; it also exports resolveConfig, getFileInfo, doc, util, version, __debug, and __internal (shared with the CLI).
- src/standalone.js reimplements withPlugins without filesystem plugin loading: plugins may be an array or an object (prettierPlugins); there is no resolveConfig/getFileInfo.
- Builtin plugins are generated (do NOT edit) by scripts/generate-builtin-plugins.js into development-plugins.js (language-* modules) and production-plugins.js (src/plugins/*.js bundles), then lazy-loaded via toLazyLoadPlugins. loadBuiltinPlugins() picks production vs development based on NODE_ENV.
- Language implementations live in src/language-{js,json,css,html,graphql,handlebars,markdown,yaml}; each exports languages, parsers, printers, and options. JS printers are a single estree printer; HTML covers angular/html/lwc/mjml/vue parsers with one html printer.
- The build is node ./scripts/build/build.js; scripts/build/packages/index.js emits four packages (prettier, plugin-hermes, plugin-oxc, plugin-yuku) into dist/. prepublishOnly exits 1 so the source tree cannot be published.
- The website is Docusaurus 3 plus a separate Vite/Vue playground (website/vite.config.mjs, website/playground/). Netlify builds with yarn build:website and publishes website/build/. Playground formatting runs in a Worker at /worker.mjs.
- CI is GitHub Actions: Dev runs yarn test (and c8 coverage) on Node 22/26; Prod first yarn build --clean then tests dist/ across Node 14–26, OS matrix, standalone, and Chrome/Firefox ESM+UMD via Puppeteer; Lint runs deps/tsc/eslint/prettier/cspell/changelog/format-test plus actionlint.
- Config resolution is src/config/resolve-config.js: searchPrettierConfig + optional EditorConfig (editorconfig-without-wasm), mergeOverrides via micromatch, and relative plugin paths resolved against the config file directory.
- The experimental CLI is a thin re-export of @prettier/cli/bin (and worker from @prettier/cli/dist/prettier_serial.js), selected by --experimental-cli or PRETTIER_EXPERIMENTAL_CLI rather than a first-party implementation in src/cli.