@git.zone/tsbundle 2.4.1 → 2.5.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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/tsbundle',
6
- version: '2.4.1',
6
+ version: '2.5.0',
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.4.1",
3
+ "version": "2.5.0",
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",
package/readme.md CHANGED
@@ -1,71 +1,304 @@
1
1
  # @git.zone/tsbundle
2
- a bundler using rollup for painless bundling of web projects
3
2
 
4
- ## Availabililty and Links
5
- * [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tsbundle)
6
- * [gitlab.com (source)](https://gitlab.com/gitzone/tsbundle)
7
- * [github.com (source mirror)](https://github.com/gitzone/tsbundle)
8
- * [docs (typedoc)](https://gitzone.gitlab.io/tsbundle/)
3
+ A powerful multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects.
9
4
 
10
- ## Status for master
5
+ ## Installation
11
6
 
12
- Status Category | Status Badge
13
- -- | --
14
- GitLab Pipelines | [![pipeline status](https://gitlab.com/gitzone/tsbundle/badges/master/pipeline.svg)](https://lossless.cloud)
15
- GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/gitzone/tsbundle/badges/master/coverage.svg)](https://lossless.cloud)
16
- npm | [![npm downloads per month](https://badgen.net/npm/dy/@git.zone/tsbundle)](https://lossless.cloud)
17
- Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/gitzone/tsbundle)](https://lossless.cloud)
18
- TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
19
- node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
20
- Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
21
- PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@git.zone/tsbundle)](https://lossless.cloud)
22
- PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@git.zone/tsbundle)](https://lossless.cloud)
23
- BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@git.zone/tsbundle)](https://lossless.cloud)
24
- Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
7
+ ```bash
8
+ # Global installation for CLI usage
9
+ npm install -g @git.zone/tsbundle
25
10
 
26
- ## Usage
11
+ # Local installation for project usage
12
+ npm install --save-dev @git.zone/tsbundle
13
+ ```
27
14
 
28
- Use TypeScript for best in class intellisense.
15
+ ## Quick Start
29
16
 
30
- tsbundle will bundle modern JavaScript websites in an Google Bot conformant way so things like AdSense do work.
17
+ ### CLI Usage
31
18
 
32
- tsbundle supports two modes of usage: CLI and API usage.
19
+ The simplest way to bundle your project:
33
20
 
34
- ### CLI
21
+ ```bash
22
+ # Bundle with default settings (from ./ts_web/index.ts to ./dist_bundle/bundle.js)
23
+ tsbundle
35
24
 
36
- ```shell
37
- # Note: This is code that belongs into your terminal ;)
38
- # Install the tool for cli usage
25
+ # Bundle with custom paths
26
+ tsbundle --from="./src/index.ts" --to="./dist/bundle.js"
39
27
 
40
- # Globally
41
- npm install -g @git.zone/tsbundle
28
+ # Production build with minification
29
+ tsbundle --from="./src/index.ts" --to="./dist/bundle.js" --production
42
30
 
43
- # Locally for use in your pacakge.json
44
- npm install --save-dev @git.zone/tsbundle
31
+ # Use a specific bundler
32
+ tsbundle --bundler=rolldown
33
+ ```
34
+
35
+ ### API Usage
36
+
37
+ ```typescript
38
+ import { TsBundle } from '@git.zone/tsbundle';
39
+
40
+ const bundler = new TsBundle();
41
+
42
+ // Basic usage
43
+ await bundler.build(
44
+ process.cwd(), // working directory
45
+ './src/index.ts', // entry point
46
+ './dist/bundle.js', // output file
47
+ { bundler: 'esbuild' } // options
48
+ );
49
+
50
+ // Production build with rolldown
51
+ await bundler.build(
52
+ process.cwd(),
53
+ './src/index.ts',
54
+ './dist/bundle.min.js',
55
+ {
56
+ bundler: 'rolldown',
57
+ production: true
58
+ }
59
+ );
60
+ ```
61
+
62
+ ## Available Bundlers
63
+
64
+ tsbundle supports three modern bundlers, each with its own strengths:
65
+
66
+ - **esbuild** (default): Extremely fast, great for development
67
+ - **rolldown**: Rust-based bundler with excellent tree-shaking
68
+ - **rspack**: High-performance bundler with webpack compatibility
69
+
70
+ Select your bundler using the `--bundler` flag in CLI or the `bundler` option in API.
71
+
72
+ ## CLI Commands
73
+
74
+ ### Default Command
75
+
76
+ Bundle TypeScript/JavaScript projects:
77
+
78
+ ```bash
79
+ tsbundle [options]
80
+
81
+ Options:
82
+ --from Source entry point (default: ./ts_web/index.ts)
83
+ --to Output bundle path (default: ./dist_bundle/bundle.js)
84
+ --production Enable production mode with minification
85
+ --bundler Choose bundler: esbuild, rolldown, or rspack
86
+ --commonjs Output CommonJS format instead of ESM
87
+ --skiplibcheck Skip TypeScript library checking
88
+ ```
89
+
90
+ ### Specialized Commands
91
+
92
+ #### `tsbundle element`
93
+
94
+ Bundle web components with standard naming conventions:
95
+
96
+ ```bash
97
+ tsbundle element
98
+ # Bundles from ./ts_web/elements/<elementName>.ts to ./dist_bundle/bundle.js
99
+ ```
100
+
101
+ #### `tsbundle npm`
102
+
103
+ Bundle npm packages for distribution:
104
+
105
+ ```bash
106
+ tsbundle npm
107
+ # Prepares your package for npm publishing
108
+ ```
109
+
110
+ #### `tsbundle website`
111
+
112
+ Full website bundling with HTML processing and asset handling:
113
+
114
+ ```bash
115
+ tsbundle website
116
+ # Bundles JavaScript, processes HTML, and copies assets
117
+ ```
118
+
119
+ ## API Reference
120
+
121
+ ### TsBundle Class
122
+
123
+ The main bundler class for programmatic usage.
45
124
 
46
- # then use it
47
- tsbundle --from="./ts/index.ts" --to="dist/bundle.js"
125
+ ```typescript
126
+ import { TsBundle } from '@git.zone/tsbundle';
127
+
128
+ const bundler = new TsBundle();
129
+
130
+ // Method signature
131
+ await bundler.build(
132
+ cwdArg: string, // Working directory
133
+ fromArg?: string, // Entry point (default: './ts_web/index.ts')
134
+ toArg?: string, // Output path (default: './dist_bundle/bundle.js')
135
+ argvArg?: ICliOptions // Configuration options
136
+ ): Promise<void>
137
+ ```
138
+
139
+ #### ICliOptions Interface
140
+
141
+ ```typescript
142
+ interface ICliOptions {
143
+ bundler: 'esbuild' | 'rolldown' | 'rspack'; // Bundler to use
144
+ production?: boolean; // Enable production optimizations
145
+ commonjs?: boolean; // Output CommonJS format
146
+ skiplibcheck?: boolean; // Skip TypeScript lib checking
147
+ }
148
+ ```
149
+
150
+ ### HtmlHandler Class
151
+
152
+ Process and minify HTML files:
48
153
 
49
- ## note you can call tsbundle without arguments. Default values are --from="./ts_web/index.ts" --to="dist_bundle/bundle.js"
50
- ## You can use --production to enable minification using terser
154
+ ```typescript
155
+ import { HtmlHandler } from '@git.zone/tsbundle';
156
+
157
+ const htmlHandler = new HtmlHandler();
158
+
159
+ // Check if HTML files exist
160
+ const exists = await htmlHandler.checkIfExists();
161
+
162
+ // Process HTML with options
163
+ await htmlHandler.processHtml({
164
+ from: './src/index.html', // Source HTML (default: './html/index.html')
165
+ to: './dist/index.html', // Output HTML (default: './dist_serve/index.html')
166
+ minify: true // Enable minification
167
+ });
51
168
  ```
52
169
 
53
- ## API
170
+ ### AssetsHandler Class
54
171
 
55
- You are using TypeScript, aren't you? Most of the stuff is apparent from the IDE intellisense.
172
+ Handle static assets (images, fonts, etc.):
56
173
 
57
174
  ```typescript
58
- import { TsBundle } from '@gitozne/tsbundle';
175
+ import { AssetsHandler } from '@git.zone/tsbundle';
176
+
177
+ const assetsHandler = new AssetsHandler();
59
178
 
60
- const myTsBundleInstance = new TsBundle();
179
+ // Ensure assets directory exists
180
+ await assetsHandler.ensureAssetsDir();
61
181
 
62
- const run = async () => {
63
- await myTsBundleInstance.buildTest('./from/my.ts', './to/mybundle.js');
64
- // OR
65
- await myTsBundleInstance.buildProduction('./from/my.ts', './to/mybundle.js');
66
- };
182
+ // Copy and process assets
183
+ await assetsHandler.processAssets({
184
+ from: './src/assets', // Source directory (default: './assets')
185
+ to: './dist/assets' // Output directory (default: './dist_serve/assets')
186
+ });
67
187
  ```
68
188
 
189
+ ## Advanced Examples
190
+
191
+ ### Building a Modern Web Application
192
+
193
+ ```typescript
194
+ import { TsBundle, HtmlHandler, AssetsHandler } from '@git.zone/tsbundle';
195
+
196
+ async function buildWebApp() {
197
+ const bundler = new TsBundle();
198
+ const htmlHandler = new HtmlHandler();
199
+ const assetsHandler = new AssetsHandler();
200
+
201
+ // Bundle the JavaScript
202
+ await bundler.build(
203
+ process.cwd(),
204
+ './src/app.ts',
205
+ './dist/app.js',
206
+ {
207
+ bundler: 'rolldown',
208
+ production: true
209
+ }
210
+ );
211
+
212
+ // Process HTML
213
+ await htmlHandler.processHtml({
214
+ from: './src/index.html',
215
+ to: './dist/index.html',
216
+ minify: true
217
+ });
218
+
219
+ // Copy assets
220
+ await assetsHandler.processAssets({
221
+ from: './src/assets',
222
+ to: './dist/assets'
223
+ });
224
+
225
+ console.log('Build complete!');
226
+ }
227
+
228
+ buildWebApp();
229
+ ```
230
+
231
+ ### Multi-Entry Point Bundling
232
+
233
+ ```typescript
234
+ import { TsBundle } from '@git.zone/tsbundle';
235
+
236
+ async function buildMultipleEntries() {
237
+ const bundler = new TsBundle();
238
+ const entries = [
239
+ { from: './src/main.ts', to: './dist/main.js' },
240
+ { from: './src/admin.ts', to: './dist/admin.js' },
241
+ { from: './src/worker.ts', to: './dist/worker.js' }
242
+ ];
243
+
244
+ for (const entry of entries) {
245
+ await bundler.build(
246
+ process.cwd(),
247
+ entry.from,
248
+ entry.to,
249
+ { bundler: 'esbuild' }
250
+ );
251
+ }
252
+ }
253
+ ```
254
+
255
+ ### Development vs Production Builds
256
+
257
+ ```typescript
258
+ import { TsBundle } from '@git.zone/tsbundle';
259
+
260
+ const bundler = new TsBundle();
261
+ const isDev = process.env.NODE_ENV === 'development';
262
+
263
+ await bundler.build(
264
+ process.cwd(),
265
+ './src/index.ts',
266
+ isDev ? './dist/dev/bundle.js' : './dist/prod/bundle.min.js',
267
+ {
268
+ bundler: isDev ? 'esbuild' : 'rolldown', // esbuild for speed in dev
269
+ production: !isDev, // minify in production
270
+ commonjs: false // use ES modules
271
+ }
272
+ );
273
+ ```
274
+
275
+ ## TypeScript Configuration
276
+
277
+ tsbundle works best with the following TypeScript configuration:
278
+
279
+ ```json
280
+ {
281
+ "compilerOptions": {
282
+ "target": "ES2022",
283
+ "module": "ESNext",
284
+ "moduleResolution": "node",
285
+ "esModuleInterop": true,
286
+ "allowSyntheticDefaultImports": true,
287
+ "strict": true
288
+ }
289
+ }
290
+ ```
291
+
292
+ ## Best Practices
293
+
294
+ 1. **Entry Points**: Keep your entry points in `ts_web/` for web bundles or `ts/` for library bundles
295
+ 2. **Output Structure**: Use `dist_bundle/` for bundled files and `dist_serve/` for web-ready files
296
+ 3. **Bundler Selection**:
297
+ - Use `esbuild` for development (fastest)
298
+ - Use `rolldown` or `rspack` for production (better optimization)
299
+ 4. **Assets**: Place static assets in the `assets/` directory
300
+ 5. **HTML**: Keep HTML templates in the `html/` directory
301
+
69
302
  ## Contribution
70
303
 
71
304
  We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
@@ -75,4 +308,4 @@ For further information read the linked docs at the top of this readme.
75
308
  > MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
76
309
  | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
77
310
 
78
- [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
311
+ [![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/tsbundle',
6
- version: '2.4.1',
6
+ version: '2.5.0',
7
7
  description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
8
8
  }