itty-packager 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md ADDED
@@ -0,0 +1,76 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Commands
6
+
7
+ ### Development Commands
8
+ - `bun bin/itty.js lint` - Lint the codebase using the CLI tool itself
9
+ - `bun bin/itty.js build` - Build the project (not typically needed as this is the build tool itself)
10
+ - `echo 'No tests yet'` - Current test command (no test suite implemented)
11
+
12
+ ### Release Commands
13
+ - `bun bin/itty.js publish --patch --tag --dry-run --src=. --no-license` - Dry run release
14
+ - `bun bin/itty.js publish --patch --tag --push --src=. --no-license` - Patch release
15
+ - `bun bin/itty.js publish --minor --tag --push --src=. --no-license` - Minor release
16
+ - `bun bin/itty.js publish --major --tag --push --src=. --no-license` - Major release
17
+
18
+ ### CLI Usage
19
+ The main CLI entry point is `bin/itty.js` which provides three core commands:
20
+ - `itty build` - TypeScript compilation with Rollup
21
+ - `itty lint` - ESLint with built-in TypeScript configuration
22
+ - `itty publish` - Version bumping and npm publishing
23
+
24
+ ## Architecture
25
+
26
+ ### Core Components
27
+
28
+ **CLI Entry Point** (`bin/itty.js`):
29
+ - Main executable that dynamically imports command modules
30
+ - Handles global flags (--help, --version) and subcommand routing
31
+ - Supports build, lint, and publish subcommands
32
+
33
+ **Build System** (`lib/builder.js`):
34
+ - Core build logic using Rollup and TypeScript
35
+ - Handles ESM/CJS hybrid builds, minification with terser, sourcemaps
36
+ - Automatically updates package.json exports based on build outputs
37
+ - Supports snippet generation for README injection
38
+ - Single file exports map to root export, multiple files get individual exports
39
+
40
+ **Command Modules** (`lib/commands/`):
41
+ - **build.js**: Wraps builder.js with CLI argument parsing
42
+ - **lint.js**: ESLint integration with smart config detection
43
+ - **publish.js**: Version bumping, package extraction, and npm publishing
44
+
45
+ **ESLint Configuration** (`lib/configs/`):
46
+ - **createConfig.mjs**: Factory function for extending base TypeScript ESLint config
47
+ - **eslint.config.mjs**: Base configuration with TypeScript support
48
+ - Automatically used when no local ESLint config is found
49
+
50
+ ### Key Architectural Patterns
51
+
52
+ **Dynamic Command Loading**: Commands are lazily loaded to improve startup time and allow future extensibility.
53
+
54
+ **Smart Configuration**: The lint command detects local ESLint configs and falls back to built-in TypeScript configuration when none exists.
55
+
56
+ **Clean Package Publishing**: The publish command creates a flat package structure by extracting build artifacts to a temporary directory, copying essential files (README, LICENSE, CHANGELOG), and transforming package.json paths before publishing.
57
+
58
+ **Extensible ESLint**: Projects can extend the built-in config using `createConfig()` from `itty-packager/lib/configs/createConfig.mjs`.
59
+
60
+ ### Build Output Handling
61
+
62
+ The build system automatically manages package.json exports:
63
+ - Single TypeScript file → root export (`"."`)
64
+ - Multiple TypeScript files → individual named exports
65
+ - Paths are automatically updated to point to dist/ directory
66
+ - ESM builds by default, CJS optional with `--hybrid` flag
67
+
68
+ ### Publishing Workflow
69
+
70
+ The publish command transforms the package structure:
71
+ 1. Extracts build artifacts from dist/ to temporary directory
72
+ 2. Copies root files (README.md, LICENSE, .npmrc)
73
+ 3. Transforms package.json paths (e.g., `./dist/file.mjs` → `./file.mjs`)
74
+ 4. Publishes the clean, flat structure
75
+ 5. Updates root package.json with new version
76
+ 6. Optionally handles git tagging and pushing
package/README.md CHANGED
@@ -138,7 +138,6 @@ Version bump and publish your package to npm with clean, flat package structure.
138
138
  - `--no-cleanup` - Leave temporary directory after publishing
