jspackr 0.1.1 → 0.3.0

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.
Files changed (3) hide show
  1. package/README.md +462 -33
  2. package/bin/jspackr +0 -0
  3. package/package.json +19 -5
package/README.md CHANGED
@@ -1,62 +1,491 @@
1
- # jspackr
1
+ <div align="center">
2
+ <img src="./logo.svg" width="240" alt="packrat (jspackr logo)" />
3
+ </div>
2
4
 
3
- A minimal JavaScript bundler powered by esbuild.
4
- Fast, simple, and focused on doing one thing well.
5
+ <h1 align="center">jspackr 0.3.0</h1>
5
6
 
6
- ## Why jspackr?
7
+ <p align="center">
8
+ A simple, fast, and modern JavaScript bundler powered by esbuild.<br />
9
+ Lightweight, easy to use, and perfect for small to medium projects.
10
+ </p>
7
11
 
8
- jspackr exists because sometimes you just want to:
12
+ <p align="center">
13
+ <a href="#-installation">Installation</a> •
14
+ <a href="#-quick-start">Quick Start</a> •
15
+ <a href="#-usage">Usage</a> •
16
+ <a href="#-configuration-file">Configuration</a> •
17
+ <a href="#-examples">Examples</a>
18
+ </p>
9
19
 
10
- - bundle a JavaScript entry file
11
- - optionally minify it
12
- - see which files actually make your bundle big
20
+ ---
21
+
22
+ ## ✨ Features
23
+
24
+ - ⚡ **Lightning Fast** - Bundles JavaScript in milliseconds using esbuild
25
+ - 🔧 **Zero Config** - Works out of the box, no configuration needed
26
+ - ✂️ **Minification** - Optional built-in minification
27
+ - 📊 **Build Reports** - See exactly what's contributing to your bundle size
28
+ - 👀 **Watch Mode** - Auto-rebuild on file changes during development
29
+ - 🗺️ **Source Maps** - Debug with linked or inline source maps
30
+ - 🎨 **Beautiful Output** - Colored CLI with helpful messages
31
+ - 🤖 **Non-Interactive Mode** - Perfect for CI/CD pipelines
32
+ - 🔄 **Config Files** - Support for JSON configuration files
13
33
 
14
- No config files.
15
- No plugins.
16
- No framework cosplay.
34
+ ---
17
35
 
18
- Run it, get your bundle, move on.
36
+ ## 📋 Prerequisites
19
37
 
20
- ## Features
38
+ - **Node.js**: v18 or higher (required for npm installation and Go binary)
39
+ - **Go**: v1.21 or higher (only if building from source)
40
+ - **Operating System**: Windows, macOS, or Linux
21
41
 
22
- - ⚡ Extremely fast bundling via esbuild
23
- - ✂️ Optional minification
24
- - 📊 Simple build report to see top contributors
25
- - 🧠 Sensible CLI UX with shorthand flags
42
+ ---
26
43
 
27
- ## Installation
44
+ ## 🚀 Installation
28
45
 
29
- For now, build from source:
46
+ ### Option 1: Install via npm (Recommended)
30
47
 
