@git.zone/tsbundle 2.5.2 → 2.6.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/mod_assets/index.d.ts +1 -0
- package/dist_ts/mod_assets/index.js +32 -14
- package/dist_ts/mod_esbuild/index.child.js +9 -3
- package/dist_ts/mod_esbuild/plugins.js +1 -1
- package/dist_ts/mod_html/index.js +12 -9
- package/dist_ts/mod_html/plugins.js +1 -1
- package/dist_ts/mod_rolldown/index.child.js +9 -6
- package/dist_ts/mod_rolldown/plugins.js +1 -1
- package/dist_ts/mod_rspack/index.child.js +9 -3
- package/dist_ts/mod_rspack/plugins.js +1 -1
- package/dist_ts/plugins.d.ts +3 -2
- package/dist_ts/plugins.js +5 -3
- package/dist_ts/tsbundle.class.tsbundle.js +3 -3
- package/dist_ts/tsbundle.cli.js +11 -2
- package/dist_ts/tsbundle.logging.js +1 -1
- package/npmextra.json +1 -1
- package/package.json +22 -14
- package/readme.hints.md +20 -4
- package/readme.md +42 -51
- package/readme.plan.md +26 -12
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/interfaces/index.ts +3 -3
- package/ts/mod_assets/index.ts +48 -20
- package/ts/mod_esbuild/index.child.ts +29 -11
- package/ts/mod_esbuild/plugins.ts +1 -3
- package/ts/mod_html/index.ts +27 -10
- package/ts/mod_html/plugins.ts +1 -3
- package/ts/mod_rolldown/index.child.ts +35 -20
- package/ts/mod_rolldown/plugins.ts +1 -1
- package/ts/mod_rspack/index.child.ts +55 -30
- package/ts/mod_rspack/plugins.ts +1 -1
- package/ts/paths.ts +1 -1
- package/ts/plugins.ts +5 -2
- package/ts/tsbundle.class.tsbundle.ts +8 -9
- package/ts/tsbundle.cli.ts +13 -4
- package/ts/tsbundle.logging.ts +3 -1
package/readme.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A powerful multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects.
|
|
4
4
|
|
|
5
|
+
## Issue Reporting and Security
|
|
6
|
+
|
|
7
|
+
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
```bash
|
|
@@ -41,22 +45,17 @@ const bundler = new TsBundle();
|
|
|
41
45
|
|
|
42
46
|
// Basic usage
|
|
43
47
|
await bundler.build(
|
|
44
|
-
process.cwd(),
|
|
45
|
-
'./src/index.ts',
|
|
46
|
-
'./dist/bundle.js',
|
|
47
|
-
{ bundler: 'esbuild' }
|
|
48
|
+
process.cwd(), // working directory
|
|
49
|
+
'./src/index.ts', // entry point
|
|
50
|
+
'./dist/bundle.js', // output file
|
|
51
|
+
{ bundler: 'esbuild' }, // options
|
|
48
52
|
);
|
|
49
53
|
|
|
50
54
|
// Production build with rolldown
|
|
51
|
-
await bundler.build(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{
|
|
56
|
-
bundler: 'rolldown',
|
|
57
|
-
production: true
|
|
58
|
-
}
|
|
59
|
-
);
|
|
55
|
+
await bundler.build(process.cwd(), './src/index.ts', './dist/bundle.min.js', {
|
|
56
|
+
bundler: 'rolldown',
|
|
57
|
+
production: true,
|
|
58
|
+
});
|
|
60
59
|
```
|
|
61
60
|
|
|
62
61
|
## Available Bundlers
|
|
@@ -141,9 +140,9 @@ await bundler.build(
|
|
|
141
140
|
```typescript
|
|
142
141
|
interface ICliOptions {
|
|
143
142
|
bundler: 'esbuild' | 'rolldown' | 'rspack'; // Bundler to use
|
|
144
|
-
production?: boolean;
|
|
145
|
-
commonjs?: boolean;
|
|
146
|
-
skiplibcheck?: boolean;
|
|
143
|
+
production?: boolean; // Enable production optimizations
|
|
144
|
+
commonjs?: boolean; // Output CommonJS format
|
|
145
|
+
skiplibcheck?: boolean; // Skip TypeScript lib checking
|
|
147
146
|
}
|
|
148
147
|
```
|
|
149
148
|
|
|
@@ -161,9 +160,9 @@ const exists = await htmlHandler.checkIfExists();
|
|
|
161
160
|
|
|
162
161
|
// Process HTML with options
|
|
163
162
|
await htmlHandler.processHtml({
|
|
164
|
-
from: './src/index.html',
|
|
165
|
-
to: './dist/index.html',
|
|
166
|
-
minify: true
|
|
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
|
|
167
166
|
});
|
|
168
167
|
```
|
|
169
168
|
|
|
@@ -181,8 +180,8 @@ await assetsHandler.ensureAssetsDir();
|
|
|
181
180
|
|
|
182
181
|
// Copy and process assets
|
|
183
182
|
await assetsHandler.processAssets({
|
|
184
|
-
from: './src/assets',
|
|
185
|
-
to: './dist/assets'
|
|
183
|
+
from: './src/assets', // Source directory (default: './assets')
|
|
184
|
+
to: './dist/assets', // Output directory (default: './dist_serve/assets')
|
|
186
185
|
});
|
|
187
186
|
```
|
|
188
187
|
|
|
@@ -197,31 +196,26 @@ async function buildWebApp() {
|
|
|
197
196
|
const bundler = new TsBundle();
|
|
198
197
|
const htmlHandler = new HtmlHandler();
|
|
199
198
|
const assetsHandler = new AssetsHandler();
|
|
200
|
-
|
|
199
|
+
|
|
201
200
|
// Bundle the JavaScript
|
|
202
|
-
await bundler.build(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
bundler: 'rolldown',
|
|
208
|
-
production: true
|
|
209
|
-
}
|
|
210
|
-
);
|
|
211
|
-
|
|
201
|
+
await bundler.build(process.cwd(), './src/app.ts', './dist/app.js', {
|
|
202
|
+
bundler: 'rolldown',
|
|
203
|
+
production: true,
|
|
204
|
+
});
|
|
205
|
+
|
|
212
206
|
// Process HTML
|
|
213
207
|
await htmlHandler.processHtml({
|
|
214
208
|
from: './src/index.html',
|
|
215
209
|
to: './dist/index.html',
|
|
216
|
-
minify: true
|
|
210
|
+
minify: true,
|
|
217
211
|
});
|
|
218
|
-
|
|
212
|
+
|
|
219
213
|
// Copy assets
|
|
220
214
|
await assetsHandler.processAssets({
|
|
221
215
|
from: './src/assets',
|
|
222
|
-
to: './dist/assets'
|
|
216
|
+
to: './dist/assets',
|
|
223
217
|
});
|
|
224
|
-
|
|
218
|
+
|
|
225
219
|
console.log('Build complete!');
|
|
226
220
|
}
|
|
227
221
|
|
|
@@ -238,16 +232,13 @@ async function buildMultipleEntries() {
|
|
|
238
232
|
const entries = [
|
|
239
233
|
{ from: './src/main.ts', to: './dist/main.js' },
|
|
240
234
|
{ from: './src/admin.ts', to: './dist/admin.js' },
|
|
241
|
-
{ from: './src/worker.ts', to: './dist/worker.js' }
|
|
235
|
+
{ from: './src/worker.ts', to: './dist/worker.js' },
|
|
242
236
|
];
|
|
243
|
-
|
|
237
|
+
|
|
244
238
|
for (const entry of entries) {
|
|
245
|
-
await bundler.build(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
entry.to,
|
|
249
|
-
{ bundler: 'esbuild' }
|
|
250
|
-
);
|
|
239
|
+
await bundler.build(process.cwd(), entry.from, entry.to, {
|
|
240
|
+
bundler: 'esbuild',
|
|
241
|
+
});
|
|
251
242
|
}
|
|
252
243
|
}
|
|
253
244
|
```
|
|
@@ -264,11 +255,11 @@ await bundler.build(
|
|
|
264
255
|
process.cwd(),
|
|
265
256
|
'./src/index.ts',
|
|
266
257
|
isDev ? './dist/dev/bundle.js' : './dist/prod/bundle.min.js',
|
|
267
|
-
{
|
|
268
|
-
bundler: isDev ? 'esbuild' : 'rolldown',
|
|
269
|
-
production: !isDev,
|
|
270
|
-
commonjs: false
|
|
271
|
-
}
|
|
258
|
+
{
|
|
259
|
+
bundler: isDev ? 'esbuild' : 'rolldown', // esbuild for speed in dev
|
|
260
|
+
production: !isDev, // minify in production
|
|
261
|
+
commonjs: false, // use ES modules
|
|
262
|
+
},
|
|
272
263
|
);
|
|
273
264
|
```
|
|
274
265
|
|
|
@@ -293,7 +284,7 @@ tsbundle works best with the following TypeScript configuration:
|
|
|
293
284
|
|
|
294
285
|
1. **Entry Points**: Keep your entry points in `ts_web/` for web bundles or `ts/` for library bundles
|
|
295
286
|
2. **Output Structure**: Use `dist_bundle/` for bundled files and `dist_serve/` for web-ready files
|
|
296
|
-
3. **Bundler Selection**:
|
|
287
|
+
3. **Bundler Selection**:
|
|
297
288
|
- Use `esbuild` for development (fastest)
|
|
298
289
|
- Use `rolldown` or `rspack` for production (better optimization)
|
|
299
290
|
4. **Assets**: Place static assets in the `assets/` directory
|
|
@@ -316,4 +307,4 @@ Registered at District court Bremen HRB 35230 HB, Germany
|
|
|
316
307
|
|
|
317
308
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
|
318
309
|
|
|
319
|
-
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.
|
|
310
|
+
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/readme.plan.md
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
**Command to reread CLAUDE.md**: `cat ~/.claude/CLAUDE.md`
|
|
4
4
|
|
|
5
5
|
## Objective
|
|
6
|
+
|
|
6
7
|
Add Rolldown as an optional bundler to tsbundle while keeping esbuild as the default bundler. This allows users to experiment with Rolldown using `--bundler=rolldown` flag.
|
|
7
8
|
|
|
8
9
|
## Current State
|
|
10
|
+
|
|
9
11
|
- tsbundle currently only uses esbuild despite having interfaces for multiple bundlers
|
|
10
12
|
- The bundler selection logic exists but always returns esbuild
|
|
11
13
|
- mod_rollup and mod_parcel directories exist but are empty
|
|
@@ -14,23 +16,26 @@ Add Rolldown as an optional bundler to tsbundle while keeping esbuild as the def
|
|
|
14
16
|
## Implementation Tasks
|
|
15
17
|
|
|
16
18
|
### Phase 1: Core Infrastructure
|
|
19
|
+
|
|
17
20
|
- [x] Update `ts/interfaces/index.ts` to include 'rolldown' in bundler union type
|
|
18
21
|
- [x] Fix `getBundlerPath()` in `ts/tsbundle.class.tsbundle.ts` to properly route bundlers
|
|
19
22
|
- [x] Remove hardcoded `bundler: 'esbuild'` from transportOptions (line 26)
|
|
20
23
|
- [x] Add rolldown dependency to package.json: `"rolldown": "^1.0.0-beta.18"`
|
|
21
24
|
|
|
22
25
|
### Phase 2: CLI Support
|
|
26
|
+
|
|
23
27
|
- [x] Check if `ts/tsbundle.cli.ts` already parses --bundler option
|
|
24
28
|
- [x] Ensure default bundler is 'esbuild' when not specified
|
|
25
29
|
- [x] Verify CLI passes bundler option correctly to TsBundle class
|
|
26
30
|
|
|
27
31
|
### Phase 3: Rolldown Module Implementation
|
|
32
|
+
|
|
28
33
|
- [x] Create `ts/mod_rolldown/` directory
|
|
29
34
|
- [x] Create `ts/mod_rolldown/plugins.ts`:
|
|
30
35
|
```typescript
|
|
31
36
|
export * from '../plugins.js';
|
|
32
37
|
import { rolldown } from 'rolldown';
|
|
33
|
-
export { rolldown }
|
|
38
|
+
export { rolldown };
|
|
34
39
|
```
|
|
35
40
|
- [x] Create `ts/mod_rolldown/index.child.ts` with:
|
|
36
41
|
- TsBundleProcess class
|
|
@@ -40,6 +45,7 @@ Add Rolldown as an optional bundler to tsbundle while keeping esbuild as the def
|
|
|
40
45
|
- run() function to read transportOptions and execute
|
|
41
46
|
|
|
42
47
|
### Phase 4: Feature Parity
|
|
48
|
+
|
|
43
49
|
- [x] Implement TypeScript compilation via rolldown
|
|
44
50
|
- [x] Ensure source map generation works
|
|
45
51
|
- [x] Support tsconfig path aliases
|
|
@@ -48,6 +54,7 @@ Add Rolldown as an optional bundler to tsbundle while keeping esbuild as the def
|
|
|
48
54
|
- [x] Handle bundle: true behavior
|
|
49
55
|
|
|
50
56
|
### Phase 5: Testing
|
|
57
|
+
|
|
51
58
|
- [x] Test default behavior (should use esbuild)
|
|
52
59
|
- [x] Test `--bundler=esbuild` explicit selection
|
|
53
60
|
- [x] Test `--bundler=rolldown` selection
|
|
@@ -57,19 +64,21 @@ Add Rolldown as an optional bundler to tsbundle while keeping esbuild as the def
|
|
|
57
64
|
## Technical Specifications
|
|
58
65
|
|
|
59
66
|
### Rolldown Configuration Mapping
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
67
|
+
|
|
68
|
+
| esbuild option | rolldown equivalent |
|
|
69
|
+
| ---------------- | ----------------------------------- |
|
|
70
|
+
| bundle: true | bundle: true |
|
|
71
|
+
| sourcemap: true | sourcemap: true |
|
|
72
|
+
| format: 'esm' | format: 'es' |
|
|
65
73
|
| target: 'es2022' | (use default, no direct equivalent) |
|
|
66
|
-
| minify: true
|
|
67
|
-
| entryPoints
|
|
68
|
-
| outfile
|
|
69
|
-
| tsconfig
|
|
70
|
-
| alias
|
|
74
|
+
| minify: true | minify: true |
|
|
75
|
+
| entryPoints | input |
|
|
76
|
+
| outfile | output.file |
|
|
77
|
+
| tsconfig | resolve.tsconfigFilename |
|
|
78
|
+
| alias | resolve.alias |
|
|
71
79
|
|
|
72
80
|
### CLI Usage
|
|
81
|
+
|
|
73
82
|
```bash
|
|
74
83
|
# Default (uses esbuild)
|
|
75
84
|
tsbundle
|
|
@@ -82,12 +91,14 @@ tsbundle --production --bundler=rolldown
|
|
|
82
91
|
```
|
|
83
92
|
|
|
84
93
|
## Risks and Mitigation
|
|
94
|
+
|
|
85
95
|
1. **Rolldown is beta** - Keep esbuild as default, mark rolldown as experimental
|
|
86
96
|
2. **API differences** - Abstract common interface, handle bundler-specific logic
|
|
87
97
|
3. **Missing features** - Document any limitations in README
|
|
88
98
|
4. **Breaking changes** - None, as esbuild remains default
|
|
89
99
|
|
|
90
100
|
## Success Criteria
|
|
101
|
+
|
|
91
102
|
- [x] Can build with esbuild (default behavior unchanged)
|
|
92
103
|
- [x] Can build with rolldown via --bundler flag
|
|
93
104
|
- [x] Both bundlers produce working ESM output
|
|
@@ -96,9 +107,11 @@ tsbundle --production --bundler=rolldown
|
|
|
96
107
|
- [ ] All existing tests pass
|
|
97
108
|
|
|
98
109
|
## Implementation Status
|
|
110
|
+
|
|
99
111
|
✅ **COMPLETED** - Rolldown has been successfully integrated as an optional bundler.
|
|
100
112
|
|
|
101
113
|
### Test Results:
|
|
114
|
+
|
|
102
115
|
- esbuild (default): Working correctly, 2.2K minified
|
|
103
116
|
- rolldown: Working correctly, 1.5K minified (better compression!)
|
|
104
117
|
- Both bundlers support all required features
|
|
@@ -106,7 +119,8 @@ tsbundle --production --bundler=rolldown
|
|
|
106
119
|
- Production and test modes work for both
|
|
107
120
|
|
|
108
121
|
## Future Considerations
|
|
122
|
+
|
|
109
123
|
- Once Rolldown reaches v1.0.0 stable, consider making it default
|
|
110
124
|
- Implement rollup and parcel modules using same pattern
|
|
111
125
|
- Add performance benchmarks comparing bundlers
|
|
112
|
-
- Consider adding --watch mode support
|
|
126
|
+
- Consider adding --watch mode support
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/interfaces/index.ts
CHANGED
|
@@ -2,13 +2,13 @@ export interface ICliOptions {
|
|
|
2
2
|
commonjs?: boolean;
|
|
3
3
|
skiplibcheck?: boolean;
|
|
4
4
|
production?: boolean;
|
|
5
|
-
bundler: 'esbuild' | 'rolldown' | 'rspack'
|
|
5
|
+
bundler: 'esbuild' | 'rolldown' | 'rspack';
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export interface IEnvTransportOptions {
|
|
9
9
|
cwd: string;
|
|
10
10
|
from: string;
|
|
11
11
|
to: string;
|
|
12
|
-
mode: 'test' | 'production'
|
|
13
|
-
argv: ICliOptions
|
|
12
|
+
mode: 'test' | 'production';
|
|
13
|
+
argv: ICliOptions;
|
|
14
14
|
}
|
package/ts/mod_assets/index.ts
CHANGED
|
@@ -3,38 +3,66 @@ import * as paths from '../paths.js';
|
|
|
3
3
|
|
|
4
4
|
export class AssetsHandler {
|
|
5
5
|
public defaultFromDirPath: string = plugins.path.join(paths.cwd, './assets');
|
|
6
|
-
public defaultToDirPath: string = plugins.path.join(
|
|
6
|
+
public defaultToDirPath: string = plugins.path.join(
|
|
7
|
+
paths.cwd,
|
|
8
|
+
'./dist_serve/assets',
|
|
9
|
+
);
|
|
7
10
|
|
|
8
11
|
public async ensureAssetsDir() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const dirExists = await plugins.fs
|
|
13
|
+
.directory(this.defaultFromDirPath)
|
|
14
|
+
.exists();
|
|
15
|
+
if (!dirExists) {
|
|
16
|
+
await plugins.fs.directory(this.defaultFromDirPath).create();
|
|
12
17
|
console.log(`created assets directory at ${this.defaultFromDirPath}`);
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
20
|
|
|
21
|
+
// copies the assets directory recursively
|
|
22
|
+
private async copyDirectoryRecursive(from: string, to: string) {
|
|
23
|
+
const entries = await plugins.fs.directory(from).recursive().list();
|
|
24
|
+
await plugins.fs.directory(to).create();
|
|
25
|
+
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const fromPath = plugins.path.join(from, entry.path);
|
|
28
|
+
const toPath = plugins.path.join(to, entry.path);
|
|
29
|
+
|
|
30
|
+
if (entry.isDirectory) {
|
|
31
|
+
await plugins.fs.directory(toPath).create();
|
|
32
|
+
} else {
|
|
33
|
+
const toDir = plugins.path.dirname(toPath);
|
|
34
|
+
await plugins.fs.directory(toDir).create();
|
|
35
|
+
await plugins.fs.file(fromPath).copy(toPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
16
40
|
// copies the html
|
|
17
|
-
public async processAssets(optionsArg?: {
|
|
18
|
-
from?: string;
|
|
19
|
-
to?: string;
|
|
20
|
-
}) {
|
|
41
|
+
public async processAssets(optionsArg?: { from?: string; to?: string }) {
|
|
21
42
|
// lets assemble the options
|
|
22
43
|
optionsArg = {
|
|
23
|
-
...
|
|
44
|
+
...{
|
|
24
45
|
from: this.defaultFromDirPath,
|
|
25
46
|
to: this.defaultToDirPath,
|
|
26
47
|
},
|
|
27
|
-
...(optionsArg || {})
|
|
28
|
-
}
|
|
29
|
-
await this.ensureAssetsDir()
|
|
30
|
-
optionsArg.from = plugins.smartpath.transform.toAbsolute(
|
|
31
|
-
|
|
48
|
+
...(optionsArg || {}),
|
|
49
|
+
};
|
|
50
|
+
await this.ensureAssetsDir();
|
|
51
|
+
optionsArg.from = plugins.smartpath.transform.toAbsolute(
|
|
52
|
+
optionsArg.from,
|
|
53
|
+
paths.cwd,
|
|
54
|
+
) as string;
|
|
55
|
+
optionsArg.to = plugins.smartpath.transform.toAbsolute(
|
|
56
|
+
optionsArg.to,
|
|
57
|
+
paths.cwd,
|
|
58
|
+
) as string;
|
|
32
59
|
|
|
33
|
-
// lets clean
|
|
34
|
-
await plugins.
|
|
60
|
+
// lets clean the target directory
|
|
61
|
+
const toExists = await plugins.fs.directory(optionsArg.to).exists();
|
|
62
|
+
if (toExists) {
|
|
63
|
+
await plugins.fs.directory(optionsArg.to).delete();
|
|
64
|
+
}
|
|
35
65
|
|
|
36
|
-
|
|
37
|
-
replaceTargetDir: true,
|
|
38
|
-
});
|
|
66
|
+
await this.copyDirectoryRecursive(optionsArg.from, optionsArg.to);
|
|
39
67
|
}
|
|
40
|
-
}
|
|
68
|
+
}
|
|
@@ -11,10 +11,16 @@ export class TsBundleProcess {
|
|
|
11
11
|
public async getAliases() {
|
|
12
12
|
try {
|
|
13
13
|
const aliasObject: Record<string, string> = {};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const tsconfigPath = plugins.path.join(paths.cwd, 'tsconfig.json');
|
|
15
|
+
const tsconfigContent = await plugins.fs
|
|
16
|
+
.file(tsconfigPath)
|
|
17
|
+
.encoding('utf8')
|
|
18
|
+
.read();
|
|
19
|
+
const localTsConfig = JSON.parse(tsconfigContent as string);
|
|
20
|
+
if (
|
|
21
|
+
localTsConfig.compilerOptions &&
|
|
22
|
+
localTsConfig.compilerOptions.paths
|
|
23
|
+
) {
|
|
18
24
|
for (const alias of Object.keys(localTsConfig.compilerOptions.paths)) {
|
|
19
25
|
const aliasPath = localTsConfig.compilerOptions.paths[alias][0];
|
|
20
26
|
aliasObject[alias] = aliasPath;
|
|
@@ -75,7 +81,7 @@ export class TsBundleProcess {
|
|
|
75
81
|
const run = async () => {
|
|
76
82
|
console.log('running spawned compilation process');
|
|
77
83
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
|
78
|
-
process.env.transportOptions
|
|
84
|
+
process.env.transportOptions,
|
|
79
85
|
);
|
|
80
86
|
console.log('=======> ESBUILD');
|
|
81
87
|
console.log(transportOptions);
|
|
@@ -85,16 +91,28 @@ const run = async () => {
|
|
|
85
91
|
if (transportOptions.mode === 'test') {
|
|
86
92
|
console.log('building for test:');
|
|
87
93
|
tsbundleProcessInstance.buildTest(
|
|
88
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
95
|
+
transportOptions.from,
|
|
96
|
+
process.cwd(),
|
|
97
|
+
),
|
|
98
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
99
|
+
transportOptions.to,
|
|
100
|
+
process.cwd(),
|
|
101
|
+
),
|
|
102
|
+
transportOptions.argv,
|
|
91
103
|
);
|
|
92
104
|
} else {
|
|
93
105
|
console.log('building for production:');
|
|
94
106
|
tsbundleProcessInstance.buildProduction(
|
|
95
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
108
|
+
transportOptions.from,
|
|
109
|
+
process.cwd(),
|
|
110
|
+
),
|
|
111
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
112
|
+
transportOptions.to,
|
|
113
|
+
process.cwd(),
|
|
114
|
+
),
|
|
115
|
+
transportOptions.argv,
|
|
98
116
|
);
|
|
99
117
|
}
|
|
100
118
|
};
|
package/ts/mod_html/index.ts
CHANGED
|
@@ -2,11 +2,17 @@ import * as plugins from './plugins.js';
|
|
|
2
2
|
import * as paths from '../paths.js';
|
|
3
3
|
|
|
4
4
|
export class HtmlHandler {
|
|
5
|
-
public defaultFromPath: string = plugins.path.join(
|
|
6
|
-
|
|
5
|
+
public defaultFromPath: string = plugins.path.join(
|
|
6
|
+
paths.htmlDir,
|
|
7
|
+
'index.html',
|
|
8
|
+
);
|
|
9
|
+
public defaultToPath: string = plugins.path.join(
|
|
10
|
+
paths.distServeDir,
|
|
11
|
+
'index.html',
|
|
12
|
+
);
|
|
7
13
|
|
|
8
14
|
public async checkIfExists() {
|
|
9
|
-
return plugins.
|
|
15
|
+
return await plugins.fs.file(this.defaultFromPath).exists();
|
|
10
16
|
}
|
|
11
17
|
|
|
12
18
|
// copies the html
|
|
@@ -16,19 +22,28 @@ export class HtmlHandler {
|
|
|
16
22
|
minify?: boolean;
|
|
17
23
|
}) {
|
|
18
24
|
optionsArg = {
|
|
19
|
-
...
|
|
25
|
+
...{
|
|
20
26
|
from: this.defaultFromPath,
|
|
21
27
|
to: this.defaultToPath,
|
|
22
28
|
minify: false,
|
|
23
29
|
},
|
|
24
|
-
...optionsArg
|
|
25
|
-
}
|
|
30
|
+
...optionsArg,
|
|
31
|
+
};
|
|
26
32
|
if (await this.checkIfExists()) {
|
|
27
33
|
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
|
|
28
34
|
}
|
|
29
|
-
optionsArg.from = plugins.smartpath.transform.toAbsolute(
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
optionsArg.from = plugins.smartpath.transform.toAbsolute(
|
|
36
|
+
optionsArg.from,
|
|
37
|
+
paths.cwd,
|
|
38
|
+
) as string;
|
|
39
|
+
optionsArg.to = plugins.smartpath.transform.toAbsolute(
|
|
40
|
+
optionsArg.to,
|
|
41
|
+
paths.cwd,
|
|
42
|
+
) as string;
|
|
43
|
+
let fileString = (await plugins.fs
|
|
44
|
+
.file(optionsArg.from)
|
|
45
|
+
.encoding('utf8')
|
|
46
|
+
.read()) as string;
|
|
32
47
|
if (optionsArg.minify) {
|
|
33
48
|
fileString = plugins.htmlMinifier.minify(fileString, {
|
|
34
49
|
minifyCSS: true,
|
|
@@ -41,7 +56,9 @@ export class HtmlHandler {
|
|
|
41
56
|
removeComments: true,
|
|
42
57
|
});
|
|
43
58
|
}
|
|
44
|
-
|
|
59
|
+
const toDir = plugins.path.dirname(optionsArg.to);
|
|
60
|
+
await plugins.fs.directory(toDir).create();
|
|
61
|
+
await plugins.fs.file(optionsArg.to).encoding('utf8').write(fileString);
|
|
45
62
|
console.log(`html processing succeeded!`);
|
|
46
63
|
}
|
|
47
64
|
}
|
package/ts/mod_html/plugins.ts
CHANGED
|
@@ -11,10 +11,16 @@ export class TsBundleProcess {
|
|
|
11
11
|
public async getAliases() {
|
|
12
12
|
try {
|
|
13
13
|
const aliasObject: Record<string, string> = {};
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const tsconfigPath = plugins.path.join(paths.cwd, 'tsconfig.json');
|
|
15
|
+
const tsconfigContent = await plugins.fs
|
|
16
|
+
.file(tsconfigPath)
|
|
17
|
+
.encoding('utf8')
|
|
18
|
+
.read();
|
|
19
|
+
const localTsConfig = JSON.parse(tsconfigContent as string);
|
|
20
|
+
if (
|
|
21
|
+
localTsConfig.compilerOptions &&
|
|
22
|
+
localTsConfig.compilerOptions.paths
|
|
23
|
+
) {
|
|
18
24
|
for (const alias of Object.keys(localTsConfig.compilerOptions.paths)) {
|
|
19
25
|
const aliasPath = localTsConfig.compilerOptions.paths[alias][0];
|
|
20
26
|
aliasObject[alias] = aliasPath;
|
|
@@ -38,10 +44,10 @@ export class TsBundleProcess {
|
|
|
38
44
|
tsconfigFilename: paths.tsconfigPath,
|
|
39
45
|
},
|
|
40
46
|
});
|
|
41
|
-
|
|
47
|
+
|
|
42
48
|
const outputDir = plugins.path.dirname(toArg);
|
|
43
49
|
const outputFilename = plugins.path.basename(toArg);
|
|
44
|
-
|
|
50
|
+
|
|
45
51
|
await result.write({
|
|
46
52
|
dir: outputDir,
|
|
47
53
|
entryFileNames: outputFilename,
|
|
@@ -59,21 +65,18 @@ export class TsBundleProcess {
|
|
|
59
65
|
console.log('rolldown specific:');
|
|
60
66
|
console.log(`from: ${fromArg}`);
|
|
61
67
|
console.log(`to: ${toArg}`);
|
|
62
|
-
|
|
68
|
+
|
|
63
69
|
const result = await plugins.rolldown({
|
|
64
70
|
input: fromArg,
|
|
65
71
|
resolve: {
|
|
66
72
|
alias: await this.getAliases(),
|
|
67
73
|
tsconfigFilename: paths.tsconfigPath,
|
|
68
74
|
},
|
|
69
|
-
experimental: {
|
|
70
|
-
enableComposingJsPlugins: true,
|
|
71
|
-
},
|
|
72
75
|
});
|
|
73
|
-
|
|
76
|
+
|
|
74
77
|
const outputDir = plugins.path.dirname(toArg);
|
|
75
78
|
const outputFilename = plugins.path.basename(toArg);
|
|
76
|
-
|
|
79
|
+
|
|
77
80
|
await result.write({
|
|
78
81
|
dir: outputDir,
|
|
79
82
|
entryFileNames: outputFilename,
|
|
@@ -88,7 +91,7 @@ export class TsBundleProcess {
|
|
|
88
91
|
const run = async () => {
|
|
89
92
|
console.log('running spawned compilation process');
|
|
90
93
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
|
91
|
-
process.env.transportOptions
|
|
94
|
+
process.env.transportOptions,
|
|
92
95
|
);
|
|
93
96
|
console.log('=======> ROLLDOWN');
|
|
94
97
|
console.log(transportOptions);
|
|
@@ -98,18 +101,30 @@ const run = async () => {
|
|
|
98
101
|
if (transportOptions.mode === 'test') {
|
|
99
102
|
console.log('building for test:');
|
|
100
103
|
await tsbundleProcessInstance.buildTest(
|
|
101
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
105
|
+
transportOptions.from,
|
|
106
|
+
process.cwd(),
|
|
107
|
+
),
|
|
108
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
109
|
+
transportOptions.to,
|
|
110
|
+
process.cwd(),
|
|
111
|
+
),
|
|
112
|
+
transportOptions.argv,
|
|
104
113
|
);
|
|
105
114
|
} else {
|
|
106
115
|
console.log('building for production:');
|
|
107
116
|
await tsbundleProcessInstance.buildProduction(
|
|
108
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
109
|
-
|
|
110
|
-
|
|
117
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
118
|
+
transportOptions.from,
|
|
119
|
+
process.cwd(),
|
|
120
|
+
),
|
|
121
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
122
|
+
transportOptions.to,
|
|
123
|
+
process.cwd(),
|
|
124
|
+
),
|
|
125
|
+
transportOptions.argv,
|
|
111
126
|
);
|
|
112
127
|
}
|
|
113
128
|
};
|
|
114
129
|
|
|
115
|
-
run();
|
|
130
|
+
run();
|