@git.zone/tsbundle 2.7.0 → 2.7.2

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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/tsbundle',
6
- version: '2.7.0',
6
+ version: '2.7.2',
7
7
  description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxvQkFBb0I7SUFDMUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHFHQUFxRztDQUNuSCxDQUFBIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@git.zone/tsbundle",
3
- "version": "2.7.0",
3
+ "version": "2.7.2",
4
4
  "private": false,
5
5
  "description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
6
6
  "main": "dist_ts/index.js",
@@ -59,7 +59,7 @@
59
59
  "packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
60
60
  "repository": {
61
61
  "type": "git",
62
- "url": "https://gitlab.com/gitzone/tsbundle.git"
62
+ "url": "https://code.foss.global/git.zone/tsbundle.git"
63
63
  },
64
64
  "bugs": {
65
65
  "url": "https://gitlab.com/gitzone/tsbundle/issues"
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @git.zone/tsbundle
2
2
 
3
- A powerful multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects.
3
+ A powerful multi-bundler tool supporting **esbuild**, **rolldown**, and **rspack** for painless bundling of web projects. 🚀
4
4
 
5
5
  ## Issue Reporting and Security
6
6
 
@@ -14,136 +14,128 @@ npm install -g @git.zone/tsbundle
14
14
 
15
15
  # Local installation for project usage
16
16
  npm install --save-dev @git.zone/tsbundle
17
+
18
+ # Or with pnpm
19
+ pnpm add -g @git.zone/tsbundle
17
20
  ```
18
21
 
19
- ## Quick Start
22
+ ## Quick Start
20
23
 
21
- ### CLI Usage
24
+ ### Interactive Setup
22
25
 
23
- The simplest way to bundle your project:
26
+ The easiest way to get started is with the interactive wizard:
24
27
 
25
28
  ```bash
26
- # Bundle with default settings (from ./ts_web/index.ts to ./dist_bundle/bundle.js)
27
- tsbundle
28
-
29
- # Bundle with custom paths
30
- tsbundle --from="./src/index.ts" --to="./dist/bundle.js"
31
-
32
- # Production build with minification
33
- tsbundle --from="./src/index.ts" --to="./dist/bundle.js" --production
34
-
35
- # Use a specific bundler
36
- tsbundle --bundler=rolldown
29
+ tsbundle init
37
30
  ```
38
31
 
39
- ### API Usage
32
+ This will guide you through setting up your bundle configuration with preset options:
40
33
 
41
- ```typescript
42
- import { TsBundle } from '@git.zone/tsbundle';
34
+ - **element** - Web component / element bundle (`./ts_web/index.ts` → `./dist_bundle/bundle.js`)
35
+ - **website** - Full website with HTML and assets (`./ts_web/index.ts` → `./dist_serve/bundle.js`)
36
+ - **npm** - NPM package bundle (`./ts/index.ts` → `./dist_bundle/bundle.js`)
37
+ - **custom** - Configure everything manually
43
38
 
44
- const bundler = new TsBundle();
39
+ ### Build Your Bundles
45
40
 
46
- // Basic usage
47
- await bundler.build(
48
- process.cwd(), // working directory
49
- './src/index.ts', // entry point
50
- './dist/bundle.js', // output file
51
- { bundler: 'esbuild' }, // options
52
- );
41
+ Once configured, simply run:
53
42
 
54
- // Production build with rolldown
55
- await bundler.build(process.cwd(), './src/index.ts', './dist/bundle.min.js', {
56
- bundler: 'rolldown',
57
- production: true,
58
- });
43
+ ```bash
44
+ tsbundle
59
45
  ```
60
46
 
61
- ## Available Bundlers
62
-
63
- tsbundle supports three modern bundlers, each with its own strengths:
64
-
65
- - **esbuild** (default): Extremely fast, great for development
66
- - **rolldown**: Rust-based bundler with excellent tree-shaking
67
- - **rspack**: High-performance bundler with webpack compatibility
68
-
69
- Select your bundler using the `--bundler` flag in CLI or the `bundler` option in API.
47
+ That's it! Your bundles will be built according to your `npmextra.json` configuration.
70
48
 
71
49
  ## CLI Commands
72
50
 
73
- ### Default Command
51
+ | Command | Description |
52
+ |---------|-------------|
53
+ | `tsbundle` | Build all bundles from `npmextra.json` configuration |
54
+ | `tsbundle custom` | Same as above (explicit) |
55
+ | `tsbundle init` | Interactive wizard to create/update bundle configuration |
74
56
 
75
- Bundle TypeScript/JavaScript projects:
57
+ ## Configuration 📝
76
58
 
77
- ```bash
78
- tsbundle [options]
79
-
80
- Options:
81
- --from Source entry point (default: ./ts_web/index.ts)
82
- --to Output bundle path (default: ./dist_bundle/bundle.js)
83
- --production Enable production mode with minification
84
- --bundler Choose bundler: esbuild, rolldown, or rspack
85
- --commonjs Output CommonJS format instead of ESM
86
- --skiplibcheck Skip TypeScript library checking
87
- ```
59
+ tsbundle uses `npmextra.json` for configuration. Here's an example:
88
60
 
89
- ### Specialized Commands
61
+ ```json
62
+ {
63
+ "@git.zone/tsbundle": {
64
+ "bundles": [
65
+ {
66
+ "from": "./ts_web/index.ts",
67
+ "to": "./dist_bundle/bundle.js",
68
+ "outputMode": "bundle",
69
+ "bundler": "esbuild",
70
+ "production": false
71
+ },
72
+ {
73
+ "from": "./ts_web/index.ts",
74
+ "to": "./dist_serve/bundle.js",
75
+ "outputMode": "bundle",
76
+ "bundler": "esbuild",
77
+ "includeFiles": ["./html/**/*.html", "./assets/**/*"]
78
+ }
79
+ ]
80
+ }
81
+ }
82
+ ```
90
83
 
91
- #### `tsbundle element`
84
+ ### Bundle Configuration Options
92
85
 
93
- Bundle web components with standard naming conventions:
86
+ | Option | Type | Default | Description |
87
+ |--------|------|---------|-------------|
88
+ | `from` | `string` | - | Entry point TypeScript file |
89
+ | `to` | `string` | - | Output file path |
90
+ | `outputMode` | `"bundle"` \| `"base64ts"` | `"bundle"` | Output format (see below) |
91
+ | `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
92
+ | `production` | `boolean` | `false` | Enable minification |
93
+ | `includeFiles` | `string[]` | `[]` | Glob patterns for additional files (HTML, assets) |
94
94
 
95
- ```bash
96
- tsbundle element
97
- # Bundles from ./ts_web/elements/<elementName>.ts to ./dist_bundle/bundle.js
98
- ```
95
+ ### Output Modes
99
96
 
100
- #### `tsbundle npm`
97
+ #### `bundle` (default)
98
+ Standard JavaScript bundle output. Additional files specified in `includeFiles` are copied to the output directory.
101
99
 
102
- Bundle npm packages for distribution:
100
+ #### `base64ts`
101
+ Generates a TypeScript file with base64-encoded content - perfect for **Deno compile** scenarios where you need everything embedded in a single executable:
103
102
 
104
- ```bash
105
- tsbundle npm
106
- # Prepares your package for npm publishing
103
+ ```typescript
104
+ // Auto-generated by tsbundle
105
+ export const files: { path: string; contentBase64: string }[] = [
106
+ { path: "bundle.js", contentBase64: "Y29uc3QgaGVsbG8gPSAid29ybGQi..." },
107
+ { path: "index.html", contentBase64: "PCFET0NUWVBFIGh0bWw+..." },
108
+ ];
107
109
  ```
108
110
 
109
- #### `tsbundle website`
111
+ ## Available Bundlers 🔧
110
112
 
111
- Full website bundling with HTML processing and asset handling:
113
+ tsbundle supports three modern bundlers:
112
114
 
113
- ```bash
114
- tsbundle website
115
- # Bundles JavaScript, processes HTML, and copies assets
116
- ```
115
+ | Bundler | Speed | Best For |
116
+ |---------|-------|----------|
117
+ | **esbuild** | ⚡⚡⚡ Blazing fast | Development, quick iterations |
118
+ | **rolldown** | ⚡⚡ Fast | Production builds, tree-shaking |
119
+ | **rspack** | ⚡⚡ Fast | Webpack compatibility |
117
120
 
118
- ## API Reference
121
+ ## API Usage
119
122
 
120
123
  ### TsBundle Class
121
124
 
122
- The main bundler class for programmatic usage.
123
-
124
125
  ```typescript
125
126
  import { TsBundle } from '@git.zone/tsbundle';
126
127
 
127
128
  const bundler = new TsBundle();
128
129
 
129
- // Method signature
130
130
  await bundler.build(
131
- cwdArg: string, // Working directory
132
- fromArg?: string, // Entry point (default: './ts_web/index.ts')
133
- toArg?: string, // Output path (default: './dist_bundle/bundle.js')
134
- argvArg?: ICliOptions // Configuration options
135
- ): Promise<void>
136
- ```
137
-
138
- #### ICliOptions Interface
139
-
140
- ```typescript
141
- interface ICliOptions {
142
- bundler: 'esbuild' | 'rolldown' | 'rspack'; // Bundler to use
143
- production?: boolean; // Enable production optimizations
144
- commonjs?: boolean; // Output CommonJS format
145
- skiplibcheck?: boolean; // Skip TypeScript lib checking
146
- }
131
+ process.cwd(), // Working directory
132
+ './src/index.ts', // Entry point
133
+ './dist/bundle.js', // Output path
134
+ {
135
+ bundler: 'esbuild',
136
+ production: true
137
+ }
138
+ );
147
139
  ```
148
140
 
149
141
  ### HtmlHandler Class
@@ -155,156 +147,152 @@ import { HtmlHandler } from '@git.zone/tsbundle';
155
147
 
156
148
  const htmlHandler = new HtmlHandler();
157
149
 
158
- // Check if HTML files exist
159
- const exists = await htmlHandler.checkIfExists();
160
-
161
- // Process HTML with options
162
150
  await htmlHandler.processHtml({
163
- from: './src/index.html', // Source HTML (default: './html/index.html')
164
- to: './dist/index.html', // Output HTML (default: './dist_serve/index.html')
165
- minify: true, // Enable minification
151
+ from: './html/index.html',
152
+ to: './dist/index.html',
153
+ minify: true
166
154
  });
167
155
  ```
168
156
 
169
157
  ### AssetsHandler Class
170
158
 
171
- Handle static assets (images, fonts, etc.):
159
+ Handle static assets:
172
160
 
173
161
  ```typescript
174
162
  import { AssetsHandler } from '@git.zone/tsbundle';
175
163
 
176
164
  const assetsHandler = new AssetsHandler();
177
165
 
178
- // Ensure assets directory exists
179
- await assetsHandler.ensureAssetsDir();
180
-
181
- // Copy and process assets
182
166
  await assetsHandler.processAssets({
183
- from: './src/assets', // Source directory (default: './assets')
184
- to: './dist/assets', // Output directory (default: './dist_serve/assets')
167
+ from: './assets',
168
+ to: './dist/assets'
185
169
  });
186
170
  ```
187
171
 
188
- ## Advanced Examples
172
+ ## Complete Example 🎯
189
173
 
190
- ### Building a Modern Web Application
174
+ ### 1. Initialize your project
191
175
 
192
- ```typescript
193
- import { TsBundle, HtmlHandler, AssetsHandler } from '@git.zone/tsbundle';
194
-
195
- async function buildWebApp() {
196
- const bundler = new TsBundle();
197
- const htmlHandler = new HtmlHandler();
198
- const assetsHandler = new AssetsHandler();
199
-
200
- // Bundle the JavaScript
201
- await bundler.build(process.cwd(), './src/app.ts', './dist/app.js', {
202
- bundler: 'rolldown',
203
- production: true,
204
- });
205
-
206
- // Process HTML
207
- await htmlHandler.processHtml({
208
- from: './src/index.html',
209
- to: './dist/index.html',
210
- minify: true,
211
- });
212
-
213
- // Copy assets
214
- await assetsHandler.processAssets({
215
- from: './src/assets',
216
- to: './dist/assets',
217
- });
218
-
219
- console.log('Build complete!');
220
- }
221
-
222
- buildWebApp();
176
+ ```bash
177
+ tsbundle init
223
178
  ```
224
179
 
225
- ### Multi-Entry Point Bundling
180
+ Select "website" preset for a full web application setup.
226
181
 
227
- ```typescript
228
- import { TsBundle } from '@git.zone/tsbundle';
182
+ ### 2. Your generated config
229
183
 
230
- async function buildMultipleEntries() {
231
- const bundler = new TsBundle();
232
- const entries = [
233
- { from: './src/main.ts', to: './dist/main.js' },
234
- { from: './src/admin.ts', to: './dist/admin.js' },
235
- { from: './src/worker.ts', to: './dist/worker.js' },
236
- ];
237
-
238
- for (const entry of entries) {
239
- await bundler.build(process.cwd(), entry.from, entry.to, {
240
- bundler: 'esbuild',
241
- });
184
+ ```json
185
+ {
186
+ "@git.zone/tsbundle": {
187
+ "bundles": [
188
+ {
189
+ "from": "./ts_web/index.ts",
190
+ "to": "./dist_serve/bundle.js",
191
+ "outputMode": "bundle",
192
+ "bundler": "esbuild",
193
+ "includeFiles": ["./html/**/*.html", "./assets/**/*"]
194
+ }
195
+ ]
242
196
  }
243
197
  }
244
198
  ```
245
199
 
246
- ### Development vs Production Builds
200
+ ### 3. Create your entry point
247
201
 
248
202
  ```typescript
249
- import { TsBundle } from '@git.zone/tsbundle';
203
+ // ts_web/index.ts
204
+ console.log('Hello from tsbundle! 🚀');
250
205
 
251
- const bundler = new TsBundle();
252
- const isDev = process.env.NODE_ENV === 'development';
206
+ export const app = {
207
+ version: '1.0.0',
208
+ init() {
209
+ console.log('App initialized');
210
+ }
211
+ };
253
212
 
254
- await bundler.build(
255
- process.cwd(),
256
- './src/index.ts',
257
- isDev ? './dist/dev/bundle.js' : './dist/prod/bundle.min.js',
258
- {
259
- bundler: isDev ? 'esbuild' : 'rolldown', // esbuild for speed in dev
260
- production: !isDev, // minify in production
261
- commonjs: false, // use ES modules
262
- },
263
- );
213
+ app.init();
264
214
  ```
265
215
 
266
- ## TypeScript Configuration
216
+ ### 4. Build
267
217
 
268
- tsbundle works best with the following TypeScript configuration:
218
+ ```bash
219
+ tsbundle
220
+ ```
221
+
222
+ Your bundle is ready in `./dist_serve/bundle.js` along with any HTML and assets!
223
+
224
+ ## Embedding for Deno Compile 🦕
225
+
226
+ For single-executable scenarios with Deno:
227
+
228
+ ```bash
229
+ tsbundle init
230
+ # Select "custom", set outputMode to "base64ts"
231
+ ```
269
232
 
233
+ Config:
270
234
  ```json
271
235
  {
272
- "compilerOptions": {
273
- "target": "ES2022",
274
- "module": "ESNext",
275
- "moduleResolution": "node",
276
- "esModuleInterop": true,
277
- "allowSyntheticDefaultImports": true,
278
- "strict": true
236
+ "@git.zone/tsbundle": {
237
+ "bundles": [
238
+ {
239
+ "from": "./ts_web/index.ts",
240
+ "to": "./ts/embedded-bundle.ts",
241
+ "outputMode": "base64ts",
242
+ "bundler": "esbuild",
243
+ "production": true,
244
+ "includeFiles": ["./html/index.html"]
245
+ }
246
+ ]
279
247
  }
280
248
  }
281
249
  ```
282
250
 
283
- ## Best Practices
251
+ Then in your Deno app:
252
+ ```typescript
253
+ import { files } from './ts/embedded-bundle.ts';
254
+
255
+ // Decode and serve your embedded files
256
+ const bundle = files.find(f => f.path === 'bundle.js');
257
+ const html = files.find(f => f.path === 'html/index.html');
258
+
259
+ const bundleContent = atob(bundle.contentBase64);
260
+ const htmlContent = atob(html.contentBase64);
261
+ ```
284
262
 
285
- 1. **Entry Points**: Keep your entry points in `ts_web/` for web bundles or `ts/` for library bundles
286
- 2. **Output Structure**: Use `dist_bundle/` for bundled files and `dist_serve/` for web-ready files
287
- 3. **Bundler Selection**:
288
- - Use `esbuild` for development (fastest)
289
- - Use `rolldown` or `rspack` for production (better optimization)
290
- 4. **Assets**: Place static assets in the `assets/` directory
291
- 5. **HTML**: Keep HTML templates in the `html/` directory
263
+ ## Project Structure Recommendations 📁
264
+
265
+ ```
266
+ your-project/
267
+ ├── ts_web/ # Web bundle entry points
268
+ │ └── index.ts
269
+ ├── ts/ # Library/node entry points
270
+ │ └── index.ts
271
+ ├── html/ # HTML templates
272
+ │ └── index.html
273
+ ├── assets/ # Static assets (images, fonts, etc.)
274
+ ├── dist_bundle/ # Output for element/npm bundles
275
+ ├── dist_serve/ # Output for website bundles
276
+ └── npmextra.json # tsbundle configuration
277
+ ```
292
278
 
293
279
  ## License and Legal Information
294
280
 
295
- This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
281
+ This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
296
282
 
297
283
  **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
298
284
 
299
285
  ### Trademarks
300
286
 
301
- This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
287
+ This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
288
+
289
+ Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
302
290
 
303
291
  ### Company Information
304
292
 
305
- Task Venture Capital GmbH
306
- Registered at District court Bremen HRB 35230 HB, Germany
293
+ Task Venture Capital GmbH
294
+ Registered at District Court Bremen HRB 35230 HB, Germany
307
295
 
308
- For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
296
+ For any legal inquiries or further information, please contact us via email at hello@task.vc.
309
297
 
310
298
  By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/tsbundle',
6
- version: '2.7.0',
6
+ version: '2.7.2',
7
7
  description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
8
8
  }