31
48
  ```bash
49
+ # Install globally
32
50
  npm install -g jspackr
51
+
52
+ # Verify installation
53
+ jspackr --version
54
+ ```
55
+
56
+ ### Option 2: Install via Go
57
+
58
+ ```bash
59
+ # Install latest version
60
+ go install github.com/kalokaradia/jspackr@latest
61
+
62
+ # Verify installation
63
+ jspackr --version
64
+ ```
65
+
66
+ ### Option 3: Build from Source
67
+
68
+ ```bash
69
+ # Clone the repository
70
+ git clone https://github.com/kalokaradia/jspackr.git
71
+ cd jspackr
72
+
73
+ # Build the binary
74
+ go build -o bin/jspackr src/main/main.go
75
+
76
+ # Make it executable (Linux/macOS)
77
+ chmod +x bin/jspackr
78
+
79
+ # Run directly
80
+ ./bin/jspackr --version
81
+ ```
82
+
83
+ ### Option 4: Manual Installation
84
+
85
+ Download the appropriate binary for your platform from the [releases page](https://github.com/kalokaradia/jspackr/releases):
86
+
87
+ ```bash
88
+ # Linux/macOS
89
+ sudo mv jspackr /usr/local/bin/jspackr
90
+
91
+ # Windows
92
+ # Move jspackr.exe to your PATH
33
93
  ```
34
94
 
35
- ## Usage
95
+ ---
96
+
97
+ ## 🎯 Quick Start
98
+
99
+ ### Basic Bundling
36
100
 
37
- -> Basic usage:
101
+ Bundle a JavaScript file with default settings:
38
102
 
39
103
  ```bash
40
104
  jspackr src/index.js
41
105
  ```
42
106
 
43
- -> With options:
107
+ This creates:
108
+
109
+ ```
110
+ dist/bundle.js
111
+ ```
112
+
113
+ ### With Options
114
+
115
+ ```bash
116
+ jspackr -i src/index.js -o dist/app.js -m -r -w
117
+ ```
118
+
119
+ This will:
120
+
121
+ - 📥 Bundle `src/index.js`
122
+ - 📤 Write to `dist/app.js`
123
+ - ✂️ Minify the output
124
+ - 📊 Show build report
125
+ - 👀 Watch for changes
126
+
127
+ ---
128
+
129
+ ## 📖 Usage
130
+
131
+ ### Command Syntax
132
+
133
+ ```bash
134
+ jspackr [options]
135
+ ```
136
+
137
+ ### CLI Options
138
+
139
+ | Short | Long Form | Description | Default |
140
+ | ----- | --------------------- | ------------------------------------------- | ---------------- |
141
+ | `-i` | `--input <file>` | Entry JavaScript file | Required |
142
+ | `-o` | `--out <file>` | Output bundle file | `dist/bundle.js` |
143
+ | `-c` | `--config <file>` | Path to config file | Optional |
144
+ | `-m` | `--minify` | Minify the output | `false` |
145
+ | `-r` | `--report` | Generate build report | `false` |
146
+ | `-s` | `--source <mode>` | Source map mode: `none`, `linked`, `inline` | `none` |
147
+ | `-w` | `--watch` | Enable watch mode | `false` |
148
+ | | `--log-level <level>` | Log level: `debug`, `info`, `warn`, `error` | `info` |
149
+ | `-f` | `--force` | Force overwrite without confirmation | `false` |
150
+ | `-y` | `--yes` | Auto-confirm all prompts | `false` |
151
+ | `-n` | `--no-confirm` | Skip all confirmation prompts | `false` |
152
+ | `-v` | `--version` | Show version (standalone) | - |
153
+ | `-h` | `--help` | Show help message | - |
154
+
155
+ ### Help Command
156
+
157
+ ```bash
158
+ # Show help
159
+ jspackr --help
160
+
161
+ # Show version
162
+ jspackr --version
163
+ ```
164
+
165
+ ---
166
+
167
+ ## ⚙️ Configuration File
168
+
169
+ Create a `jspackr.config.json` file for persistent configuration:
170
+
171
+ ```json
172
+ {
173
+ "input": "./src/index.js",
174
+ "output": "./dist/bundle.js",
175
+ "minify": true,
176
+ "report": true,
177
+ "sourceMap": "linked",
178
+ "watch": false,
179
+ "logLevel": "info"
180
+ }
181
+ ```
182
+
183
+ ### Config File Options
184
+
185
+ | Option | Type | Description |
186
+ | ----------- | ------- | ----------------------------------------------- |
187
+ | `input` | string | Entry JavaScript file path |
188
+ | `output` | string | Output bundle file path |
189
+ | `minify` | boolean | Minify the output bundle |
190
+ | `report` | boolean | Generate build report |
191
+ | `sourceMap` | string | Source map mode: `none`, `linked`, `inline` |
192
+ | `watch` | boolean | Enable watch mode |
193
+ | `logLevel` | string | Log verbosity: `debug`, `info`, `warn`, `error` |
194
+
195
+ ### Using Config File
196
+
197
+ ```bash
198
+ # Use default config (jspackr.config.json)
199
+ jspackr
200
+
201
+ # Specify custom config file
202
+ jspackr -c custom.config.json
203
+ ```
204
+
205
+ ---
206
+
207
+ ## 💡 Examples
208
+
209
+ ### Example 1: Basic Bundle
210
+
211
+ ```bash
212
+ # Bundle a single file
213
+ jspackr -i src/index.js
214
+
215
+ # With custom output
216
+ jspackr -i src/index.js -o dist/app.js
217
+ ```
218
+
219
+ ### Example 2: Production Build
220
+
221
+ ```bash
222
+ # Minified with source map and report
223
+ jspackr -i src/index.js -o dist/app.min.js -m -r -s inline
224
+ ```
225
+
226
+ ### Example 3: Development with Watch Mode
227
+
228
+ ```bash
229
+ # Watch for changes and rebuild automatically
230
+ jspackr -i src/index.js -o dist/app.js -w
231
+ ```
232
+
233
+ ### Example 4: CI/CD / Non-Interactive
234
+
235
+ ```bash
236
+ # Force overwrite, skip all confirmations
237
+ jspackr -i src/index.js -o dist/app.js -f
238
+
239
+ # Or with yes flag
240
+ jspackr -i src/index.js -o dist/app.js -y
241
+
242
+ # Or completely non-interactive
243
+ jspackr -i src/index.js -o dist/app.js -n
244
+ ```
245
+
246
+ ### Example 5: Using Configuration File
247
+
248
+ **Create `jspackr.config.json`:**
249
+
250
+ ```json
251
+ {
252
+ "input": "./src/app.js",
253
+ "output": "./build/app.js",
254
+ "minify": true,
255
+ "report": true
256
+ }
257
+ ```
258
+
259
+ **Run:**
260
+
261
+ ```bash
262
+ jspackr
263
+ ```
264
+
265
+ ### Example 6: Verbose Logging
266
+
267
+ ```bash
268
+ # Debug mode
269
+ jspackr -i src/index.js --log-level debug
270
+
271
+ # Quiet mode
272
+ jspackr -i src/index.js --log-level warn
273
+ ```
274
+
275
+ ### Example 7: Multiple Options Combined
276
+
277
+ ```bash
278
+ # Production-ready bundle with all features
279
+ jspackr \
280
+ --input src/index.js \
281
+ --output dist/app.js \
282
+ --minify \
283
+ --report \
284
+ --source linked \
285
+ --log-level info
286
+ ```
287
+
288
+ ---
289
+
290
+ ## 📊 Build Report
291
+
292
+ When using the `--report` flag, jspackr generates a detailed breakdown:
293
+
294
+ ```
295
+ Bundle Size: 45.2 KB
296
+ ⏱️ Build Time: 123ms
297
+
298
+ 📦 Dependencies:
299
+ src/utils.js 12.3 KB
300
+ src/helpers.js 8.1 KB
301
+ src/index.js 2.4 KB
302
+ ...
303
+ ```
304
+
305
+ ---
306
+
307
+ ## 🗺️ Source Maps
308
+
309
+ | Mode | Flag Value | Description |
310
+ | ------ | ---------- | ------------------------------------- |
311
+ | None | `none` | No source map (default) |
312
+ | Linked | `linked` | Separate .map file linked via comment |
313
+ | Inline | `inline` | Embedded as base64 in the bundle |
314
+
315
+ ```bash
316
+ # Linked source map
317
+ jspackr -i src/index.js -s linked
318
+
319
+ # Inline source map
320
+ jspackr -i src/index.js -s inline
321
+ ```
322
+
323
+ ---
324
+
325
+ ## 📁 Project Structure
326
+
327
+ ```
328
+ jspackr/
329
+ ├── bin/ # Compiled binaries
330
+ ├── src/
331
+ │ ├── cli/ # CLI output and styling
332
+ │ │ ├── logger.go # Logging functionality
333
+ │ │ ├── styles.go # Colored output styles
334
+ │ │ └── ui.go # UI components
335
+ │ ├── config/ # Configuration management
336
+ │ │ ├── config.go # Config structures
337
+ │ │ ├── loader.go # JSON config loading
338
+ │ │ ├── merger.go # Config merging
339
+ │ │ └── validator.go # Config validation
340
+ │ ├── core/
341
+ │ │ ├── builder/ # Bundling logic
342
+ │ │ │ ├── builder.go # Main builder
343
+ │ │ │ ├── report.go # Build reporting
344
+ │ │ │ └── sourcemap.go # Source map handling
345
+ │ │ └── watcher/ # File watching
346
+ │ │ ├── debouncer.go
347
+ │ │ ├── hasher.go
348
+ │ │ └── watcher.go
349
+ │ ├── main/
350
+ │ │ └── main.go # Entry point
351
+ │ └── utils/
352
+ │ ├── confirm.go # Confirmation prompts
353
+ │ ├── file.go # File utilities
354
+ │ └── flags.go # CLI flags parsing
355
+ ├── .gitignore
356
+ ├── .npmignore
357
+ ├── go.mod
358
+ ├── go.sum
359
+ ├── LICENSE
360
+ ├── logo.svg
361
+ ├── package.json
362
+ └── README.md
363
+ ```
364
+
365
+ ---
366
+
367
+ ## 🐛 Troubleshooting
368
+
369
+ ### Command Not Found
370
+
371
+ If `jspackr` is not found after installation:
372
+
373
+ ```bash
374
+ # Add to PATH (npm global)
375
+ npm config get prefix
376
+ # Add the output path to your shell profile
377
+
378
+ # Or for Go installation
379
+ echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.bashrc
380
+ source ~/.bashrc
381
+ ```
382
+
383
+ ### Permission Denied
384
+
385
+ ```bash
386
+ # Linux/macOS
387
+ sudo chown $(whoami) /usr/local/bin/jspackr
388
+
389
+ # Or use npm with sudo (not recommended)
390
+ sudo npm install -g jspackr
391
+ ```
392
+
393
+ ### Node Version Too Old
394
+
395
+ ```bash
396
+ # Check version
397
+ node --version
398
+
399
+ # Update using nvm (Linux/macOS)
400
+ nvm install 18
401
+ nvm use 18
402
+
403
+ # Or download from nodejs.org
404
+ ```
405
+
406
+ ### Build Fails
407
+
408
+ ```bash
409
+ # Clear cache and rebuild
410
+ go clean -cache
411
+ go build -o bin/jspackr src/main/main.go
412
+
413
+ # Check dependencies
414
+ go mod download
415
+ go mod verify
416
+ ```
417
+
418
+ ### Watch Mode Not Working
419
+
420
+ ```bash
421
+ # Ensure you're not using network drives
422
+ # Check file permissions
423
+ ls -la src/
424
+
425
+ # Try with absolute paths
426
+ jspackr -i /absolute/path/to/index.js
427
+ ```
428
+
429
+ ---
430
+
431
+ ## 🤝 Contributing
432
+
433
+ Contributions are welcome! Please feel free to submit a Pull Request.
434
+
435
+ ### Development Setup
44
436
 
45
437
  ```bash
46
- jspackr -i src/index.js -o dist/app.js -m -r
438
+ # Fork the repository
439
+ git clone https://github.com/YOUR-USERNAME/jspackr.git
440
+ cd jspackr
441
+
442
+ # Create a feature branch
443
+ git checkout -b feature/amazing-feature
444
+
445
+ # Make changes
446
+ # Test your changes
447
+ go test ./...
448
+
449
+ # Commit your changes
450
+ git commit -m "Add amazing feature"
451
+
452
+ # Push to GitHub
453
+ git push origin feature/amazing-feature
454
+
455
+ # Open a Pull Request
47
456
  ```
48
457
 
49
- ## CLI Options
458
+ ### Coding Standards
459
+
460
+ - Follow Go formatting conventions (`gofmt`)
461
+ - Add comments for public functions
462
+ - Write tests for new features
463
+ - Update documentation as needed
464
+
465
+ ---
466
+
467
+ ## 📝 License
468
+
469
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
470
+
471
+ ---
472
+
473
+ ## 🙏 Acknowledgments
474
+
475
+ - [esbuild](https://esbuild.github.io/) for the amazing bundling engine
476
+ - [fatih/color](https://github.com/fatih/color) for colored terminal output
477
+ - All contributors and users!
478
+
479
+ ---
480
+
481
+ ## 📧 Contact
50
482
 
51
- | Flag | Long Form | Description |
52
- | ---- | --------------- | ------------------------------------- |
53
- | -i | --input \<file> | Entry file |
54
- | -o | --out \<file> | Output file (default: dist/bundle.js) |
55
- | -m | --minify | Minify output |
56
- | -r | --report | Show build report |
57
- | -h | --help | Show help |
483
+ - **Author**: [Kaloka Radia Nanda](https://kalokaradiananda.my.id)
484
+ - **GitHub**: [@kalokaradia](https://github.com/kalokaradia)
485
+ - **Issues**: [Report a bug](https://github.com/kalokaradia/jspackr/issues)
58
486
 
59
487
  ---
60
488
 
61
- Created with ❤️ by Kaloka Radia Nanda
62
- Licensed under the MIT License.
489
+ <p align="center">
490
+ Made with ❤️ by <b>Kaloka Radia Nanda</b>
491
+ </p>
package/bin/jspackr CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jspackr",
3
- "version": "0.1.1",
4
- "description": "A minimal JavaScript bundler powered by esbuild",
3
+ "version": "0.3.0",
4
+ "description": "A fast and modern JavaScript bundler powered by esbuild",
5
5
  "bin": {
6
6
  "jspackr": "bin/jspackr"
7
7
  },
@@ -12,13 +12,27 @@
12
12
  ],
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/kalokaradia/jspackr"
15
+ "url": "git+https://github.com/kalokaradia/jspackr.git"
16
16
  },
17
17
  "keywords": [
18
18
  "bundler",
19
19
  "esbuild",
20
20
  "javascript",
21
- "cli"
21
+ "cli",
22
+ "build-tool",
23
+ "minifier"
22
24
  ],
23
- "license": "MIT"
25
+ "categories": [
26
+ "Other"
27
+ ],
28
+ "author": "Kaloka Radia Nanda",
29
+ "license": "MIT",
30
+ "homepage": "https://github.com/kalokaradia/jspackr#readme",
31
+ "bugs": {
32
+ "url": "https://github.com/kalokaradia/jspackr/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "preferGlobal": true
24
38
  }