Skip to content

Commit ab232ed

Browse files
committed
chore(repo): format playbook with Prettier; add PR step to run Prettier
1 parent 60d4d79 commit ab232ed

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

.charlie/instructions/pull-requests.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Use `chore(repo): …` in PR titles for any PR that does not modify package source code (implementation) — docs, CI, release scripts, templates, configs, repo maintenance.
1212
- If a PR is a repository management task (even when it touches a package’s meta files like `package.json`, `.d.ts`, or config), title it with `chore(repo): …`.
1313
- Before marking a PR ready for review, run locally:
14+
- `pnpm prettier` (format everything; ensures CI's Prettier check passes)
1415
- `pnpm lint`
1516
- `pnpm fix:js`
1617

.charlie/playbooks/upgrade-plugin-to-esm-only.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,27 @@ Upgrade a single plugin under `packages/<name>` to publish ESM-only output with
1111
## Steps
1212

1313
1. Identify the target package
14+
1415
- Set a shell variable for reuse: `PKG=packages/<name>`.
1516

1617
2. Package metadata: ESM-only and minimums
18+
1719
- Edit `$PKG/package.json`:
18-
- Set `"type": "module"`.
19-
- Replace legacy `main/module/exports.require` with ESM-only exports:
20-
```json
21-
"exports": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
22-
"types": "./dist/index.d.ts"
23-
```
24-
- Set minimums: `"engines": { "node": ">=20.19.0" }` and `"peerDependencies": { "rollup": ">=4.0.0" }`.
25-
- Keep `rollup` as a devDependency only if tests use it. Otherwise remove it.
26-
- Ensure published files include dist but exclude maps:
27-
```json
28-
"files": ["dist", "!dist/**/*.map", "README.md", "LICENSE"]
29-
```
20+
- Set `"type": "module"`.
21+
- Replace legacy `main/module/exports.require` with ESM-only exports:
22+
```json
23+
"exports": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
24+
"types": "./dist/index.d.ts"
25+
```
26+
- Set minimums: `"engines": { "node": ">=20.19.0" }` and `"peerDependencies": { "rollup": ">=4.0.0" }`.
27+
- Keep `rollup` as a devDependency only if tests use it. Otherwise remove it.
28+
- Ensure published files include dist but exclude maps:
29+
```json
30+
"files": ["dist", "!dist/**/*.map", "README.md", "LICENSE"]
31+
```
3032

3133
3. Build scripts: TypeScript emit to dist
34+
3235
- Prefer a tsc-only build for packages that do not need bundling:
3336
- In `$PKG/package.json`, set scripts:
3437
```json
@@ -41,7 +44,9 @@ Upgrade a single plugin under `packages/<name>` to publish ESM-only output with
4144
- If this package still needs bundling for tests/examples, keep its Rollup config but point inputs at the TypeScript output in `dist/` instead of sources.
4245

4346
4. TypeScript config: emit ESM to `dist/`
47+
4448
- Create or update `$PKG/tsconfig.json` to extend the shared plugin config and emit declarations:
49+
4550
```json
4651
{
4752
"extends": "../../.config/tsconfig.base.json",
@@ -55,15 +60,18 @@ Upgrade a single plugin under `packages/<name>` to publish ESM-only output with
5560
"include": ["src/**/*"]
5661
}
5762
```
63+
5864
- Delete any package-local `rollup` build scripts that produced CJS, and remove any `types/` folder if declarations were hand-authored (they will now be generated).
5965

6066
5. Source: convert to pure ESM and modern Node APIs
67+
6168
- Replace `require`, `module.exports`, and `__dirname` patterns with ESM equivalents.
6269
- Use `node:` specifiers for built-ins (e.g., `import path from 'node:path'`).
6370
- Prefer URL utilities where needed (`fileURLToPath(new URL('.', import.meta.url))`).
6471
- Inline and export public types from `src/index.ts`; avoid separate `types/` unless unavoidable.
6572

6673
6. Tests: drop CJS branches; ESM everywhere
74+
6775
- Remove CJS-specific branches/assertions from tests.
6876
- Keep the existing runner (AVA) if it already handles ESM in Node 20. If the package already uses Vitest in this repo, keep that pattern.
6977
- Ensure Rollup bundles created in tests are `await bundle.close()`-d to avoid leaks.

0 commit comments

Comments
 (0)