You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: translate bundler comparison from Polish to English
Translate comprehensive tsdown vs pkgroll comparison to English:
- Main heading and executive summary
- Automatic shebang handling section
- Technology and performance comparison table
- CLI configuration approaches
- Library compatibility matrix
- Bundle size and tree-shaking analysis
- Standalone binaries preparation
- Developer experience and debugging
- Critical edge cases
- Known issues and gotchas
- Use case recommendations
All technical content now in English for wider accessibility
while maintaining the same depth and technical accuracy.
# tsdown vs pkgroll: Który bundler wybrać do CLI w TypeScript?
186
+
# tsdown vs pkgroll: Which bundler to choose for TypeScript CLI?
187
187
188
-
**pkgroll wygrywa dla narzędzi CLI**dzięki automatycznej obsłudze shebang i konfiguracji zero-config, podczas gdy tsdown oferuje szybsze buildy, ale wymaga ręcznych workaroundów dla plików wykonywalnych. Dla złożonego CLI z subkomendami i wieloma kanałami dystrybucji (npm, npx, bin, deno compile), pkgroll zapewnia mniej problemów out-of-the-box, ale tsdown może być lepszy przy intensywnym development workflow dzięki 2x szybszemu buildowi.
188
+
**pkgroll wins for CLI tools**thanks to automatic shebang handling and zero-config setup, while tsdown offers faster builds but requires manual workarounds for executable files. For complex CLIs with subcommands and multiple distribution channels (npm, npx, bin, deno compile), pkgroll provides fewer out-of-the-box issues, but tsdown may be better for intensive development workflows thanks to 2x faster builds.
189
189
190
190
---
191
191
192
-
## Automatyczna obsługa shebang decyduje o wyborze
192
+
## Automatic shebang handling makes the difference
193
193
194
-
Najważniejsza różnica między bundlerami dla CLI to sposób obsługi **hashbang** (`#!/usr/bin/env node`). pkgroll automatycznie dodaje shebang do wszystkich plików zdefiniowanych w `bin` field package.json, co eliminuje całą klasę problemów z wykonywalnością. tsdown, zaprojektowany jako "The Elegant Library Bundler", nie posiada natywnej obsługi shebang i wymaga workaroundu:
194
+
The most important difference between bundlers for CLI is how they handle **hashbang** (`#!/usr/bin/env node`). pkgroll automatically adds shebang to all files defined in the `bin` field of package.json, which eliminates an entire class of executability problems. tsdown, designed as "The Elegant Library Bundler", doesn't have native shebang support and requires a workaround:
pkgroll miał historycznie kilka bugów z shebang (hashbang w złym miejscu przy ESM, brak na Windows, znikający przy obecności `main` key), ale**wszystkie zostały naprawione**do wersji 2.14.2 (lipiec 2025). Teraz system działa niezawodnie - wystarczy zdefiniować`bin`w package.json.
206
+
pkgroll historically had several shebang bugs (hashbang in wrong place with ESM, missing on Windows, disappearing with `main` key present), but**all were fixed**by version 2.14.2 (July 2025). The system now works reliably - just define`bin`in package.json.
|**Build speed**|~2x faster than tsup |Slower (JS-based) |
218
+
|**Tree-shaking**| Rolldown-based | Rollup (best in class) |
219
+
|**Minification**| Oxc (alpha - may have bugs) | esbuild (stable) |
220
220
221
-
tsdown jest**do 8x szybszy**przy generowaniu TypeScript declarations dzięki Rust-owemu backendowi. Przy częstym rebuildowaniu podczas developmentu ta różnica jest odczuwalna. Jednak pkgroll oferuje**najlepszy tree-shaking**w ekosystemie dzięki Rollup, co przekłada się na mniejsze bundle size dla finalnych buildów.
221
+
tsdown is**up to 8x faster**at generating TypeScript declarations thanks to its Rust backend. When frequently rebuilding during development, this difference is noticeable. However, pkgroll offers**best-in-class tree-shaking**in the ecosystem thanks to Rollup, which translates to smaller bundle sizes for final builds.
222
222
223
223
---
224
224
225
-
## Konfiguracja dla złożonego CLI z subkomendami
225
+
## Configuration for complex CLI with subcommands
226
226
227
-
### Podejście pkgroll (zero-config)
227
+
### pkgroll approach (zero-config)
228
228
229
229
```json
230
230
{
@@ -246,9 +246,9 @@ tsdown jest **do 8x szybszy** przy generowaniu TypeScript declarations dzięki R
246
246
}
247
247
```
248
248
249
-
pkgroll automatycznie wykrywa entry pointy z`bin`i`exports`, dodaje shebangi gdzie trzeba, i generuje odpowiednie formaty. **Nie ma pliku konfiguracyjnego** - package.json jest "single source of truth".
249
+
pkgroll automatically detects entry points from`bin`and`exports`, adds shebangs where needed, and generates appropriate formats. **There's no config file** - package.json is the "single source of truth".
tsdown oferuje większą kontrolę i migrację z tsup (`npx tsdown migrate`), ale wymaga więcej konfiguracji dla CLI.
276
+
tsdown offers more control and migration from tsup (`npx tsdown migrate`), but requires more configuration for CLI.
277
277
278
278
---
279
279
280
-
## Kompatybilność z bibliotekami CLI
280
+
## CLI library compatibility
281
281
282
-
Obie bundlery**externalizują dependencies**domyślnie (pakiety z`dependencies` vs `devDependencies`), co oznacza że większość bibliotek CLI nie jest bundlowana. Dla heavy dependencies jak inquirer, commander czy chalk to zalecane podejście:
282
+
Both bundlers**externalize dependencies**by default (packages in`dependencies` vs `devDependencies`), meaning most CLI libraries aren't bundled. For heavy dependencies like inquirer, commander, or chalk, this is the recommended approach:
**ESM-only packages** (chalk 5+, ora, cac) działają w obu bundlerach bez problemów. Pakiety używające**dynamic requires** (inquirer, cosmiconfig) lepiej trzymać jako external dependencies.
**ESM-only packages** (chalk 5+, ora, cac) work in both bundlers without issues. Packages using**dynamic requires** (inquirer, cosmiconfig) are better kept as external dependencies.
297
297
298
298
---
299
299
300
-
## Bundle size i tree-shaking dla CLI
300
+
## Bundle size and tree-shaking for CLI
301
301
302
-
### Efektywność tree-shaking
302
+
### Tree-shaking efficiency
303
303
304
-
pkgroll z Rollup oferuje**najlepszy tree-shaking** - szczególnie istotne dla CLI z wieloma subkomendami, gdzie użytkownik wywołuje tylko jedną na raz. Rollup lepiej eliminuje nieużywany kod między modułami.
304
+
pkgroll with Rollup offers**best-in-class tree-shaking** - especially important for CLIs with many subcommands, where users invoke only one at a time. Rollup better eliminates unused code between modules.
305
305
306
-
tsdown z Rolldown ma tree-shaking **włączony domyślnie** (`--no-treeshake`wyłącza), ale może być mniej agresywny niż Rollup w edge cases.
306
+
tsdown with Rolldown has tree-shaking **enabled by default** (`--no-treeshake`disables it), but may be less aggressive than Rollup in edge cases.
307
307
308
-
### Lazy loading subkomend
308
+
### Lazy loading subcommands
309
309
310
-
Żaden bundler nie ma wbudowanego lazy loading, ale można go zaimplementować manualnie:
310
+
Neither bundler has built-in lazy loading, but you can implement it manually:
311
311
312
312
```typescript
313
313
// src/cli.ts
@@ -325,15 +325,15 @@ if (handler) {
325
325
}
326
326
```
327
327
328
-
Oba bundlery obsługują dynamic imports, więc ten pattern działa.
328
+
Both bundlers support dynamic imports, so this pattern works.
329
329
330
330
---
331
331
332
-
## Przygotowanie do standalone binaries
332
+
## Preparing for standalone binaries
333
333
334
334
### deno compile compatibility
335
335
336
-
Dla deno compile potrzebujesz bundla jako pojedynczy plik ESM:
336
+
For deno compile you need a bundle as a single ESM file:
Oba bundlery mogą agresywnie tree-shake kod po`process.exit()`. Bezpieczny pattern:
440
+
Both bundlers may aggressively tree-shake code after`process.exit()`. Safe pattern:
441
441
442
442
```typescript
443
443
asyncfunctionmain() {
@@ -454,55 +454,55 @@ main()
454
454
455
455
### Native modules
456
456
457
-
pkgroll **automatycznie obsługuje** pliki `.node`- kopiuje do`dist/natives/`i przepisuje importy. tsdown nie ma udokumentowanej obsługi - lepiej externalizować pakiety z native modules.
457
+
pkgroll **automatically handles** `.node`files - copies to`dist/natives/`and rewrites imports. tsdown has no documented support - better to externalize packages with native modules.
458
458
459
459
---
460
460
461
-
## Znane problemy i gotchas
461
+
## Known issues and gotchas
462
462
463
463
### pkgroll (19 open issues)
464
-
- CJS default exports nie są unwrapowane pod`default` property (#101)
- You're intensively developing CLI and need fast rebuilds
491
+
- You're migrating from tsup (built-in migration tool)
492
+
- You need programmatic API
493
+
- You plan to use framework plugins (Vue, Solid, Svelte)
494
+
- You want explicit config file with defineConfig()
495
495
496
-
### Moja rekomendacja
496
+
### My recommendation
497
497
498
-
**Zacznij od pkgroll** - automatyczna obsługa shebang i zero-config znacząco redukują friction przy budowaniu CLI. Jeśli buildy staną się bottleneckiem (duży projekt, częste rebuildy), rozważ migrację do tsdown z przygotowanymi workaroundami dla shebang.
498
+
**Start with pkgroll** - automatic shebang handling and zero-config significantly reduce friction when building CLIs. If builds become a bottleneck (large project, frequent rebuilds), consider migrating to tsdown with prepared shebang workarounds.
499
499
500
-
Struktura projektu powinna wyglądać tak:
500
+
Project structure should look like this:
501
501
502
502
```
503
503
my-cli/
504
504
├── src/
505
-
│ ├── cli.ts # Main entry (hashbang dodawany automatycznie)
505
+
│ ├── cli.ts # Main entry (hashbang added automatically)
Ta konfiguracja działa out-of-the-box dla npm, npx i globalnej instalacji, a output można łatwo przekazać do deno compile lub pkg dla standalone binaries.
530
+
This configuration works out-of-the-box for npm, npx, and global installation, and the output can be easily passed to deno compile or pkg for standalone binaries.
0 commit comments