susee 1.5.7 → 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
@@ -14,11 +14,12 @@
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
- > [!WARNING]
18
- > Susee relies on TypeScript's programmatic API. Because `TypeScript 7.0` does not ship that API yet, Susee currently works with `TypeScript 6.0`.
19
- > As part of the TypeScript 6.0/7.0 transition, TypeScript published a compatibility package, `@typescript/typescript6`. This package provides a `tsc6` executable, allowing you to install `TypeScript 7.0` side by side with its own `tsc` binary and avoid naming conflicts. It also re-exports the TypeScript 6.0 API, so you can use `tsc` for TypeScript 7 while other tooling continues to rely on 6.0.
20
- > See the details in this [blog post](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/).
21
- > The `susee` package and its ecosystem are currently adapting to the new compatibility package, `@typescript/typescript6`, so some Susee APIs may be temporarily unavailable.
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.
22
23
 
23
24
  ---
24
25
 
@@ -28,7 +29,7 @@ A **TypeScript-first** bundler designed specifically for **library packages** th
28
29
 
29
30
  ✅ **Dual Output** - Generate both ESM and CommonJS formats automatically
30
31
 
31
- ✅ **Automatic Renaming** - Handles duplicate declarations intelligently
32
+ ✅ **Duplicate Declaration Detection** - Fails fast when bundled files contain conflicting top-level declarations
32
33
 
33
34
  ✅ **Fast Builds** - Optimized for library packages with minimal overhead
34
35
 
@@ -38,6 +39,8 @@ A **TypeScript-first** bundler designed specifically for **library packages** th
38
39
 
39
40
  ✅ **CLI & Programmatic API** - Use as a CLI tool or integrate directly
40
41
 
42
+ ✅ **Build Profiling** - Print bundler and compiler phase timings with `--profile`
43
+
41
44
  ---
42
45
 
43
46
  ## Installation and Quick Start
@@ -103,7 +106,6 @@ await build({
103
106
  entry: "src/index.ts",
104
107
  exportPath: ".",
105
108
  format: ["esm", "commonjs"],
106
- renameDuplicates: true,
107
109
  },
108
110
  ],
109
111
  outDir: "dist",
@@ -142,18 +144,18 @@ Do not open public issues for security reports.
142
144
 
143
145
  ## API Quick Reference
144
146
 
145
- | Surface | Command / API | Purpose | Defaults |
146
- | ------------ | -------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
147
- | Programmatic | `build(options?)` | Build from provided options or discovered config file | Exits with code 1 when options and config are both missing |
148
- | CLI | `susee` | Build using `susee.config.ts/js/mjs` in project root | Uses resolved config |
149
- | CLI | `susee init` | Create config template in project root | Prompts for TypeScript project |
150
- | 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` |
151
- | Config | `entryPoints[].format` | Output module format(s) | `["esm"]` |
152
- | Config | `entryPoints[].renameDuplicates` | Rename duplicate declarations | `true` |
153
- | Config | `entryPoints[].tsconfigFilePath` | Custom tsconfig path | `undefined` |
154
- | Config | `entryPoints[].plugins` | Post-process plugin list | `[]` |
155
- | Config | `outDir` | Root output directory | `"dist"` |
156
- | 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`.
157
159
 
158
160
  ---
159
161
 
@@ -177,10 +179,9 @@ Usage:
177
179
  --outdir <path> Output directory (default: dist)
178
180
  --format <cjs|commonjs|esm> Output format (default: esm)
179
181
  --tsconfig <path> Custom tsconfig path
180
- --rename[=true|false] Rename duplicate declarations (default: true)
181
182
  --allow-update[=true|false] Allow package.json updates (default: false)
182
- --minify[=true|false] Minify output (default: false)
183
- --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)
184
185
  ```
185
186
 
186
187
  ### CLI Examples
@@ -188,9 +189,16 @@ Usage:
188
189
  ```bash
189
190
  npx susee build src/index.ts --outdir dist
190
191
  npx susee build src/index.ts --format commonjs
191
- 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
192
194
  ```
193
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
+
194
202
  ---
195
203
 
196
204
  ## Config File
@@ -211,7 +219,6 @@ interface EntryPoint {
211
219
  exportPath: "." | `./${string}`;
212
220
  format?: OutputFormat; // default: ["esm"]
213
221
  tsconfigFilePath?: string | undefined; // default: undefined
214
- renameDuplicates?: boolean; // default: true
215
222
  plugins?: unknown[]; // default: []
216
223
  warning?: boolean; // default: false
217
224
  }
@@ -266,6 +273,7 @@ Runtime behavior:
266
273
  1. If `options` is provided, Susee builds from that object.
267
274
  2. If `options` is omitted, Susee tries to load config from project root.
268
275
  3. If both are missing, Susee logs an error and exits with code `1`.
276
+ 4. Before compiling, Susee clears the configured `outDir`.
269
277
 
270
278
  ```ts
271
279
  import { build, type SuSeeConfig } from "susee";
@@ -308,19 +316,19 @@ Notes:
308
316
 
309
317
  ## Package.json Update Matrix
310
318
 
311
- 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.
312
320
 
313
- | Context | Condition | Updated Fields | Observed Result |
314
- | -------------------- | --------------------------------------------- | --------------------------- | ----------------------------------------------------------- |
315
- | Main export build | `exportPath: "."` with ESM + CommonJS outputs | `main`, `module` | `main: "dist/index.cjs"`, `module: "dist/index.mjs"` |
316
- | Main export build | `exportPath: "."` with declarations | `types` | Set from generated CommonJS declaration path when available |
317
- | 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"`.
318
326
 
319
327
  Notes:
320
328
 
321
329
  1. Package update requires a `package.json` file in the project root.
322
- 2. With update disabled, package fields are left unchanged.
323
- 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.
324
332
 
325
333
  ## Validation Rules
326
334
 
@@ -329,6 +337,8 @@ From config validation logic:
329
337
  1. At least one `entryPoints` item is required.
330
338
  2. Duplicate `exportPath` values are rejected.
331
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`.
332
342
 
333
343
  Violations print an error and exit with code `1`.
334
344