@git.zone/tsbundle 2.11.4 → 2.13.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/interfaces/index.d.ts +3 -0
- package/dist_ts/mod_custom/index.d.ts +10 -3
- package/dist_ts/mod_custom/index.js +278 -86
- package/dist_ts/mod_esbuild/index.child.d.ts +4 -8
- package/dist_ts/mod_esbuild/index.child.js +54 -44
- package/dist_ts/mod_esbuild/plugins.d.ts +5 -2
- package/dist_ts/mod_esbuild/plugins.js +5 -3
- package/dist_ts/mod_esbuild/workerplugin.d.ts +12 -0
- package/dist_ts/mod_esbuild/workerplugin.js +254 -0
- package/dist_ts/mod_output/artifactpublisher.d.ts +43 -0
- package/dist_ts/mod_output/artifactpublisher.js +925 -0
- package/dist_ts/mod_output/index.d.ts +1 -0
- package/dist_ts/mod_output/index.js +11 -3
- package/dist_ts/mod_presets/index.js +2 -1
- package/dist_ts/mod_rolldown/index.child.d.ts +4 -2
- package/dist_ts/mod_rolldown/index.child.js +48 -36
- package/dist_ts/mod_rspack/index.child.d.ts +4 -2
- package/dist_ts/mod_rspack/index.child.js +76 -115
- package/dist_ts/plugins.d.ts +3 -1
- package/dist_ts/plugins.js +4 -2
- package/dist_ts/tsbundle.class.tsbundle.js +98 -16
- package/package.json +7 -5
- package/readme.hints.md +20 -4
- package/readme.md +29 -6
- package/third-party-notices.md +29 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/interfaces/index.ts +3 -0
- package/ts/mod_custom/index.ts +348 -96
- package/ts/mod_esbuild/index.child.ts +81 -47
- package/ts/mod_esbuild/plugins.ts +9 -2
- package/ts/mod_esbuild/workerplugin.ts +328 -0
- package/ts/mod_output/artifactpublisher.ts +1185 -0
- package/ts/mod_output/index.ts +10 -2
- package/ts/mod_presets/index.ts +1 -0
- package/ts/mod_rolldown/index.child.ts +66 -42
- package/ts/mod_rspack/index.child.ts +98 -127
- package/ts/plugins.ts +3 -1
- package/ts/tsbundle.class.tsbundle.ts +102 -14
|
@@ -3,7 +3,6 @@ import * as interfaces from './interfaces/index.js';
|
|
|
3
3
|
import { logger } from './tsbundle.logging.js';
|
|
4
4
|
export class TsBundle {
|
|
5
5
|
async build(cwdArg, fromArg = './ts_web/index.ts', toArg = './dist_bundle/bundle.js', argvArg) {
|
|
6
|
-
const done = plugins.smartpromise.defer();
|
|
7
6
|
const getBundlerPath = () => {
|
|
8
7
|
switch (argvArg.bundler) {
|
|
9
8
|
case 'rolldown':
|
|
@@ -39,22 +38,105 @@ export class TsBundle {
|
|
|
39
38
|
transportOptions: JSON.stringify(transportOptions),
|
|
40
39
|
},
|
|
41
40
|
});
|
|
42
|
-
const
|
|
43
|
-
childProcess
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
const startPromise = threadsimple.start();
|
|
42
|
+
const childProcess = threadsimple.threadChildProcess;
|
|
43
|
+
if (!childProcess) {
|
|
44
|
+
await startPromise;
|
|
45
|
+
throw new Error('ThreadSimple.start() did not expose its child process synchronously');
|
|
46
|
+
}
|
|
47
|
+
await new Promise((resolve, reject) => {
|
|
48
|
+
let settled = false;
|
|
49
|
+
let startSettled = false;
|
|
50
|
+
let terminal = false;
|
|
51
|
+
let firstError;
|
|
52
|
+
let terminationRequested = false;
|
|
53
|
+
let forceKillTimer;
|
|
54
|
+
const cleanupListeners = () => {
|
|
55
|
+
childProcess.removeListener('error', handleError);
|
|
56
|
+
childProcess.removeListener('exit', handleExit);
|
|
57
|
+
childProcess.removeListener('close', handleClose);
|
|
58
|
+
};
|
|
59
|
+
const clearForceKillTimer = () => {
|
|
60
|
+
if (forceKillTimer) {
|
|
61
|
+
clearTimeout(forceKillTimer);
|
|
62
|
+
forceKillTimer = undefined;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const settleIfComplete = () => {
|
|
66
|
+
if (settled || !startSettled || !terminal) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
settled = true;
|
|
70
|
+
clearForceKillTimer();
|
|
71
|
+
cleanupListeners();
|
|
72
|
+
if (firstError) {
|
|
73
|
+
reject(firstError);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
resolve();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const isChildLive = () => (childProcess.exitCode === null && childProcess.signalCode === null);
|
|
80
|
+
const requestTermination = () => {
|
|
81
|
+
if (terminationRequested || !childProcess.pid || !isChildLive()) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
terminationRequested = true;
|
|
85
|
+
forceKillTimer = setTimeout(() => {
|
|
86
|
+
if (isChildLive()) {
|
|
87
|
+
try {
|
|
88
|
+
childProcess.kill('SIGKILL');
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// The first child-process failure remains the actionable error.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, 5_000);
|
|
95
|
+
try {
|
|
96
|
+
childProcess.kill('SIGTERM');
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// The first child-process failure remains the actionable error.
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleError = (errorArg) => {
|
|
103
|
+
firstError ??= errorArg;
|
|
104
|
+
requestTermination();
|
|
105
|
+
};
|
|
106
|
+
const handleTerminal = (statusArg, signalArg) => {
|
|
107
|
+
if (terminal) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
terminal = true;
|
|
111
|
+
clearForceKillTimer();
|
|
112
|
+
if (!firstError && statusArg !== 0) {
|
|
113
|
+
const exitDetail = statusArg === null ? `signal ${signalArg}` : `exit code ${statusArg}`;
|
|
114
|
+
firstError = new Error(`Bundle build failed with ${exitDetail}`);
|
|
115
|
+
}
|
|
116
|
+
settleIfComplete();
|
|
117
|
+
};
|
|
118
|
+
const handleExit = (statusArg, signalArg) => {
|
|
119
|
+
handleTerminal(statusArg, signalArg);
|
|
120
|
+
};
|
|
121
|
+
const handleClose = (statusArg, signalArg) => {
|
|
122
|
+
handleTerminal(statusArg, signalArg);
|
|
123
|
+
};
|
|
124
|
+
childProcess.on('error', handleError);
|
|
125
|
+
childProcess.once('exit', handleExit);
|
|
126
|
+
childProcess.once('close', handleClose);
|
|
127
|
+
void startPromise.then(() => {
|
|
128
|
+
startSettled = true;
|
|
129
|
+
settleIfComplete();
|
|
130
|
+
}, (errorArg) => {
|
|
131
|
+
startSettled = true;
|
|
132
|
+
firstError ??= errorArg instanceof Error ? errorArg : new Error(String(errorArg));
|
|
133
|
+
requestTermination();
|
|
134
|
+
settleIfComplete();
|
|
135
|
+
});
|
|
136
|
+
if (childProcess.exitCode !== null || childProcess.signalCode !== null) {
|
|
137
|
+
handleTerminal(childProcess.exitCode, childProcess.signalCode);
|
|
49
138
|
}
|
|
50
139
|
});
|
|
51
|
-
await done.promise;
|
|
52
|
-
if (argvArg.sourcemap === false) {
|
|
53
|
-
const outputPath = plugins.path.isAbsolute(toArg)
|
|
54
|
-
? toArg
|
|
55
|
-
: plugins.path.resolve(cwdArg, toArg);
|
|
56
|
-
await plugins.fsPromises.rm(`${outputPath}.map`, { force: true });
|
|
57
|
-
}
|
|
58
140
|
}
|
|
59
141
|
}
|
|
60
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
142
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHNidW5kbGUuY2xhc3MudHNidW5kbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c2J1bmRsZS5jbGFzcy50c2J1bmRsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGNBQWMsQ0FBQztBQUN4QyxPQUFPLEtBQUssVUFBVSxNQUFNLHVCQUF1QixDQUFDO0FBQ3BELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFB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UFDLEVBQ0QsQ0FBQyxRQUFpQixFQUFFLEVBQUU7Z0JBQ3BCLFlBQVksR0FBRyxJQUFJLENBQUM7Z0JBQ3BCLFVBQVUsS0FBSyxRQUFRLFlBQVksS0FBSyxDQUFDLENBQUMsQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDLElBQUksS0FBSyxDQUFDLE1BQU0sQ0FBQyxRQUFRLENBQUMsQ0FBQyxDQUFDO2dCQUNsRixrQkFBa0IsRUFBRSxDQUFDO2dCQUNyQixnQkFBZ0IsRUFBRSxDQUFDO1lBQ3JCLENBQUMsQ0FDRixDQUFDO1lBQ0YsSUFBSSxZQUFZLENBQUMsUUFBUSxLQUFLLElBQUksSUFBSSxZQUFZLENBQUMsVUFBVSxLQUFLLElBQUksRUFBRSxDQUFDO2dCQUN2RSxjQUFjLENBQUMsWUFBWSxDQUFDLFFBQVEsRUFBRSxZQUFZLENBQUMsVUFBVSxDQUFDLENBQUM7WUFDakUsQ0FBQztRQUNILENBQUMsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztDQUNGIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@git.zone/tsbundle",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.13.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",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@git.zone/tsbuild": "^4.4.2",
|
|
16
16
|
"@git.zone/tsrun": "^2.0.6",
|
|
17
17
|
"@git.zone/tstest": "^4.0.0",
|
|
18
|
-
"@types/node": "^26.
|
|
18
|
+
"@types/node": "^26.2.0",
|
|
19
19
|
"lit": "^3.3.3"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@rspack/core": "^2.1.2",
|
|
34
34
|
"esbuild": "^0.28.1",
|
|
35
35
|
"html-minifier-next": "^5.2.2",
|
|
36
|
+
"magic-string": "1.2.0",
|
|
36
37
|
"rolldown": "1.2.1",
|
|
37
38
|
"typescript": "6.0.3"
|
|
38
39
|
},
|
|
@@ -45,7 +46,8 @@
|
|
|
45
46
|
"assets/**/*",
|
|
46
47
|
"cli.js",
|
|
47
48
|
".smartconfig.json",
|
|
48
|
-
"readme.md"
|
|
49
|
+
"readme.md",
|
|
50
|
+
"third-party-notices.md"
|
|
49
51
|
],
|
|
50
52
|
"browserslist": [
|
|
51
53
|
"last 1 chrome versions"
|
|
@@ -55,9 +57,9 @@
|
|
|
55
57
|
"url": "https://code.foss.global/git.zone/tsbundle.git"
|
|
56
58
|
},
|
|
57
59
|
"bugs": {
|
|
58
|
-
"url": "https://
|
|
60
|
+
"url": "https://community.foss.global/"
|
|
59
61
|
},
|
|
60
|
-
"homepage": "https://
|
|
62
|
+
"homepage": "https://code.foss.global/git.zone/tsbundle",
|
|
61
63
|
"scripts": {
|
|
62
64
|
"test": "pnpm run build && (tstest test/ --verbose)",
|
|
63
65
|
"build": "(tsbuild --web)",
|
package/readme.hints.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# tsbundle Hints and Findings
|
|
2
2
|
|
|
3
|
+
## Recent Updates (2026-08-23)
|
|
4
|
+
|
|
5
|
+
- Esbuild module workers are transformed by the internal MIT-derived plugin in `ts/mod_esbuild/workerplugin.ts`; there is no runtime dependency on the Chialab package.
|
|
6
|
+
- Every direct backend output is generated in a same-filesystem staging directory. Direct and custom outputs acquire both output-directory and destination locks so generated and included files cannot interleave.
|
|
7
|
+
- Worker chunks use a namespace derived from the final logical output name. `chunks/<namespace>/.tsbundle-artifacts.json` tracks ownership so successful rebuilds can remove stale artifacts without touching neighboring bundles.
|
|
8
|
+
- Rejected generation or publication before the main-file commit restores mutable output and preserves the last successful main bundle. `base64ts` embeds generated chunks and source maps but excludes tsbundle ownership metadata.
|
|
9
|
+
- Each custom bundle uses a unique project-local `.nogit/tsbundle-temp-*` workspace. Active concurrent workspaces are retained; abandoned marked workspaces older than 24 hours and legacy marked workspaces are pruned.
|
|
10
|
+
|
|
3
11
|
## Recent Updates (2026-03-24)
|
|
4
12
|
|
|
5
13
|
- Upgraded all dependencies to latest versions
|
|
6
|
-
- Migrated from npmextra.json to smartconfig.json (renamed file, updated all references)
|
|
14
|
+
- Migrated from npmextra.json to `.smartconfig.json` (renamed file, updated all references)
|
|
7
15
|
- Renamed `npmextra` import to `smartconfig` in plugins.ts
|
|
8
16
|
- Fixed rolldown deprecation: `inlineDynamicImports` replaced with `codeSplitting: false`
|
|
9
17
|
- Major version bumps: tsbuild ^3.1.2 -> ^4.3.0, TypeScript 5.9.3 -> 6.0.2
|
|
@@ -20,12 +28,12 @@
|
|
|
20
28
|
## Bundler Implementations
|
|
21
29
|
|
|
22
30
|
- **esbuild** (default): Fully implemented, production ready
|
|
23
|
-
- **rolldown**: Implemented and working (1.
|
|
24
|
-
- **rspack**: Implemented and working (
|
|
31
|
+
- **rolldown**: Implemented and working (1.2.1), produces smallest bundles
|
|
32
|
+
- **rspack**: Implemented and working (v2.1.2), webpack-compatible API
|
|
25
33
|
|
|
26
34
|
## Configuration
|
|
27
35
|
|
|
28
|
-
- Config file:
|
|
36
|
+
- Config file: `.smartconfig.json` (previously `npmextra.json`)
|
|
29
37
|
- Config key: `@git.zone/tsbundle` with `bundles` array
|
|
30
38
|
- Supports `bundle` and `base64ts` output modes
|
|
31
39
|
- Interactive init wizard via `tsbundle init`
|
|
@@ -40,3 +48,11 @@
|
|
|
40
48
|
## Known Issues
|
|
41
49
|
|
|
42
50
|
- Rolldown emits a warning about `preserveValueImports` in tsconfig - this is informational only
|
|
51
|
+
|
|
52
|
+
## Esbuild Worker Artifacts
|
|
53
|
+
|
|
54
|
+
- Standard module workers use `new Worker(new URL('./worker.js', import.meta.url), { type: 'module' })` and are emitted through tsbundle's internal worker plugin.
|
|
55
|
+
- Direct `.ts` references and NodeNext-style `.js` references are supported. Acyclic nested workers are emitted recursively; cycles reject the build, and shared workers are built once with URLs relative to each emitter.
|
|
56
|
+
- Test-mode builds need an explicit collision-safe `chunkNames` pattern because the main entry name is derived from the requested destination filename.
|
|
57
|
+
- Custom bundle handling must publish every generated artifact from its unique `.nogit/tsbundle-temp-*` workspace before cleanup; this includes worker chunks and source maps. `base64ts` must embed the same complete artifact set.
|
|
58
|
+
- TypeScript remains on 6.0.3 because 7.0.2 no longer exports the stable compiler API used by the worker transformer.
|
package/readme.md
CHANGED
|
@@ -48,7 +48,7 @@ Your bundles will be built according to your `.smartconfig.json` configuration.
|
|
|
48
48
|
| Command | Description |
|
|
49
49
|
|---------|-------------|
|
|
50
50
|
| `tsbundle` | Build all bundles from `.smartconfig.json` configuration |
|
|
51
|
-
| `tsbundle --keep-temp` | Build all bundles and keep `.nogit/tsbundle-temp
|
|
51
|
+
| `tsbundle --keep-temp` | Build all bundles and keep their `.nogit/tsbundle-temp-*` workspaces for debugging |
|
|
52
52
|
| `tsbundle custom` | Same as above (explicit) |
|
|
53
53
|
| `tsbundle init` | Interactive wizard to create/update bundle configuration |
|
|
54
54
|
| `tsbundle element` | Zero-config compatibility preset for `ts_web` component bundles |
|
|
@@ -96,22 +96,32 @@ tsbundle uses `.smartconfig.json` for configuration. Here's an example:
|
|
|
96
96
|
| `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
|
|
97
97
|
| `production` | `boolean` | `false` | Enable minification |
|
|
98
98
|
| `sourcemap` | `boolean` | `true` | Control external source-map generation |
|
|
99
|
-
| `
|
|
99
|
+
| `banner` | `string` | - | Valid JavaScript inserted verbatim before every JavaScript output, including emitted workers |
|
|
100
|
+
| `includeFiles` | `(string \| { from: string; to: string })[]` | `[]` | Additional file patterns; object entries set the serve path in `base64ts` mode |
|
|
100
101
|
| `maxLineLength` | `number` | `0` (unlimited) | For `base64ts` mode: max chars per line in output |
|
|
101
|
-
| `keepTemp` | `boolean` | `false` | Keep `.nogit/tsbundle-temp
|
|
102
|
+
| `keepTemp` | `boolean` | `false` | Keep the bundle's `.nogit/tsbundle-temp-*` workspace for debugging |
|
|
102
103
|
|
|
103
104
|
Top-level `keepTemp: true` keeps the temp workspace for all bundles. Per-bundle `keepTemp` only affects that bundle. `TSBUNDLE_KEEP_TEMP=true` and `--keep-temp` are supported for one-off debugging.
|
|
104
105
|
|
|
106
|
+
Use `banner` for content that must remain attached to every generated JavaScript artifact,
|
|
107
|
+
such as a license or attribution comment. The value is inserted verbatim and therefore
|
|
108
|
+
must be valid JavaScript; a block comment is the usual form. Esbuild, Rolldown, and Rspack
|
|
109
|
+
apply the same option through their native banner support.
|
|
110
|
+
|
|
105
111
|
### Temporary Workspace Cleanup
|
|
106
112
|
|
|
107
|
-
|
|
113
|
+
Each custom bundle build uses a unique project-local `.nogit/tsbundle-temp-*` intermediate workspace. tsbundle writes `.gitzone-tool-cache.json` into the workspace and removes it after output handling unless `keepTemp` is enabled. The marker records the owning process so concurrent builds do not delete each other's active workspaces. On startup, marked workspaces older than 24 hours whose owner is no longer running are pruned so interrupted builds do not accumulate indefinitely.
|
|
108
114
|
|
|
109
|
-
|
|
115
|
+
Legacy `.nogit/tsbundle-temp` and OS temp workspaces with valid stale tsbundle markers are also pruned. An unmarked legacy workspace is never claimed or deleted.
|
|
110
116
|
|
|
111
117
|
### Output Modes
|
|
112
118
|
|
|
113
119
|
#### `bundle` (default)
|
|
114
|
-
Standard JavaScript bundle output. Additional files specified in `includeFiles` are copied to the output directory.
|
|
120
|
+
Standard JavaScript bundle output. Additional files specified in `includeFiles` are copied to the output directory. Generated chunks, module workers, and enabled source maps are preserved beside the main bundle.
|
|
121
|
+
|
|
122
|
+
All direct backends and custom publication acquire both output-directory and destination locks so generated and included files cannot interleave. If generation or publication reports an error before the main-file commit, tsbundle restores mutable files and leaves the previous bundle intact. After a successful commit, it removes stale worker chunks and source maps that it owns without deleting neighboring bundle artifacts. Each owned namespace records that ownership in `chunks/<namespace>/.tsbundle-artifacts.json`.
|
|
123
|
+
|
|
124
|
+
String `includeFiles` entries and object entries in `bundle` mode are copied by source basename into the bundle output directory. In `base64ts` mode, an object entry's `to` value is its embedded serve path. Duplicate embedded paths reject the build instead of producing ambiguous output.
|
|
115
125
|
|
|
116
126
|
#### `base64ts`
|
|
117
127
|
Generates a TypeScript file with base64-encoded content - perfect for **Deno compile** scenarios where you need everything embedded in a single executable:
|
|
@@ -120,12 +130,25 @@ Generates a TypeScript file with base64-encoded content - perfect for **Deno com
|
|
|
120
130
|
// Auto-generated by tsbundle
|
|
121
131
|
export const files: { path: string; contentBase64: string }[] = [
|
|
122
132
|
{ path: "bundle.js", contentBase64: "Y29uc3QgaGVsbG8gPSAid29ybGQi..." },
|
|
133
|
+
{ path: "bundle.js.map", contentBase64: "eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbLi4u" },
|
|
123
134
|
{ path: "index.html", contentBase64: "PCFET0NUWVBFIGh0bWw+..." },
|
|
124
135
|
];
|
|
125
136
|
```
|
|
126
137
|
|
|
127
138
|
If you're working with AI tools that have line length limitations, set `maxLineLength` (e.g., `200`) to split long base64 strings across multiple lines.
|
|
128
139
|
|
|
140
|
+
### Module Workers With Esbuild
|
|
141
|
+
|
|
142
|
+
The esbuild backend recognizes standard module-worker construction and emits the worker as a separate collision-safe chunk:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const worker = new Worker(new URL('./worker.js', import.meta.url), {
|
|
146
|
+
type: 'module',
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Both direct `.ts` worker references and NodeNext-style `.js` specifiers are supported; `.js` references resolve to the corresponding TypeScript source when present. Acyclic nested worker graphs are emitted recursively, and reused workers are built once while receiving the correct URL from every parent. Cyclic worker graphs reject the build. Direct and custom `bundle` output publishes worker chunks and source maps with the main bundle, while `base64ts` includes them in its generated file list. Rebuilding the same destination replaces its owned worker artifact set without affecting files owned by another bundle.
|
|
151
|
+
|
|
129
152
|
## Available Bundlers
|
|
130
153
|
|
|
131
154
|
tsbundle supports three modern bundlers, each with different strengths:
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
## Chialab esbuild worker plugin
|
|
4
|
+
|
|
5
|
+
The internal esbuild module-worker transformation in
|
|
6
|
+
`ts/mod_esbuild/workerplugin.ts` is derived from
|
|
7
|
+
`@chialab/esbuild-plugin-worker` version 0.19.2.
|
|
8
|
+
|
|
9
|
+
MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2021 Chialab
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/interfaces/index.ts
CHANGED
|
@@ -3,7 +3,9 @@ export interface ICliOptions {
|
|
|
3
3
|
skiplibcheck?: boolean;
|
|
4
4
|
production?: boolean;
|
|
5
5
|
sourcemap?: boolean;
|
|
6
|
+
banner?: string;
|
|
6
7
|
keepTemp?: boolean;
|
|
8
|
+
chunkOwner?: string;
|
|
7
9
|
bundler: 'esbuild' | 'rolldown' | 'rspack';
|
|
8
10
|
}
|
|
9
11
|
|
|
@@ -33,6 +35,7 @@ export interface IBundleConfig {
|
|
|
33
35
|
bundler?: TBundler;
|
|
34
36
|
production?: boolean;
|
|
35
37
|
sourcemap?: boolean;
|
|
38
|
+
banner?: string;
|
|
36
39
|
includeFiles?: TIncludeFile[];
|
|
37
40
|
maxLineLength?: number; // For base64ts output: max chars per line. 0 or undefined = unlimited (default)
|
|
38
41
|
keepTemp?: boolean;
|