susee 0.1.9 → 1.0.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 (2) hide show
  1. package/README.md +143 -46
  2. package/package.json +2 -1
package/README.md CHANGED
@@ -1,59 +1,56 @@
1
+ <!-- markdownlint-disable MD033 -->
2
+ <!-- markdownlint-disable MD041 -->
1
3
  <div align="center">
2
- <img src="https://pub-d94f06e647584b8496cac0d43a6fecfb.r2.dev/susee/susee.webp" width="160" height="160" alt="susee" />
4
+ <img src="https://susee.phothin.dev/logo/susee.webp" width="160" height="160" alt="susee" />
3
5
  <h1>susee</h1>
4
6
  </div>
7
+ <!-- markdownlint-enable MD033 -->
5
8
 
6
- Susee is a small TypeScript bundler that collates a package's local dependency tree, then emits compiled artifacts for ESM and/or CommonJS along with type definitions. It can also update `package.json` exports automatically for main and subpath exports.
9
+ [![npm version](https://img.shields.io/npm/v/susee)](https://www.npmjs.com/package/susee) [![license](https://img.shields.io/npm/l/susee)](LICENSE) [![GitHub Actions Workflow Status](https://github.com/phothinmg/susee/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/phothinmg/susee/actions/workflows/npm-publish.yml)
7
10
 
8
- **Key points**
11
+ ## Overview
9
12
 
10
- - Produces ESM (`.mjs`) and/or CommonJS (`.cjs`) outputs and corresponding type files (`.d.mts` / `.d.cts`).
11
- - Merges local dependency files into a single bundled input for the TypeScript compiler.
12
- - Supports simple plugin hooks at multiple stages: `dependency`, `pre-process`, and `post-process`.
13
- - When enabled, updates `package.json` fields (`type`, `main`, `module`, `types`, `exports`) for the main export and merges subpath exports.
13
+ `susee` is a TypeScript bundler that processes a package's local dependency tree and emits compiled artifacts in multiple module formats. Unlike general-purpose bundlers that target browser environments or bundle `node_modules`, `susee` focuses on library authorship: it collates local TypeScript files, merges them into cohesive bundles, compiles them through the TypeScript compiler, and generates properly formatted outputs for consumption as npm packages.
14
14
 
15
- ## Installation
15
+ ## Key Features
16
16
 
17
- ```bash
18
- npm install susee
19
- ```
17
+ 1. **Dependency Tree Resolution** : automatically resolves and collects local TypeScript dependencies starting from specified entry points.
18
+
19
+ 2. **Dual-Format Module Output** : generates outputs for both ESM and CommonJS module systems from a single TypeScript source.
20
+
21
+ 3. **File Extension Conventions** : dual-emit conventions for unambiguous module format identification.
20
22
 
21
- ## Usage
23
+ | Module Format | JavaScript Extension | Type Definition Extension |
24
+ | ------------- | -------------------- | ------------------------- |
25
+ | ESM | `.mjs` | `.d.mts` |
26
+ | CommonJS | `.cjs` | `.d.cts` |
22
27
 
23
- CLI (global or npx):
28
+ 4. **Automatic package.json Management** : conditionally updates package.json fields based on compilation outputs, this feature is controlled by the `allowUpdatePackageJson` boolean in `SuSeeConfig`.
29
+
30
+ ## Installation
31
+
32
+ Install as a development dependency :
24
33
 
25
34
  ```bash
26
- npx susee
35
+ npm install susee --save-dev
27
36
  ```
28
37
 
29
- programmatic (exports):
38
+ Global install:
30
39
 
31
- ```ts
32
- import { susee } from "susee";
33
-
34
- await susee();
40
+ ```bash
41
+ npm install -g susee
35
42
  ```
36
43
 
37
- ## Configuration
44
+ ## Quick Start
45
+
46
+ The `susee` CLI binary is exposed through the `bin` field and becomes available immediately after installation.
38
47
 
39
- Place a `susee.config.ts` at your project root. The config defines entry points and optional hooks.
48
+ ### Creating a Minimal Configuration
40
49
 
41
- Example `susee.config.ts`:
50
+ Create a file named `susee.config.ts` in your project root:
42
51
 
43
52
  ```ts
44
53
  import type { SuSeeConfig } from "susee";
45
- import suseeBannerText from "@suseejs/plugin-banner-text";
46
- import suseeTerser from "@suseejs/plugin-terser";
47
-
48
- const licenseText = `
49
- /*! *****************************************************************************
50
- Copyright (c) John Doe <johndoe@jhondoe.org>
51
-
52
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
53
- this file except in compliance with the License. You may obtain a copy of the
54
- License at http://www.apache.org/licenses/LICENSE-2.0
55
- ***************************************************************************** */
56
- `.trim();
57
54
 
58
55
  const config: SuSeeConfig = {
59
56
  entryPoints: [
@@ -63,23 +60,104 @@ const config: SuSeeConfig = {
63
60
  format: "both",
64
61
  },
65
62
  ],
66
- plugins: [suseeBannerText(licenseText), suseeTerser()],
67
63
  };
68
64
 
69
65
  export default config;
70
66
  ```
71
67
 
72
- Config summary:
68
+ ### Running Your First Build
69
+
70
+ Execute the bundler using one of these methods:
71
+
72
+ #### CLI Execution
73
73
 
74
- - `entryPoints`: array of entry definitions
75
- - `entry` — path to entry file (required)
76
- - `exportPath` — `.` or a subpath like `./feature`
77
- - `format` — `esm` | `commonjs` | `both` (defaults to `esm`)
78
- - `tsconfigFilePath` — optional custom tsconfig for that entry
79
- - `renameDuplicates` — whether to auto-rename duplicate identifiers
80
- - `outDir` — where compiled files will be written (e.g. `dist`)
81
- - `postProcessHooks` — array of `post-process` plugins (sync or async)
82
- - `allowUpdatePackageJson` — when true, `package.json` is updated with produced entry points
74
+ with `npx` :
75
+
76
+ ```bash
77
+ npx susee
78
+ ```
79
+
80
+ via `package.json` :
81
+
82
+ ```json
83
+ {
84
+ "scripts": {
85
+ "build": "susee"
86
+ }
87
+ }
88
+ ```
89
+
90
+ ```bash
91
+ npm run build
92
+ ```
93
+
94
+ for global :
95
+
96
+ ```bash
97
+ susee
98
+ ```
99
+
100
+ #### Programmatic Execution
101
+
102
+ ```ts
103
+ import { susee } from "susee";
104
+
105
+ await susee();
106
+ ```
107
+
108
+ The `susee()` function is an asynchronous operation that:
109
+
110
+ 1. Loads configuration from `susee.config.ts`
111
+ 2. Resolves the dependency tree
112
+ 3. Bundles local dependencies
113
+ 4. Compiles to target formats
114
+ 5. Optionally updates `package.json`
115
+
116
+ ## Configuration summary
117
+
118
+ ### Top-Level Configuration Fields
119
+
120
+ #### entryPoints
121
+
122
+ An array of [EntryPoint](#entrypoint-structure) objects defining the files to bundle. Each entry point represents a separate bundling operation with its own entry file, export path, and output configuration. The array must contain at least one entry point.
123
+
124
+ #### plugins (optional)
125
+
126
+ An optional array of plugin instances that provide transformation hooks. Plugins can be objects or factory functions and execute at different stages of the bundling pipeline (dependency, pre-process, post-process). Defaults to `[]` if not specified.
127
+
128
+ #### allowUpdatePackageJson (optional)
129
+
130
+ Controls whether `susee` automatically updates the `package.json` file with generated `exports`, `main` fields, and `module` fields. When `true`, susee modifies the `package.json` to reflect the bundled outputs. When `false`, `package.json` remains unchanged.
131
+ Defaults to `true` if not specified.
132
+
133
+ #### outDir (optional)
134
+
135
+ Specifies the base output directory where compiled files are written. This can be overridden per entry point if needed (though the current implementation uses a global outDir). Defaults to `"dist"` if not specified.
136
+
137
+ ### EntryPoint Structure
138
+
139
+ Each entry point in the [entryPoints](#entrypoints) array defines a separate bundling target. The EntryPoint interface specifies the following fields:
140
+
141
+ **entry**: The file path to the TypeScript entry file. This path is validated during configuration loading to ensure the file exists
142
+
143
+ **exportPath**: The package export path where this bundle will be exposed. Use "." for the main package export, or subpath like "./config" for additional exports. Duplicate export paths across entry points are not allowed and will cause validation failure.
144
+
145
+ **format (optional)**: Determines which module format(s), `commonjs`,`esm` or both `esm`and `commonjs` to generate.
146
+ Defaults to `esm` if not specified.
147
+
148
+ **tsconfigFilePath (optional)**: Optional path to a custom TypeScript configuration file for this specific entry point. If not specified, susee will resolve for TypesScript compiler options as follow :
149
+
150
+ Priority -
151
+
152
+ 1. this custom `tsconfig.json`
153
+
154
+ 2. `tsconfig.json` at root directory
155
+
156
+ 3. default compiler options of `susee`
157
+
158
+ Notes: You can control TypesScript compiler options from `tsconfig.json` except , `rootDir` , `outDir`,`module`.
159
+
160
+ **renameDuplicates (optional)**: Controls whether susee automatically renames duplicate identifiers during the bundling process to avoid naming conflicts when merging files.(default to `true`).If you want to rename your self set to `false`, process will exit with code-1 and print where duplicate found.
83
161
 
84
162
  ## Plugins
85
163
 
@@ -112,8 +190,22 @@ Output file name hints (produced by the compiler):
112
190
  - The entry file should be an ESM-compatible TypeScript file.
113
191
  - Exports from the entry file are not removed — only dependency exports may be stripped during bundling.
114
192
 
193
+ ## Roadmap
194
+
195
+ Current environment support:
196
+
197
+ - Node.js only.
198
+
199
+ Planned work:
200
+
201
+ - [ ] Add first-class support for Deno environments.
202
+ - [ ] Add browser-oriented library build support.
203
+ - [ ] Improve workflows for building React-related libraries.
204
+
115
205
  ## Contributing and tests
116
206
 
207
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution workflow, pull request checklist, and development guidelines.
208
+
117
209
  - Build and run tests with the repo scripts (see `package.json`):
118
210
 
119
211
  ```bash
@@ -123,4 +215,9 @@ npm test
123
215
 
124
216
  ## License
125
217
 
126
- Apache-2.0
218
+ [Apache-2.0][license] © [Pho Thin Maung][ptm]
219
+
220
+ <!-- markdownlint-disable MD053 -->
221
+
222
+ [license]: LICENSE
223
+ [ptm]: https://github.com/phothinmg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "susee",
3
- "version": "0.1.9",
3
+ "version": "1.0.0",
4
4
  "description": "Tiny TypeScript Bundler",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -70,6 +70,7 @@
70
70
  "url": "git+https://github.com/phothinmg/susee.git",
71
71
  "type": "git"
72
72
  },
73
+ "homepage": "https://github.com/phothinmg/susee#readme",
73
74
  "bugs": {
74
75
  "url": "https://github.com/phothinmg/susee/issues"
75
76
  }