@git.zone/tsbundle 2.7.1 → 2.7.3
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/mod_output/index.js +21 -3
- package/package.json +1 -1
- package/readme.md +177 -189
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/mod_output/index.ts +25 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@git.zone/tsbundle',
|
|
6
|
-
version: '2.7.
|
|
6
|
+
version: '2.7.3',
|
|
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=
|
|
@@ -71,9 +71,27 @@ export class Base64TsOutput {
|
|
|
71
71
|
* Generate TypeScript file content
|
|
72
72
|
*/
|
|
73
73
|
generateTypeScript() {
|
|
74
|
-
const
|
|
74
|
+
const MAX_LINE_LENGTH = 200;
|
|
75
|
+
const formatBase64 = (base64) => {
|
|
76
|
+
if (base64.length <= MAX_LINE_LENGTH) {
|
|
77
|
+
return `"${base64}"`;
|
|
78
|
+
}
|
|
79
|
+
const chunks = [];
|
|
80
|
+
for (let i = 0; i < base64.length; i += MAX_LINE_LENGTH) {
|
|
81
|
+
chunks.push(base64.slice(i, i + MAX_LINE_LENGTH));
|
|
82
|
+
}
|
|
83
|
+
return `"" +\n "${chunks.join('" +\n "')}"`;
|
|
84
|
+
};
|
|
85
|
+
const filesFormatted = this.files.map(file => {
|
|
86
|
+
return ` {
|
|
87
|
+
"path": "${file.path}",
|
|
88
|
+
"contentBase64": ${formatBase64(file.contentBase64)}
|
|
89
|
+
}`;
|
|
90
|
+
}).join(',\n');
|
|
75
91
|
return `// Auto-generated by tsbundle - do not edit
|
|
76
|
-
export const files: { path: string; contentBase64: string }[] =
|
|
92
|
+
export const files: { path: string; contentBase64: string }[] = [
|
|
93
|
+
${filesFormatted}
|
|
94
|
+
];
|
|
77
95
|
`;
|
|
78
96
|
}
|
|
79
97
|
/**
|
|
@@ -100,4 +118,4 @@ export const files: { path: string; contentBase64: string }[] = ${filesJson};
|
|
|
100
118
|
this.files = [];
|
|
101
119
|
}
|
|
102
120
|
}
|
|
103
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
121
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2Rfb3V0cHV0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sY0FBYyxDQUFDO0FBQ3hDLE9BQU8sS0FBSyxLQUFLLE1BQU0sYUFBYSxDQUFDO0FBQ3JDLE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFFckQsTUFBTSxPQUFPLGNBQWM7SUFDakIsS0FBSyxHQUE2QixFQUFFLENBQUM7SUFDckMsR0FBRyxDQUFTO0lBRXBCLFlBQVksTUFBYyxLQUFLLENBQUMsR0FBRztRQUNqQyxJQUFJLENBQUMsR0FBRyxHQUFHLEdBQUcsQ0FBQztJQUNqQixDQUFDO0lBRUQ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VUFBVSxDQUFDLFVBQVUsRUFBRSxJQUFJLENBQUMsR0FBRyxDQUFXLENBQUM7UUFDNUYsTUFBTSxTQUFTLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUM7UUFDckQsTUFBTSxPQUFPLENBQUMsRUFBRSxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQztRQUMvQyxNQUFNLE9BQU8sR0FBRyxJQUFJLENBQUMsa0JBQWtCLEVBQUUsQ0FBQztRQUMxQyxNQUFNLE9BQU8sQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFDLFFBQVEsQ0FBQyxNQUFNLENBQUMsQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDcEUsT0FBTyxDQUFDLEdBQUcsQ0FBQyw4QkFBOEIsVUFBVSxFQUFFLENBQUMsQ0FBQztJQUMxRCxDQUFDO0lBRUQ7O09BRUc7SUFDSSxRQUFRO1FBQ2IsT0FBTyxJQUFJLENBQUMsS0FBSyxDQUFDO0lBQ3BCLENBQUM7SUFFRDs7T0FFRztJQUNJLEtBQUs7UUFDVixJQUFJLENBQUMsS0FBSyxHQUFHLEVBQUUsQ0FBQztJQUNsQixDQUFDO0NBQ0YifQ==
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @git.zone/tsbundle
|
|
2
2
|
|
|
3
|
-
A powerful multi-bundler tool supporting esbuild
|
|
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
|
-
###
|
|
24
|
+
### Interactive Setup
|
|
22
25
|
|
|
23
|
-
The
|
|
26
|
+
The easiest way to get started is with the interactive wizard:
|
|
24
27
|
|
|
25
28
|
```bash
|
|
26
|
-
|
|
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
|
-
|
|
32
|
+
This will guide you through setting up your bundle configuration with preset options:
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
39
|
+
### Build Your Bundles
|
|
45
40
|
|
|
46
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
bundler: 'rolldown',
|
|
57
|
-
production: true,
|
|
58
|
-
});
|
|
43
|
+
```bash
|
|
44
|
+
tsbundle
|
|
59
45
|
```
|
|
60
46
|
|
|
61
|
-
|
|
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
|
-
|
|
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
|
-
|
|
57
|
+
## Configuration 📝
|
|
76
58
|
|
|
77
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
+
### Bundle Configuration Options
|
|
92
85
|
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
tsbundle element
|
|
97
|
-
# Bundles from ./ts_web/elements/<elementName>.ts to ./dist_bundle/bundle.js
|
|
98
|
-
```
|
|
95
|
+
### Output Modes
|
|
99
96
|
|
|
100
|
-
#### `
|
|
97
|
+
#### `bundle` (default)
|
|
98
|
+
Standard JavaScript bundle output. Additional files specified in `includeFiles` are copied to the output directory.
|
|
101
99
|
|
|
102
|
-
|
|
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
|
-
```
|
|
105
|
-
tsbundle
|
|
106
|
-
|
|
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
|
-
|
|
111
|
+
## Available Bundlers 🔧
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
tsbundle supports three modern bundlers:
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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: './
|
|
164
|
-
to: './dist/index.html',
|
|
165
|
-
minify: true
|
|
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
|
|
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: './
|
|
184
|
-
to: './dist/assets'
|
|
167
|
+
from: './assets',
|
|
168
|
+
to: './dist/assets'
|
|
185
169
|
});
|
|
186
170
|
```
|
|
187
171
|
|
|
188
|
-
##
|
|
172
|
+
## Complete Example 🎯
|
|
189
173
|
|
|
190
|
-
###
|
|
174
|
+
### 1. Initialize your project
|
|
191
175
|
|
|
192
|
-
```
|
|
193
|
-
|
|
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
|
-
|
|
180
|
+
Select "website" preset for a full web application setup.
|
|
226
181
|
|
|
227
|
-
|
|
228
|
-
import { TsBundle } from '@git.zone/tsbundle';
|
|
182
|
+
### 2. Your generated config
|
|
229
183
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
###
|
|
200
|
+
### 3. Create your entry point
|
|
247
201
|
|
|
248
202
|
```typescript
|
|
249
|
-
|
|
203
|
+
// ts_web/index.ts
|
|
204
|
+
console.log('Hello from tsbundle! 🚀');
|
|
250
205
|
|
|
251
|
-
const
|
|
252
|
-
|
|
206
|
+
export const app = {
|
|
207
|
+
version: '1.0.0',
|
|
208
|
+
init() {
|
|
209
|
+
console.log('App initialized');
|
|
210
|
+
}
|
|
211
|
+
};
|
|
253
212
|
|
|
254
|
-
|
|
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
|
-
|
|
216
|
+
### 4. Build
|
|
267
217
|
|
|
268
|
-
|
|
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
|
-
"
|
|
273
|
-
"
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
|
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.
|
|
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
|
|
293
|
+
Task Venture Capital GmbH
|
|
294
|
+
Registered at District Court Bremen HRB 35230 HB, Germany
|
|
307
295
|
|
|
308
|
-
For any legal inquiries or
|
|
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.
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/mod_output/index.ts
CHANGED
|
@@ -79,9 +79,32 @@ export class Base64TsOutput {
|
|
|
79
79
|
* Generate TypeScript file content
|
|
80
80
|
*/
|
|
81
81
|
public generateTypeScript(): string {
|
|
82
|
-
const
|
|
82
|
+
const MAX_LINE_LENGTH = 200;
|
|
83
|
+
|
|
84
|
+
const formatBase64 = (base64: string): string => {
|
|
85
|
+
if (base64.length <= MAX_LINE_LENGTH) {
|
|
86
|
+
return `"${base64}"`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const chunks: string[] = [];
|
|
90
|
+
for (let i = 0; i < base64.length; i += MAX_LINE_LENGTH) {
|
|
91
|
+
chunks.push(base64.slice(i, i + MAX_LINE_LENGTH));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return `"" +\n "${chunks.join('" +\n "')}"`;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const filesFormatted = this.files.map(file => {
|
|
98
|
+
return ` {
|
|
99
|
+
"path": "${file.path}",
|
|
100
|
+
"contentBase64": ${formatBase64(file.contentBase64)}
|
|
101
|
+
}`;
|
|
102
|
+
}).join(',\n');
|
|
103
|
+
|
|
83
104
|
return `// Auto-generated by tsbundle - do not edit
|
|
84
|
-
export const files: { path: string; contentBase64: string }[] =
|
|
105
|
+
export const files: { path: string; contentBase64: string }[] = [
|
|
106
|
+
${filesFormatted}
|
|
107
|
+
];
|
|
85
108
|
`;
|
|
86
109
|
}
|
|
87
110
|
|