jspackr 0.3.0 → 0.4.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.
- package/LICENSE +2 -2
- package/README.md +76 -447
- package/bin/jspackr-darwin-arm64 +0 -0
- package/bin/jspackr-darwin-x64 +0 -0
- package/bin/{jspackr → jspackr-linux-arm64} +0 -0
- package/bin/jspackr-linux-x64 +0 -0
- package/bin/jspackr-win32-arm64.exe +0 -0
- package/bin/jspackr-win32-x64.exe +0 -0
- package/index.js +67 -0
- package/package.json +40 -36
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 Kaloka Radia Nanda
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,491 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="./logo.svg" width="240" alt="packrat (jspackr logo)" />
|
|
3
|
-
</div>
|
|
1
|
+
# jspackr
|
|
4
2
|
|
|
5
|
-
<
|
|
3
|
+
<img src='./logo.svg' width=150>
|
|
6
4
|
|
|
7
|
-
|
|
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>
|
|
5
|
+
`jspackr` is a small JavaScript bundler CLI implemented in Go and powered by [esbuild](https://esbuild.github.io/). It bundles one entry file and can minify output, generate source maps, print a size report, and rebuild when files under the entry file's directory change.
|
|
11
6
|
|
|
12
|
-
|
|
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>
|
|
7
|
+
## Features
|
|
19
8
|
|
|
20
|
-
|
|
9
|
+
- Bundle JavaScript with esbuild into ESM, IIFE, or CommonJS output.
|
|
10
|
+
- ESM output supports top-level `await`.
|
|
11
|
+
- Optional whitespace, syntax, and identifier minification.
|
|
12
|
+
- Linked or inline source maps.
|
|
13
|
+
- Build size report and watch mode.
|
|
14
|
+
- JSON configuration plus command line overrides.
|
|
21
15
|
|
|
22
|
-
##
|
|
16
|
+
## Requirements and supported platforms
|
|
23
17
|
|
|
24
|
-
|
|
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
|
|
18
|
+
The Go source uses Go 1.22 or newer. Go can compile the CLI for Windows, Linux, and macOS on amd64 and arm64. The npm package currently contains a Linux x64 binary only; its launcher reports a clear error on other platforms. For other targets, install from source with Go.
|
|
33
19
|
|
|
34
|
-
|
|
20
|
+
## Installation
|
|
35
21
|
|
|
36
|
-
|
|
22
|
+
Install with Go:
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- **Operating System**: Windows, macOS, or Linux
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## 🚀 Installation
|
|
45
|
-
|
|
46
|
-
### Option 1: Install via npm (Recommended)
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
# Install globally
|
|
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
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
|
-
## 🎯 Quick Start
|
|
98
|
-
|
|
99
|
-
### Basic Bundling
|
|
100
|
-
|
|
101
|
-
Bundle a JavaScript file with default settings:
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
jspackr src/index.js
|
|
105
|
-
```
|
|
106
|
-
|
|
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
|
|
24
|
+
```sh
|
|
25
|
+
go install github.com/kalokaradia/jspackr/src/main@latest
|
|
217
26
|
```
|
|
218
27
|
|
|
219
|
-
|
|
28
|
+
The resulting `jspackr` executable must be on your `PATH`. The npm package is also available for Linux x64:
|
|
220
29
|
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
jspackr -i src/index.js -o dist/app.min.js -m -r -s inline
|
|
30
|
+
```sh
|
|
31
|
+
npm install -g jspackr
|
|
224
32
|
```
|
|
225
33
|
|
|
226
|
-
|
|
34
|
+
## Quick start
|
|
227
35
|
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
jspackr -i src/index.js -o dist/app.js
|
|
36
|
+
```sh
|
|
37
|
+
jspackr --input src/index.js --out dist/bundle.js
|
|
38
|
+
jspackr -i src/index.js -o dist/app.js --minify --report
|
|
39
|
+
jspackr -i src/index.js -o dist/app.js --watch
|
|
40
|
+
jspackr -i src/index.js -o dist/app.mjs --format esm
|
|
231
41
|
```
|
|
232
42
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# Force overwrite, skip all confirmations
|
|
237
|
-
jspackr -i src/index.js -o dist/app.js -f
|
|
43
|
+
The output directory is created when needed. Existing output files prompt before overwrite; use `--force`/`--yes` to skip that prompt. `--no-confirm` skips all confirmation prompts.
|
|
44
|
+
If no `--config`/`-c` path is provided, jspackr loads `jspackr.config.json` from the current directory when that file exists.
|
|
238
45
|
|
|
239
|
-
|
|
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
|
-
```
|
|
46
|
+
## CLI options
|
|
245
47
|
|
|
246
|
-
|
|
48
|
+
| Option | Meaning |
|
|
49
|
+
| -------------------- | ------------------------------------------------------- |
|
|
50
|
+
| `-i`, `--input` | Entry JavaScript file (required) |
|
|
51
|
+
| `-o`, `--out` | Output file; defaults to `dist/bundle.js` |
|
|
52
|
+
| `-c`, `--config` | Read a JSON configuration file |
|
|
53
|
+
| `-m`, `--minify` | Enable esbuild minification |
|
|
54
|
+
| `-s`, `--source` | Source map mode: `none`, `l` (linked), or `in` (inline) |
|
|
55
|
+
| `--format` | Output format: `esm`, `iife`, or `cjs` (default: `iife`) |
|
|
56
|
+
| `-r`, `--report` | Print bundle size information |
|
|
57
|
+
| `-w`, `--watch` | Rebuild after changes under the entry file's directory |
|
|
58
|
+
| `--log-level` | `debug`, `info`, `warn`, or `error` |
|
|
59
|
+
| `-f`, `--force` | Skip output overwrite confirmation |
|
|
60
|
+
| `-y`, `--yes` | Automatically confirm overwrite prompts |
|
|
61
|
+
| `-n`, `--no-confirm` | Skip all confirmation prompts |
|
|
62
|
+
| `-h`, `--help` | Show help |
|
|
63
|
+
| `-v`, `--version` | Show CLI version |
|
|
247
64
|
|
|
248
|
-
|
|
65
|
+
Example `jspackr.config.json`:
|
|
249
66
|
|
|
250
67
|
```json
|
|
251
68
|
{
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
69
|
+
"input": "./src/index.js",
|
|
70
|
+
"output": "./dist/bundle.js",
|
|
71
|
+
"minify": true,
|
|
72
|
+
"report": true,
|
|
73
|
+
"sourcemap": "l",
|
|
74
|
+
"format": "esm",
|
|
75
|
+
"watch": false,
|
|
76
|
+
"logLevel": "info"
|
|
256
77
|
}
|
|
257
78
|
```
|
|
258
79
|
|
|
259
|
-
|
|
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
|
|
80
|
+
CLI values override config values when supplied. Boolean CLI flags turn a config option on; they do not turn a config option off.
|
|
394
81
|
|
|
395
|
-
|
|
396
|
-
# Check version
|
|
397
|
-
node --version
|
|
82
|
+
Use `--format esm` to preserve ES module output and bundle entry points that use top-level `await`. The default `iife` keeps the classic self-executing bundle behavior. `cjs` emits CommonJS. When running an ESM output file with Node.js, use an `.mjs` extension or configure the containing package with `"type": "module"`.
|
|
398
83
|
|
|
399
|
-
|
|
400
|
-
nvm install 18
|
|
401
|
-
nvm use 18
|
|
402
|
-
|
|
403
|
-
# Or download from nodejs.org
|
|
404
|
-
```
|
|
84
|
+
Configuration supports the same build and confirmation options: `input`, `output`, `minify`, `report`, `sourcemap`, `format`, `watch`, `logLevel`, `force`, `yes`, and `noConfirm`. Source map values are `none`, `l` (linked), and `in` (inline); log levels are `debug`, `info`, `warn`, and `error`.
|
|
405
85
|
|
|
406
|
-
|
|
86
|
+
## Development
|
|
407
87
|
|
|
408
|
-
|
|
409
|
-
# Clear cache and rebuild
|
|
410
|
-
go clean -cache
|
|
411
|
-
go build -o bin/jspackr src/main/main.go
|
|
88
|
+
The implementation is organized into `src/main` (CLI orchestration), `src/config` (JSON configuration and validation), `src/core/builder` (esbuild integration), `src/core/watcher` (file watching), `src/cli` (terminal output), and `src/utils` (shared helpers).
|
|
412
89
|
|
|
413
|
-
|
|
90
|
+
```sh
|
|
414
91
|
go mod download
|
|
415
|
-
go
|
|
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
|
|
436
|
-
|
|
437
|
-
```bash
|
|
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
|
|
92
|
+
go build ./...
|
|
447
93
|
go test ./...
|
|
448
|
-
|
|
449
|
-
|
|
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
|
|
94
|
+
go vet ./...
|
|
95
|
+
go test -race ./...
|
|
456
96
|
```
|
|
457
97
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
- Follow Go formatting conventions (`gofmt`)
|
|
461
|
-
- Add comments for public functions
|
|
462
|
-
- Write tests for new features
|
|
463
|
-
- Update documentation as needed
|
|
98
|
+
## Build and release
|
|
464
99
|
|
|
465
|
-
|
|
100
|
+
Build locally with `go build -o jspackr ./src/main`. Set the version in release binaries with:
|
|
466
101
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
---
|
|
102
|
+
```sh
|
|
103
|
+
go build -ldflags "-X main.version=0.4.0" -o jspackr ./src/main
|
|
104
|
+
```
|
|
472
105
|
|
|
473
|
-
|
|
106
|
+
For cross compilation, set `GOOS` and `GOARCH`, for example `GOOS=windows GOARCH=amd64`, `GOOS=linux GOARCH=arm64`, or `GOOS=darwin GOARCH=arm64`. Release maintainers should keep the git tag, npm `version`, and injected CLI version aligned. npm binary artifacts are currently maintained for Linux x64 only.
|
|
474
107
|
|
|
475
|
-
|
|
476
|
-
- [fatih/color](https://github.com/fatih/color) for colored terminal output
|
|
477
|
-
- All contributors and users!
|
|
108
|
+
## Troubleshooting
|
|
478
109
|
|
|
479
|
-
|
|
110
|
+
- `input path does not exist`: check the entry file path relative to the current working directory.
|
|
111
|
+
- npm reports an unsupported platform: use `go install` on Windows, macOS, or non-x64 Linux; those prebuilt binaries are not currently shipped in npm.
|
|
112
|
+
- Output overwrite prompt: pass `--force` in scripts that intentionally replace an existing bundle.
|
|
480
113
|
|
|
481
|
-
##
|
|
114
|
+
## Contributing
|
|
482
115
|
|
|
483
|
-
|
|
484
|
-
- **GitHub**: [@kalokaradia](https://github.com/kalokaradia)
|
|
485
|
-
- **Issues**: [Report a bug](https://github.com/kalokaradia/jspackr/issues)
|
|
116
|
+
Please use `gofmt` for Go files, add focused tests for behavior changes, and run the development checks above. Keep the CLI and configuration compatible unless a change is explicitly documented.
|
|
486
117
|
|
|
487
|
-
|
|
118
|
+
## License
|
|
488
119
|
|
|
489
|
-
|
|
490
|
-
Made with ❤️ by <b>Kaloka Radia Nanda</b>
|
|
491
|
-
</p>
|
|
120
|
+
MIT. See [LICENSE](LICENSE).
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { spawnSync } = require("node:child_process");
|
|
6
|
+
const fs = require("node:fs");
|
|
7
|
+
const path = require("node:path");
|
|
8
|
+
|
|
9
|
+
const platformMap = {
|
|
10
|
+
linux: "linux",
|
|
11
|
+
darwin: "darwin",
|
|
12
|
+
win32: "win32",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const archMap = {
|
|
16
|
+
x64: "x64",
|
|
17
|
+
arm64: "arm64",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const platform = platformMap[process.platform];
|
|
21
|
+
const arch = archMap[process.arch];
|
|
22
|
+
|
|
23
|
+
if (!platform || !arch) {
|
|
24
|
+
console.error(
|
|
25
|
+
`jspackr: unsupported platform or architecture: ${process.platform}/${process.arch}`,
|
|
26
|
+
);
|
|
27
|
+
console.error(
|
|
28
|
+
"Supported platforms: Linux, macOS, and Windows on x64 or arm64.",
|
|
29
|
+
);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const extension = platform === "win32" ? ".exe" : "";
|
|
34
|
+
|
|
35
|
+
const binaryName = `jspackr-${platform}-${arch}${extension}`;
|
|
36
|
+
const binary = path.join(__dirname, "bin", binaryName);
|
|
37
|
+
|
|
38
|
+
if (!fs.existsSync(binary)) {
|
|
39
|
+
console.error(`jspackr: bundled binary is missing: ${binary}`);
|
|
40
|
+
console.error("Reinstall the package or install jspackr manually with Go:");
|
|
41
|
+
console.error("go install github.com/kalokaradia/jspackr/src/main@latest");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (platform !== "win32") {
|
|
46
|
+
try {
|
|
47
|
+
fs.chmodSync(binary, 0o755);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(
|
|
50
|
+
`jspackr: cannot make bundled binary executable: ${error.message}`,
|
|
51
|
+
);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const result = spawnSync(binary, process.argv.slice(2), {
|
|
57
|
+
stdio: "inherit",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
if (result.error) {
|
|
61
|
+
console.error(
|
|
62
|
+
`jspackr: could not start bundled binary: ${result.error.message}`,
|
|
63
|
+
);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
process.exit(result.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
"name": "jspackr",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "A fast and modern JavaScript bundler powered by esbuild",
|
|
5
|
+
"bin": {
|
|
6
|
+
"jspackr": "index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/*",
|
|
10
|
+
"index.js",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/kalokaradia/jspackr.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"bundler",
|
|
20
|
+
"esbuild",
|
|
21
|
+
"javascript",
|
|
22
|
+
"cli",
|
|
23
|
+
"build-tool",
|
|
24
|
+
"minifier"
|
|
25
|
+
],
|
|
26
|
+
"categories": [
|
|
27
|
+
"Formatters"
|
|
28
|
+
],
|
|
29
|
+
"author": "Kaloka Radia Nanda",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"homepage": "https://github.com/kalokaradia/jspackr#readme",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/kalokaradia/jspackr/issues"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"preferGlobal": true,
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"jspackr": "file:jspackr-0.4.0.tgz"
|
|
41
|
+
}
|
|
38
42
|
}
|