@git.zone/tsbundle 2.5.2 → 2.6.1
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/license +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
|
@@ -11,14 +11,23 @@ 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
|
// Convert TypeScript path to absolute path for rspack
|
|
21
|
-
aliasObject[alias.replace('/*', '')] = plugins.path.resolve(
|
|
27
|
+
aliasObject[alias.replace('/*', '')] = plugins.path.resolve(
|
|
28
|
+
paths.cwd,
|
|
29
|
+
aliasPath.replace('/*', ''),
|
|
30
|
+
);
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
return aliasObject;
|
|
@@ -34,7 +43,7 @@ export class TsBundleProcess {
|
|
|
34
43
|
const aliases = await this.getAliases();
|
|
35
44
|
const outputDir = plugins.path.dirname(toArg);
|
|
36
45
|
const outputFilename = plugins.path.basename(toArg);
|
|
37
|
-
|
|
46
|
+
|
|
38
47
|
const config = {
|
|
39
48
|
mode: 'development' as const,
|
|
40
49
|
entry: {
|
|
@@ -96,13 +105,15 @@ export class TsBundleProcess {
|
|
|
96
105
|
return;
|
|
97
106
|
}
|
|
98
107
|
|
|
99
|
-
console.log(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
console.log(
|
|
109
|
+
stats.toString({
|
|
110
|
+
colors: true,
|
|
111
|
+
modules: false,
|
|
112
|
+
children: false,
|
|
113
|
+
chunks: false,
|
|
114
|
+
chunkModules: false,
|
|
115
|
+
}),
|
|
116
|
+
);
|
|
106
117
|
|
|
107
118
|
resolve(undefined);
|
|
108
119
|
});
|
|
@@ -116,11 +127,11 @@ export class TsBundleProcess {
|
|
|
116
127
|
console.log('rspack specific:');
|
|
117
128
|
console.log(`from: ${fromArg}`);
|
|
118
129
|
console.log(`to: ${toArg}`);
|
|
119
|
-
|
|
130
|
+
|
|
120
131
|
const aliases = await this.getAliases();
|
|
121
132
|
const outputDir = plugins.path.dirname(toArg);
|
|
122
133
|
const outputFilename = plugins.path.basename(toArg);
|
|
123
|
-
|
|
134
|
+
|
|
124
135
|
const config = {
|
|
125
136
|
mode: 'production' as const,
|
|
126
137
|
entry: {
|
|
@@ -192,13 +203,15 @@ export class TsBundleProcess {
|
|
|
192
203
|
return;
|
|
193
204
|
}
|
|
194
205
|
|
|
195
|
-
console.log(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
206
|
+
console.log(
|
|
207
|
+
stats.toString({
|
|
208
|
+
colors: true,
|
|
209
|
+
modules: false,
|
|
210
|
+
children: false,
|
|
211
|
+
chunks: false,
|
|
212
|
+
chunkModules: false,
|
|
213
|
+
}),
|
|
214
|
+
);
|
|
202
215
|
|
|
203
216
|
resolve(undefined);
|
|
204
217
|
});
|
|
@@ -209,7 +222,7 @@ export class TsBundleProcess {
|
|
|
209
222
|
const run = async () => {
|
|
210
223
|
console.log('running spawned compilation process');
|
|
211
224
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
|
212
|
-
process.env.transportOptions
|
|
225
|
+
process.env.transportOptions,
|
|
213
226
|
);
|
|
214
227
|
console.log('=======> RSPACK');
|
|
215
228
|
console.log(transportOptions);
|
|
@@ -219,18 +232,30 @@ const run = async () => {
|
|
|
219
232
|
if (transportOptions.mode === 'test') {
|
|
220
233
|
console.log('building for test:');
|
|
221
234
|
await tsbundleProcessInstance.buildTest(
|
|
222
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
223
|
-
|
|
224
|
-
|
|
235
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
236
|
+
transportOptions.from,
|
|
237
|
+
process.cwd(),
|
|
238
|
+
),
|
|
239
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
240
|
+
transportOptions.to,
|
|
241
|
+
process.cwd(),
|
|
242
|
+
),
|
|
243
|
+
transportOptions.argv,
|
|
225
244
|
);
|
|
226
245
|
} else {
|
|
227
246
|
console.log('building for production:');
|
|
228
247
|
await tsbundleProcessInstance.buildProduction(
|
|
229
|
-
plugins.smartpath.transform.makeAbsolute(
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
249
|
+
transportOptions.from,
|
|
250
|
+
process.cwd(),
|
|
251
|
+
),
|
|
252
|
+
plugins.smartpath.transform.makeAbsolute(
|
|
253
|
+
transportOptions.to,
|
|
254
|
+
process.cwd(),
|
|
255
|
+
),
|
|
256
|
+
transportOptions.argv,
|
|
232
257
|
);
|
|
233
258
|
}
|
|
234
259
|
};
|
|
235
260
|
|
|
236
|
-
run();
|
|
261
|
+
run();
|
package/ts/mod_rspack/plugins.ts
CHANGED
package/ts/paths.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as plugins from './plugins.js';
|
|
|
3
3
|
export const cwd = process.cwd();
|
|
4
4
|
export const packageDir = plugins.path.join(
|
|
5
5
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
|
6
|
-
'../'
|
|
6
|
+
'../',
|
|
7
7
|
);
|
|
8
8
|
export const htmlDir = plugins.path.join(cwd, './html');
|
|
9
9
|
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
package/ts/plugins.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { path };
|
|
|
5
5
|
|
|
6
6
|
// pushrocks scope
|
|
7
7
|
import * as smartcli from '@push.rocks/smartcli';
|
|
8
|
-
import * as
|
|
8
|
+
import * as smartfs from '@push.rocks/smartfs';
|
|
9
9
|
import * as smartlog from '@push.rocks/smartlog';
|
|
10
10
|
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
|
11
11
|
import * as smartpath from '@push.rocks/smartpath';
|
|
@@ -14,10 +14,13 @@ import * as smartspawn from '@push.rocks/smartspawn';
|
|
|
14
14
|
|
|
15
15
|
export {
|
|
16
16
|
smartcli,
|
|
17
|
-
|
|
17
|
+
smartfs,
|
|
18
18
|
smartlog,
|
|
19
19
|
smartlogDestinationLocal,
|
|
20
20
|
smartpath,
|
|
21
21
|
smartpromise,
|
|
22
22
|
smartspawn,
|
|
23
23
|
};
|
|
24
|
+
|
|
25
|
+
// Create a shared SmartFs instance using Node provider
|
|
26
|
+
export const fs = new smartfs.SmartFs(new smartfs.SmartFsProviderNode());
|
|
@@ -3,12 +3,11 @@ import * as interfaces from './interfaces/index.js';
|
|
|
3
3
|
import { logger } from './tsbundle.logging.js';
|
|
4
4
|
|
|
5
5
|
export class TsBundle {
|
|
6
|
-
|
|
7
6
|
public async build(
|
|
8
7
|
cwdArg: string,
|
|
9
8
|
fromArg: string = './ts_web/index.ts',
|
|
10
9
|
toArg: string = './dist_bundle/bundle.js',
|
|
11
|
-
argvArg: interfaces.ICliOptions
|
|
10
|
+
argvArg: interfaces.ICliOptions,
|
|
12
11
|
) {
|
|
13
12
|
const done = plugins.smartpromise.defer();
|
|
14
13
|
const getBundlerPath = () => {
|
|
@@ -21,20 +20,20 @@ export class TsBundle {
|
|
|
21
20
|
default:
|
|
22
21
|
return './mod_esbuild/index.child.js';
|
|
23
22
|
}
|
|
24
|
-
}
|
|
23
|
+
};
|
|
25
24
|
const transportOptions: interfaces.IEnvTransportOptions = {
|
|
26
25
|
cwd: cwdArg,
|
|
27
26
|
from: fromArg,
|
|
28
27
|
to: toArg,
|
|
29
28
|
mode: argvArg && argvArg.production ? 'production' : 'test',
|
|
30
|
-
argv:
|
|
31
|
-
...argvArg
|
|
32
|
-
}
|
|
33
|
-
}
|
|
29
|
+
argv: {
|
|
30
|
+
...argvArg,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
34
33
|
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
|
35
34
|
plugins.path.join(
|
|
36
35
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
|
37
|
-
getBundlerPath()
|
|
36
|
+
getBundlerPath(),
|
|
38
37
|
),
|
|
39
38
|
[],
|
|
40
39
|
{
|
|
@@ -42,7 +41,7 @@ export class TsBundle {
|
|
|
42
41
|
...process.env,
|
|
43
42
|
transportOptions: JSON.stringify(transportOptions),
|
|
44
43
|
},
|
|
45
|
-
}
|
|
44
|
+
},
|
|
46
45
|
);
|
|
47
46
|
const childProcess = await threadsimple.start();
|
|
48
47
|
childProcess.on('exit', (status) => {
|
package/ts/tsbundle.cli.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const runCli = async () => {
|
|
|
18
18
|
process.cwd(),
|
|
19
19
|
'./ts_web/index.ts',
|
|
20
20
|
'./dist_bundle/bundle.js',
|
|
21
|
-
argvArg
|
|
21
|
+
argvArg,
|
|
22
22
|
);
|
|
23
23
|
});
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ export const runCli = async () => {
|
|
|
29
29
|
process.cwd(),
|
|
30
30
|
'./ts/index.ts',
|
|
31
31
|
'./dist_bundle/bundle.js',
|
|
32
|
-
argvArg
|
|
32
|
+
argvArg,
|
|
33
33
|
);
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -42,9 +42,18 @@ export const runCli = async () => {
|
|
|
42
42
|
process.cwd(),
|
|
43
43
|
'./ts_web/index.ts',
|
|
44
44
|
'./dist_serve/bundle.js',
|
|
45
|
-
argvArg
|
|
45
|
+
argvArg,
|
|
46
46
|
);
|
|
47
|
-
const
|
|
47
|
+
const htmlDirPath = plugins.path.join(process.cwd(), './html');
|
|
48
|
+
let htmlFiles: string[] = [];
|
|
49
|
+
const htmlDirExists = await plugins.fs.directory(htmlDirPath).exists();
|
|
50
|
+
if (htmlDirExists) {
|
|
51
|
+
const entries = await plugins.fs
|
|
52
|
+
.directory(htmlDirPath)
|
|
53
|
+
.filter(/\.html$/)
|
|
54
|
+
.list();
|
|
55
|
+
htmlFiles = entries.map((entry) => entry.path);
|
|
56
|
+
}
|
|
48
57
|
for (const htmlFile of htmlFiles) {
|
|
49
58
|
await htmlHandler.processHtml({
|
|
50
59
|
from: `./html/${htmlFile}`,
|
package/ts/tsbundle.logging.ts
CHANGED
|
@@ -12,4 +12,6 @@ export const logger = new plugins.smartlog.Smartlog({
|
|
|
12
12
|
minimumLogLevel: 'silly',
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
logger.addLogDestination(
|
|
15
|
+
logger.addLogDestination(
|
|
16
|
+
new plugins.smartlogDestinationLocal.DestinationLocal(),
|
|
17
|
+
);
|