139
139
  - `--public` - Publish as public package (`--access=public`)
140
140
  - `--no-license` - Do not copy LICENSE file to published package
141
- - `--no-changelog` - Do not copy CHANGELOG.md file to published package
142
141
 
143
142
  **Git Options:**
144
143
  - `--tag` - Create git tag for release
@@ -148,7 +147,7 @@ Version bump and publish your package to npm with clean, flat package structure.
148
147
  **Default Behavior:**
149
148
  - Defaults to patch version bump if no type specified
150
149
  - Extracts build artifacts to temporary directory
151
- - Copies root files: `README.md`, `LICENSE`, `CHANGELOG.md`, `.npmrc` (if they exist)
150
+ - Copies root files: `README.md`, `LICENSE`, `.npmrc` (if they exist)
152
151
  - Transforms package.json paths (e.g., `./dist/file.mjs` → `./file.mjs`)
153
152
  - Creates clean, flat package structure in node_modules
154
153
 
@@ -166,7 +165,7 @@ itty publish --no-license # Publish without copying LICENSE file
166
165
  The publish command creates a clean package structure by:
167
166
 
168
167
  1. **Extracting build artifacts** from your `dist/` directory to package root
169
- 2. **Copying essential files** like README, LICENSE, CHANGELOG
168
+ 2. **Copying essential files** like README, LICENSE
170
169
  3. **Transforming paths** in package.json to point to root-level files
171
170
  4. **Publishing the clean structure** so users get flat imports
172
171
 
@@ -153,10 +153,6 @@ export async function publishCommand(args) {
153
153
  type: 'boolean',
154
154
  description: 'Do not copy LICENSE file to published package'
155
155
  },
156
- 'no-changelog': {
157
- type: 'boolean',
158
- description: 'Do not copy CHANGELOG.md file to published package'
159
- },
160
156
  help: {
161
157
  type: 'boolean',
162
158
  short: 'h',
@@ -185,7 +181,6 @@ Publish Options:
185
181
  --no-cleanup Leave temporary directory after publishing
186
182
  --public Publish as public package (--access=public)
187
183
  --no-license Do not copy LICENSE file to published package
188
- --no-changelog Do not copy CHANGELOG.md file to published package
189
184
 
190
185
  Git Options:
191
186
  --tag Create git tag for release
@@ -229,7 +224,6 @@ This creates a clean, flat package structure in node_modules.
229
224
  const shouldPush = publishArgs.push
230
225
  const noGit = publishArgs['no-git']
231
226
  const noLicense = publishArgs['no-license']
232
- const noChangelog = publishArgs['no-changelog']
233
227
 
234
228
  try {
235
229
  // Read package.json
@@ -280,7 +274,6 @@ This creates a clean, flat package structure in node_modules.
280
274
 
281
275
  // Add optional files based on flags
282
276
  if (!noLicense) rootFiles.push('LICENSE')
283
- if (!noChangelog) rootFiles.push('CHANGELOG.md')
284
277
 
285
278
  for (const file of rootFiles) {
286
279
  const srcFile = path.join(rootPath, file)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-packager",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Universal build tool for itty libraries",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,10 +9,10 @@
9
9
  "scripts": {
10
10
  "lint": "bun bin/itty.js lint",
11
11
  "test": "echo 'No tests yet'",
12
- "release:dry": "bun bin/itty.js publish --patch --tag --dry-run --src=. --no-license --no-changelog",
13
- "release": "bun bin/itty.js publish --patch --tag --push --src=. --no-license --no-changelog",
14
- "release:minor": "bun bin/itty.js publish --minor --tag --push --src=. --no-license --no-changelog",
15
- "release:major": "bun bin/itty.js publish --major --tag --push --src=. --no-license --no-changelog"
12
+ "release:dry": "bun bin/itty.js publish --patch --tag --dry-run --src=. --no-license",
13
+ "release": "bun bin/itty.js publish --patch --tag --push --src=. --no-license",
14
+ "release:minor": "bun bin/itty.js publish --minor --tag --push --src=. --no-license",
15
+ "release:major": "bun bin/itty.js publish --major --tag --push --src=. --no-license"
16
16
  },
17
17
  "keywords": [
18
18
  "build",