susee 1.5.6 → 1.6.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/README.md CHANGED
@@ -8,12 +8,19 @@
8
8
 
9
9
  [![NPM][nodei_img]][nodei_url]
10
10
 
11
- [![npm version][npm_v_img]][npm_v_url] [![license][license_img]](LICENSE) [![codecov][codecov_img]][codecov_url][![publish to npm][publish_npm_svg]][publish_npm][![CodeQL Advanced][code_ql_svg]][code_ql] [![OpenSSF Baseline](https://www.bestpractices.dev/projects/13115/baseline)](https://www.bestpractices.dev/projects/13115) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/13115/badge)](https://www.bestpractices.dev/projects/13115)
11
+ [![npm version][npm_v_img]][npm_v_url] [![license][license_img]](LICENSE) [![mmcov][mmcov_svg]][mmcov_url] [![publish to npm][publish_npm_svg]][publish_npm][![CodeQL Advanced][code_ql_svg]][code_ql] [![OpenSSF Baseline](https://www.bestpractices.dev/projects/13115/baseline)](https://www.bestpractices.dev/projects/13115) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/13115/badge)](https://www.bestpractices.dev/projects/13115)
12
12
 
13
13
  ## About
14
14
 
15
15
  A **TypeScript-first** bundler designed specifically for **library packages** that delivers **fast builds**, **type safety**, and **modern JavaScript output** with minimal configuration.
16
16
 
17
+ > [!NOTE]
18
+ >
19
+ > - Susee currently depends on the `TypeScript 6` programmatic API.
20
+ > - Starting with `v1.6.0`, Susee uses `@suseejs/ts6`, a focused fork of `@typescript/typescript6` that exposes the `ts6` runtime Susee needs.
21
+ > - This keeps Susee's TypeScript API dependency isolated, while allowing your project to install and use `TypeScript 7` alongside it without `tsc` naming conflicts.
22
+ > - For the best compatibility with this setup, use `Susee v1.6.0` or newer.
23
+
17
24
  ---
18
25
 
19
26
  ## Key Features
@@ -22,7 +29,7 @@ A **TypeScript-first** bundler designed specifically for **library packages** th
22
29
 
23
30
  ✅ **Dual Output** - Generate both ESM and CommonJS formats automatically
24
31
 
25
- ✅ **Automatic Renaming** - Handles duplicate declarations intelligently
32
+ ✅ **Duplicate Declaration Detection** - Fails fast when bundled files contain conflicting top-level declarations
26
33
 
27
34
  ✅ **Fast Builds** - Optimized for library packages with minimal overhead
28
35
 
@@ -32,6 +39,8 @@ A **TypeScript-first** bundler designed specifically for **library packages** th
32
39
 
33
40
  ✅ **CLI & Programmatic API** - Use as a CLI tool or integrate directly
34
41
 
42
+ ✅ **Build Profiling** - Print bundler and compiler phase timings with `--profile`
43
+
35
44
  ---
36
45
 
37
46
  ## Installation and Quick Start
@@ -97,7 +106,6 @@ await build({
97
106
  entry: "src/index.ts",
98
107
  exportPath: ".",
99
108
  format: ["esm", "commonjs"],
100
- renameDuplicates: true,
101
109
  },
102
110
  ],
103
111
  outDir: "dist",
@@ -136,18 +144,18 @@ Do not open public issues for security reports.
136
144
 
137
145
  ## API Quick Reference
138
146
 
139
- | Surface | Command / API | Purpose | Defaults |
140
- | ------------ | -------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
141
- | Programmatic | `build(options?)` | Build from provided options or discovered config file | Exits with code 1 when options and config are both missing |
142
- | CLI | `susee` | Build using `susee.config.ts/js/mjs` in project root | Uses resolved config |
143
- | CLI | `susee init` | Create config template in project root | Prompts for TypeScript project |
144
- | CLI | `susee build <entry> [options]` | Build a single entry directly from CLI args | `--outdir dist`, `--format esm`, `--rename true`, `--allow-update false`, `--minify false`, `--warning false` |
145
- | Config | `entryPoints[].format` | Output module format(s) | `["esm"]` |
146
- | Config | `entryPoints[].renameDuplicates` | Rename duplicate declarations | `true` |
147
- | Config | `entryPoints[].tsconfigFilePath` | Custom tsconfig path | `undefined` |
148
- | Config | `entryPoints[].plugins` | Post-process plugin list | `[]` |
149
- | Config | `outDir` | Root output directory | `"dist"` |
150
- | Config | `allowUpdatePackageJson` | Update package fields based on output | `false` |
147
+ 1. `build(options?)`: Build from the provided options or from a discovered `susee.config.ts/js/mjs` file. If neither exists, Susee exits with code `1`.
148
+ 2. `suseeBundler(entry)`: Bundle a single entry and return the merged source string. This export does not expose plugin or warning options.
149
+ 3. `suseeCliBuild()`: Run the CLI dispatcher programmatically using `process.argv`.
150
+ 4. `susee`: Build from the root config file and clear the configured `outDir` before compiling.
151
+ 5. `susee init`: Generate a config template in the project root after prompting whether the project uses TypeScript.
152
+ 6. `susee build <entry> [options]`: Build a single entry directly from CLI arguments. Defaults: `--outdir dist`, `--format esm`, `--warning false`, `--allow-update false`, `--profile false`.
153
+ 7. `entryPoints[].format`: Output module format list. Default: `["esm"]`.
154
+ 8. `entryPoints[].tsconfigFilePath`: Custom tsconfig path. Default: `undefined`.
155
+ 9. `entryPoints[].plugins`: Dependency, pre-process, and post-process plugins. Default: `[]`.
156
+ 10. `entryPoints[].warning`: Treat dependency graph warnings as fatal. Default: `false`.
157
+ 11. `outDir`: Root output directory. Default: `"dist"`.
158
+ 12. `allowUpdatePackageJson`: Update package fields based on generated output. Default: `false`.
151
159
 
152
160
  ---
153
161
 
@@ -171,10 +179,9 @@ Usage:
171
179
  --outdir <path> Output directory (default: dist)
172
180
  --format <cjs|commonjs|esm> Output format (default: esm)
173
181
  --tsconfig <path> Custom tsconfig path
174
- --rename[=true|false] Rename duplicate declarations (default: true)
175
182
  --allow-update[=true|false] Allow package.json updates (default: false)
176
- --minify[=true|false] Minify output (default: false)
177
- --warning[=true|false] Enable warnings (default: false)
183
+ --warning[=true|false] Treat dependency graph warnings as fatal (default: false)
184
+ --profile[=true|false] Print bundler/compiler phase timings (default: false)
178
185
  ```
179
186
 
180
187
  ### CLI Examples
@@ -182,9 +189,16 @@ Usage:
182
189
  ```bash
183
190
  npx susee build src/index.ts --outdir dist
184
191
  npx susee build src/index.ts --format commonjs
185
- npx susee build --entry src/index.ts --format esm --minify
192
+ npx susee build --entry src/index.ts --format esm
193
+ npx susee build src/index.ts --profile
186
194
  ```
187
195
 
196
+ Notes:
197
+
198
+ 1. `susee build` accepts either a positional `<entry>` or `--entry <path>`.
199
+ 2. `--profile` is also accepted on plain `susee` config-driven builds.
200
+ 3. The CLI clears the target `outDir` before writing new output.
201
+
188
202
  ---
189
203
 
190
204
  ## Config File
@@ -205,7 +219,6 @@ interface EntryPoint {
205
219
  exportPath: "." | `./${string}`;
206
220
  format?: OutputFormat; // default: ["esm"]
207
221
  tsconfigFilePath?: string | undefined; // default: undefined
208
- renameDuplicates?: boolean; // default: true
209
222
  plugins?: unknown[]; // default: []
210
223
  warning?: boolean; // default: false
211
224
  }
@@ -260,6 +273,7 @@ Runtime behavior:
260
273
  1. If `options` is provided, Susee builds from that object.
261
274
  2. If `options` is omitted, Susee tries to load config from project root.
262
275
  3. If both are missing, Susee logs an error and exits with code `1`.
276
+ 4. Before compiling, Susee clears the configured `outDir`.
263
277
 
264
278
  ```ts
265
279
  import { build, type SuSeeConfig } from "susee";
@@ -302,19 +316,19 @@ Notes:
302
316
 
303
317
  ## Package.json Update Matrix
304
318
 
305
- When `allowUpdatePackageJson` (config) or `--allow-update` (CLI build) is enabled, Susee can update package fields.
319
+ When `allowUpdatePackageJson` (config) or `--allow-update` (CLI build) is enabled, Susee rewrites package metadata from the emitted file paths.
306
320
 
307
- | Context | Condition | Updated Fields | Observed Result |
308
- | -------------------- | --------------------------------------------- | --------------------------- | ----------------------------------------------------------- |
309
- | Main export build | `exportPath: "."` with ESM + CommonJS outputs | `main`, `module` | `main: "dist/index.cjs"`, `module: "dist/index.mjs"` |
310
- | Main export build | `exportPath: "."` with declarations | `types` | Set from generated CommonJS declaration path when available |
311
- | Subpath export build | `exportPath: "./foo"` | `exports` (subpath mapping) | Currently remains `{}` in tested behavior |
321
+ 1. Main export build with `exportPath: "."` and CommonJS output: updates `main` to the generated `.cjs` file.
322
+ 2. Main export build with `exportPath: "."` and ESM output: updates `module` to the generated `.mjs` file.
323
+ 3. Main export build with `exportPath: "."` and declarations: updates `types` to the generated declaration file.
324
+ 4. Any export build with generated import or require declarations: creates or merges `exports` entries for that export path.
325
+ 5. Any package update: forces `type` to `"module"`.
312
326
 
313
327
  Notes:
314
328
 
315
329
  1. Package update requires a `package.json` file in the project root.
316
- 2. With update disabled, package fields are left unchanged.
317
- 3. Existing tests in this repo currently assert `exports` remains `{}` for the tested update flows.
330
+ 2. For subpath exports, Susee merges the generated entry into existing `exports` when that field is an object.
331
+ 3. For the main export path `.`, Susee replaces `exports` with the generated root mapping.
318
332
 
319
333
  ## Validation Rules
320
334
 
@@ -323,6 +337,8 @@ From config validation logic:
323
337
  1. At least one `entryPoints` item is required.
324
338
  2. Duplicate `exportPath` values are rejected.
325
339
  3. Each `entry` path must exist.
340
+ 4. Duplicate top-level declarations across bundled files fail the build during dependency analysis.
341
+ 5. CommonJS modules in the dependency tree fail the build unless you handle them with `@suseejs/commonjs-plugin`.
326
342
 
327
343
  Violations print an error and exit with code `1`.
328
344
 
@@ -343,8 +359,6 @@ Violations print an error and exit with code `1`.
343
359
 
344
360
  <!-- -->
345
361
 
346
- [codecov_img]: https://codecov.io/gh/phothinmg/susee/graph/badge.svg?token=6240Y3L0V1
347
- [codecov_url]: https://codecov.io/gh/phothinmg/susee
348
362
  [nodei_img]: https://nodei.co/npm/susee.svg?color=red
349
363
  [nodei_url]: https://nodei.co/npm/susee/
350
364
  [npm_v_img]: https://img.shields.io/npm/v/susee
@@ -354,3 +368,5 @@ Violations print an error and exit with code `1`.
354
368
  [publish_npm_svg]: https://github.com/phothinmg/susee/actions/workflows/npm-publish.yml/badge.svg?event=release
355
369
  [code_ql]: https://github.com/phothinmg/susee/actions/workflows/codeql.yml
356
370
  [code_ql_svg]: https://github.com/phothinmg/susee/actions/workflows/codeql.yml/badge.svg
371
+ [mmcov_svg]: https://img.shields.io/badge/mmcov-85.01%25-green?style=flat&labelColor=%232c3e50
372
+ [mmcov_url]: https://suseejs.org/coverage
package/bin/susee CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import("../dist/bin/index.mjs");
3
+ import {suseeCliBuild} from "../dist/index.mjs";
4
+ suseeCliBuild()