@simplysm/sd-cli 12.5.23 → 12.5.26
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/entry/SdCliCordova.js +6 -6
- package/dist/entry/SdCliCordova.js.map +1 -1
- package/dist/entry/SdCliElectron.js +2 -2
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.js +5 -7
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.js +4 -4
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +3 -10
- package/dist/pkg-builders/SdMultiBuildRunner.js +132 -116
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +6 -5
- package/dist/pkg-builders/client/SdClientBuildRunner.js +16 -8
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdNgBundler.js +1 -0
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
- package/dist/pkg-builders/client/createSdNgPlugin.js +3 -3
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +6 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +25 -26
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -3
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -11
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +5 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.js +32 -29
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -1
- package/dist/pkg-builders/server/createSdServerPlugin.js +3 -3
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -1
- package/dist/ts-builder/SdTsCompiler.js +172 -160
- package/dist/ts-builder/SdTsCompiler.js.map +1 -1
- package/dist/types/build-runner.type.d.ts +7 -0
- package/dist/types/build-runner.type.js +2 -0
- package/dist/types/build-runner.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +14 -0
- package/dist/workers/build-runner-worker.js +49 -0
- package/dist/workers/build-runner-worker.js.map +1 -0
- package/package.json +10 -10
- package/src/entry/SdCliCordova.ts +6 -5
- package/src/entry/SdCliElectron.ts +2 -2
- package/src/entry/SdCliLocalUpdate.ts +7 -7
- package/src/entry/SdCliProject.ts +4 -4
- package/src/index.ts +1 -1
- package/src/pkg-builders/SdMultiBuildRunner.ts +122 -120
- package/src/pkg-builders/client/SdClientBuildRunner.ts +26 -22
- package/src/pkg-builders/client/SdNgBundler.ts +1 -0
- package/src/pkg-builders/client/createSdNgPlugin.ts +3 -3
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +39 -26
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +12 -13
- package/src/pkg-builders/server/SdServerBuildRunner.ts +44 -29
- package/src/pkg-builders/server/createSdServerPlugin.ts +3 -3
- package/src/ts-builder/SdTsCompiler.ts +220 -216
- package/src/types/build-runner.type.ts +8 -0
- package/src/types/workers.type.ts +13 -0
- package/src/workers/build-runner-worker.ts +56 -0
- package/tsconfig.json +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +0 -9
- package/dist/ts-builder/SdTsCompileWorker.js +0 -16
- package/dist/ts-builder/SdTsCompileWorker.js.map +0 -1
- package/dist/workers/compile-worker.js +0 -27
- package/dist/workers/compile-worker.js.map +0 -1
- package/src/ts-builder/SdTsCompileWorker.ts +0 -21
- package/src/workers/compile-worker.ts +0 -31
- /package/dist/workers/{compile-worker.d.ts → build-runner-worker.d.ts} +0 -0
|
@@ -52,6 +52,8 @@ export class SdTsCompiler {
|
|
|
52
52
|
|
|
53
53
|
readonly #lintWorker = new SdWorker<TSdLintWorkerType>(import.meta.resolve("../workers/lint-worker"));
|
|
54
54
|
|
|
55
|
+
#perf!: SdCliPerformanceTimer;
|
|
56
|
+
|
|
55
57
|
constructor(opt: SdTsCompilerOptions) {
|
|
56
58
|
this.#pkgPath = opt.pkgPath;
|
|
57
59
|
this.#globalStyleFilePath = opt.globalStyleFilePath;
|
|
@@ -169,48 +171,71 @@ export class SdTsCompiler {
|
|
|
169
171
|
// resourceFile: 외부 리소스 파일 (styleUrls로 입력하지 않고 styles에 직접 입력한 경우 null)
|
|
170
172
|
// referencedFiles: import한 외부 scss 파일 혹은 woff파일등 외부 파일
|
|
171
173
|
|
|
172
|
-
this.#debug(
|
|
174
|
+
// this.#debug(`bundle stylesheet...(${containingFile}, ${resourceFile})`);
|
|
175
|
+
|
|
176
|
+
return await this.#perf.run("bundle style", async () => {
|
|
177
|
+
const stylesheetResult =
|
|
178
|
+
resourceFile != null
|
|
179
|
+
? await this.#stylesheetBundler!.bundleFile(resourceFile)
|
|
180
|
+
: await this.#stylesheetBundler!.bundleInline(data, containingFile, "scss");
|
|
173
181
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
if (stylesheetResult.referencedFiles) {
|
|
183
|
+
for (const referencedFile of stylesheetResult.referencedFiles) {
|
|
184
|
+
const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(
|
|
185
|
+
PathUtil.norm(referencedFile),
|
|
186
|
+
new Set<TNormPath>(),
|
|
187
|
+
);
|
|
188
|
+
depCacheSet.add(resourceFile ?? containingFile);
|
|
189
|
+
}
|
|
178
190
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(
|
|
182
|
-
PathUtil.norm(referencedFile),
|
|
183
|
-
new Set<TNormPath>(),
|
|
191
|
+
this.#watchFileSet.adds(
|
|
192
|
+
...Array.from(stylesheetResult.referencedFiles.values()).map((item) => PathUtil.norm(item)),
|
|
184
193
|
);
|
|
185
|
-
depCacheSet.add(resourceFile ?? containingFile);
|
|
186
194
|
}
|
|
187
195
|
|
|
188
|
-
this.#
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
196
|
+
this.#stylesheetBundlingResultMap.set(PathUtil.norm(resourceFile ?? containingFile), {
|
|
197
|
+
outputFiles: stylesheetResult.outputFiles,
|
|
198
|
+
metafile: stylesheetResult.metafile,
|
|
199
|
+
errors: stylesheetResult.errors,
|
|
200
|
+
warnings: stylesheetResult.warnings,
|
|
201
|
+
});
|
|
192
202
|
|
|
193
|
-
|
|
194
|
-
outputFiles: stylesheetResult.outputFiles,
|
|
195
|
-
metafile: stylesheetResult.metafile,
|
|
196
|
-
errors: stylesheetResult.errors,
|
|
197
|
-
warnings: stylesheetResult.warnings,
|
|
203
|
+
return stylesheetResult.contents;
|
|
198
204
|
});
|
|
199
|
-
|
|
200
|
-
return stylesheetResult.contents;
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
async compileAsync(modifiedFileSet: Set<TNormPath>): Promise<ISdTsCompilerResult> {
|
|
204
|
-
|
|
208
|
+
this.#perf = new SdCliPerformanceTimer("esbuild compile");
|
|
205
209
|
|
|
206
210
|
this.#modifiedFileSet = new Set(modifiedFileSet);
|
|
207
211
|
this.#affectedFileSet = new Set<TNormPath>();
|
|
208
212
|
|
|
209
|
-
|
|
213
|
+
const prepareResult = await this.#prepareAsync();
|
|
214
|
+
|
|
215
|
+
const [buildResult, lintResults] = await Promise.all([this.#buildAsync(), this.#lintAsync()]);
|
|
216
|
+
|
|
217
|
+
this.#debug(`build completed`, this.#perf.toString());
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
messages: [
|
|
221
|
+
...prepareResult.messages,
|
|
222
|
+
...SdCliConvertMessageUtil.convertToBuildMessagesFromTsDiag(buildResult.diagnostics),
|
|
223
|
+
...SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults),
|
|
224
|
+
],
|
|
225
|
+
watchFileSet: this.#watchFileSet,
|
|
226
|
+
affectedFileSet: this.#affectedFileSet,
|
|
227
|
+
stylesheetBundlingResultMap: this.#stylesheetBundlingResultMap,
|
|
228
|
+
emittedFilesCacheMap: this.#emittedFilesCacheMap,
|
|
229
|
+
emitFileSet: buildResult.emitFileSet,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async #prepareAsync() {
|
|
234
|
+
if (this.#modifiedFileSet.size !== 0) {
|
|
210
235
|
this.#debug(`get affected (old deps & old res deps)...`);
|
|
211
236
|
|
|
212
|
-
perf.run("get affected", () => {
|
|
213
|
-
for (const modifiedFile of modifiedFileSet) {
|
|
237
|
+
this.#perf.run("get affected", () => {
|
|
238
|
+
for (const modifiedFile of this.#modifiedFileSet) {
|
|
214
239
|
this.#affectedFileSet.add(modifiedFile);
|
|
215
240
|
this.#affectedFileSet.adds(...(this.#revDependencyCacheMap.get(modifiedFile) ?? []));
|
|
216
241
|
this.#affectedFileSet.adds(...(this.#resourceDependencyCacheMap.get(modifiedFile) ?? []));
|
|
@@ -221,8 +246,8 @@ export class SdTsCompiler {
|
|
|
221
246
|
|
|
222
247
|
this.#debug(`invalidate & clear cache...`);
|
|
223
248
|
|
|
224
|
-
perf.run("invalidate & clear cache", () => {
|
|
225
|
-
this.#stylesheetBundler?.invalidate(modifiedFileSet);
|
|
249
|
+
this.#perf.run("invalidate & clear cache", () => {
|
|
250
|
+
this.#stylesheetBundler?.invalidate(this.#modifiedFileSet);
|
|
226
251
|
|
|
227
252
|
for (const affectedFile of this.#affectedFileSet) {
|
|
228
253
|
this.#sourceFileCacheMap.delete(affectedFile);
|
|
@@ -237,7 +262,7 @@ export class SdTsCompiler {
|
|
|
237
262
|
|
|
238
263
|
this.#debug(`create program...`);
|
|
239
264
|
|
|
240
|
-
perf.run("create program", () => {
|
|
265
|
+
this.#perf.run("create program", () => {
|
|
241
266
|
if (this.#isForAngular) {
|
|
242
267
|
this.#ngProgram = new NgtscProgram(
|
|
243
268
|
this.#parsedTsconfig.fileNames,
|
|
@@ -257,7 +282,7 @@ export class SdTsCompiler {
|
|
|
257
282
|
});
|
|
258
283
|
|
|
259
284
|
if (this.#ngProgram) {
|
|
260
|
-
await perf.run("ng analyze", async () => {
|
|
285
|
+
await this.#perf.run("ng analyze", async () => {
|
|
261
286
|
await this.#ngProgram!.compiler.analyzeAsync();
|
|
262
287
|
});
|
|
263
288
|
}
|
|
@@ -281,7 +306,7 @@ export class SdTsCompiler {
|
|
|
281
306
|
|
|
282
307
|
const messages: ISdBuildMessage[] = [];
|
|
283
308
|
|
|
284
|
-
perf.run("get new deps", () => {
|
|
309
|
+
this.#perf.run("get new deps", () => {
|
|
285
310
|
const depMap = new Map<
|
|
286
311
|
TNormPath,
|
|
287
312
|
{
|
|
@@ -363,10 +388,10 @@ export class SdTsCompiler {
|
|
|
363
388
|
}
|
|
364
389
|
});
|
|
365
390
|
|
|
366
|
-
if (modifiedFileSet.size === 0) {
|
|
391
|
+
if (this.#modifiedFileSet.size === 0) {
|
|
367
392
|
this.#debug(`get affected (init)...`);
|
|
368
393
|
|
|
369
|
-
perf.run("get affected (init)", () => {
|
|
394
|
+
this.#perf.run("get affected (init)", () => {
|
|
370
395
|
for (const sf of sourceFileSet) {
|
|
371
396
|
if (!this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(sf.fileName, scopePath))) {
|
|
372
397
|
continue;
|
|
@@ -411,225 +436,204 @@ export class SdTsCompiler {
|
|
|
411
436
|
}
|
|
412
437
|
}
|
|
413
438
|
|
|
414
|
-
|
|
439
|
+
return {
|
|
440
|
+
messages,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
415
443
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
this.#debug(`get diagnostics...`);
|
|
444
|
+
async #lintAsync() {
|
|
445
|
+
return await this.#lintWorker.run("lint", [
|
|
446
|
+
{
|
|
447
|
+
cwd: this.#pkgPath,
|
|
448
|
+
fileSet: this.#affectedFileSet,
|
|
449
|
+
},
|
|
450
|
+
]);
|
|
451
|
+
}
|
|
425
452
|
|
|
426
|
-
|
|
453
|
+
async #buildAsync() {
|
|
454
|
+
const emitFileSet = new Set<TNormPath>();
|
|
455
|
+
const diagnostics: ts.Diagnostic[] = [];
|
|
427
456
|
|
|
428
|
-
|
|
429
|
-
diagnostics.push(
|
|
430
|
-
...this.#program!.getConfigFileParsingDiagnostics(),
|
|
431
|
-
...this.#program!.getOptionsDiagnostics(),
|
|
432
|
-
...this.#program!.getGlobalDiagnostics(),
|
|
433
|
-
);
|
|
457
|
+
this.#debug(`get diagnostics...`);
|
|
434
458
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
459
|
+
this.#perf.run("get program diagnostics", () => {
|
|
460
|
+
diagnostics.push(
|
|
461
|
+
...this.#program!.getConfigFileParsingDiagnostics(),
|
|
462
|
+
...this.#program!.getOptionsDiagnostics(),
|
|
463
|
+
...this.#program!.getGlobalDiagnostics(),
|
|
464
|
+
);
|
|
439
465
|
|
|
440
|
-
|
|
466
|
+
if (this.#ngProgram) {
|
|
467
|
+
diagnostics.push(...this.#ngProgram.compiler.getOptionDiagnostics());
|
|
468
|
+
}
|
|
469
|
+
});
|
|
441
470
|
|
|
442
|
-
|
|
443
|
-
if (!PathUtil.isChildPath(affectedFile, this.#pkgPath)) {
|
|
444
|
-
continue;
|
|
445
|
-
}
|
|
471
|
+
this.#debug(`get diagnostics of files...`);
|
|
446
472
|
|
|
447
|
-
|
|
473
|
+
for (const affectedFile of this.#affectedFileSet) {
|
|
474
|
+
if (!PathUtil.isChildPath(affectedFile, this.#pkgPath)) {
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
448
477
|
|
|
449
|
-
|
|
450
|
-
!affectedSourceFile ||
|
|
451
|
-
(this.#ngProgram && this.#ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))
|
|
452
|
-
) {
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
478
|
+
const affectedSourceFile = this.#program!.getSourceFile(affectedFile);
|
|
455
479
|
|
|
456
|
-
|
|
480
|
+
if (
|
|
481
|
+
!affectedSourceFile ||
|
|
482
|
+
(this.#ngProgram && this.#ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))
|
|
483
|
+
) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
457
486
|
|
|
458
|
-
|
|
459
|
-
diagnostics.push(
|
|
460
|
-
...this.#program!.getSyntacticDiagnostics(affectedSourceFile),
|
|
461
|
-
...this.#program!.getSemanticDiagnostics(affectedSourceFile),
|
|
462
|
-
);
|
|
463
|
-
});
|
|
487
|
+
// this.#debug(`get diagnostics of file ${affectedFile}...`);
|
|
464
488
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
489
|
+
this.#perf.run("get file diagnostics", () => {
|
|
490
|
+
diagnostics.push(
|
|
491
|
+
...this.#program!.getSyntacticDiagnostics(affectedSourceFile),
|
|
492
|
+
...this.#program!.getSemanticDiagnostics(affectedSourceFile),
|
|
493
|
+
);
|
|
494
|
+
});
|
|
470
495
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
496
|
+
if (this.#ngProgram) {
|
|
497
|
+
this.#perf.run("get file diagnostics: ng", () => {
|
|
498
|
+
if (affectedSourceFile.isDeclarationFile) {
|
|
499
|
+
return;
|
|
475
500
|
}
|
|
476
|
-
}
|
|
477
501
|
|
|
478
|
-
|
|
479
|
-
|
|
502
|
+
diagnostics.push(
|
|
503
|
+
...this.#ngProgram!.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram),
|
|
504
|
+
);
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
480
508
|
|
|
481
|
-
|
|
509
|
+
this.#perf.run("emit", () => {
|
|
510
|
+
this.#debug(`prepare emit...`);
|
|
482
511
|
|
|
483
|
-
|
|
484
|
-
transformers = {
|
|
485
|
-
...transformers,
|
|
486
|
-
...this.#ngProgram.compiler.prepareEmit().transformers,
|
|
487
|
-
};
|
|
488
|
-
(transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
|
|
489
|
-
}
|
|
490
|
-
// (transformers.before ??= []).push(transformKeys(this.#program));
|
|
512
|
+
let transformers: ts.CustomTransformers = {};
|
|
491
513
|
|
|
492
|
-
|
|
514
|
+
if (this.#ngProgram) {
|
|
515
|
+
transformers = {
|
|
516
|
+
...transformers,
|
|
517
|
+
...this.#ngProgram.compiler.prepareEmit().transformers,
|
|
518
|
+
};
|
|
519
|
+
(transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
|
|
520
|
+
}
|
|
521
|
+
// (transformers.before ??= []).push(transformKeys(this.#program));
|
|
493
522
|
|
|
494
|
-
|
|
495
|
-
// 비교해보니, 딱히 getSourceFiles라서 더 느려지는것 같지는 않음
|
|
496
|
-
// 그래도 affected로 다시 테스트
|
|
497
|
-
for (const affectedFile of this.#affectedFileSet) {
|
|
498
|
-
if (this.#emittedFilesCacheMap.has(affectedFile)) {
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
523
|
+
this.#debug(`emit for files...`);
|
|
501
524
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
525
|
+
// affected에 새로 추가된 파일은 포함되지 않는 현상이 있어 sourceFileSet으로 바꿈
|
|
526
|
+
// 비교해보니, 딱히 getSourceFiles라서 더 느려지는것 같지는 않음
|
|
527
|
+
// 그래도 affected로 다시 테스트
|
|
528
|
+
for (const affectedFile of this.#affectedFileSet) {
|
|
529
|
+
if (this.#emittedFilesCacheMap.has(affectedFile)) {
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
506
532
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
533
|
+
const sf = this.#program!.getSourceFile(affectedFile);
|
|
534
|
+
if (!sf) {
|
|
535
|
+
continue;
|
|
536
|
+
}
|
|
510
537
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
538
|
+
if (sf.isDeclarationFile) {
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
514
541
|
|
|
515
|
-
|
|
516
|
-
|
|
542
|
+
if (this.#ngProgram?.compiler.ignoreForEmit.has(sf)) {
|
|
543
|
+
continue;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
if (this.#ngProgram?.compiler.incrementalCompilation.safeToSkipEmit(sf)) {
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// esbuild를 통해 bundle로 묶어야 하는놈들은 모든 output이 있어야 함.
|
|
551
|
+
if (!this.#isForBundle) {
|
|
552
|
+
if (!PathUtil.isChildPath(sf.fileName, this.#pkgPath)) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
this.#program!.emit(
|
|
558
|
+
sf,
|
|
559
|
+
(fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
|
|
560
|
+
if (!sourceFiles || sourceFiles.length === 0) {
|
|
561
|
+
this.#compilerHost.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
|
|
562
|
+
return;
|
|
517
563
|
}
|
|
518
564
|
|
|
519
|
-
|
|
520
|
-
if (
|
|
521
|
-
if (
|
|
522
|
-
|
|
565
|
+
const sourceFile = ts.getOriginalNode(sourceFiles[0], ts.isSourceFile);
|
|
566
|
+
if (this.#ngProgram) {
|
|
567
|
+
if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) {
|
|
568
|
+
return;
|
|
523
569
|
}
|
|
570
|
+
this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
524
571
|
}
|
|
525
572
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) {
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(
|
|
544
|
-
PathUtil.norm(sourceFile.fileName),
|
|
545
|
-
[],
|
|
573
|
+
const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(PathUtil.norm(sourceFile.fileName), []);
|
|
574
|
+
|
|
575
|
+
if (PathUtil.isChildPath(sourceFile.fileName, this.#pkgPath)) {
|
|
576
|
+
let realFilePath = PathUtil.norm(fileName);
|
|
577
|
+
let realText = text;
|
|
578
|
+
if (
|
|
579
|
+
PathUtil.isChildPath(realFilePath, path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"))
|
|
580
|
+
) {
|
|
581
|
+
realFilePath = PathUtil.norm(
|
|
582
|
+
this.#distPath,
|
|
583
|
+
path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
|
|
546
584
|
);
|
|
547
585
|
|
|
548
|
-
if (
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
realFilePath,
|
|
554
|
-
path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"),
|
|
555
|
-
)
|
|
556
|
-
) {
|
|
557
|
-
realFilePath = PathUtil.norm(
|
|
558
|
-
this.#distPath,
|
|
559
|
-
path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
|
|
560
|
-
);
|
|
561
|
-
|
|
562
|
-
if (fileName.endsWith(".js.map")) {
|
|
563
|
-
const sourceMapContents = JSON.parse(realText);
|
|
564
|
-
// remove "../../"
|
|
565
|
-
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
566
|
-
realText = JSON.stringify(sourceMapContents);
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
emitFileInfoCaches.push({
|
|
571
|
-
outAbsPath: realFilePath,
|
|
572
|
-
text: realText,
|
|
573
|
-
});
|
|
574
|
-
} else {
|
|
575
|
-
emitFileInfoCaches.push({ text });
|
|
586
|
+
if (fileName.endsWith(".js.map")) {
|
|
587
|
+
const sourceMapContents = JSON.parse(realText);
|
|
588
|
+
// remove "../../"
|
|
589
|
+
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
590
|
+
realText = JSON.stringify(sourceMapContents);
|
|
576
591
|
}
|
|
592
|
+
}
|
|
577
593
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
//-- global style
|
|
588
|
-
if (
|
|
589
|
-
this.#globalStyleFilePath != null &&
|
|
590
|
-
FsUtil.exists(this.#globalStyleFilePath) &&
|
|
591
|
-
!this.#emittedFilesCacheMap.has(this.#globalStyleFilePath)
|
|
592
|
-
) {
|
|
593
|
-
this.#debug(`bundle global style...`);
|
|
594
|
-
|
|
595
|
-
await perf.run("bundle global style", async () => {
|
|
596
|
-
const data = FsUtil.readFile(this.#globalStyleFilePath!);
|
|
597
|
-
const contents = await this.#bundleStylesheetAsync(
|
|
598
|
-
data,
|
|
599
|
-
this.#globalStyleFilePath!,
|
|
600
|
-
this.#globalStyleFilePath,
|
|
601
|
-
);
|
|
602
|
-
const emitFileInfos = this.#emittedFilesCacheMap.getOrCreate(this.#globalStyleFilePath!, []);
|
|
603
|
-
emitFileInfos.push({
|
|
604
|
-
outAbsPath: PathUtil.norm(
|
|
605
|
-
this.#pkgPath,
|
|
606
|
-
path
|
|
607
|
-
.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!)
|
|
608
|
-
.replace(/\.scss$/, ".css"),
|
|
609
|
-
),
|
|
610
|
-
text: contents,
|
|
611
|
-
});
|
|
612
|
-
emitFileSet.add(this.#globalStyleFilePath!);
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
this.#debug(`build completed`, perf.toString());
|
|
617
|
-
|
|
618
|
-
//-- result
|
|
594
|
+
emitFileInfoCaches.push({
|
|
595
|
+
outAbsPath: realFilePath,
|
|
596
|
+
text: realText,
|
|
597
|
+
});
|
|
598
|
+
} else {
|
|
599
|
+
emitFileInfoCaches.push({ text });
|
|
600
|
+
}
|
|
619
601
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
602
|
+
emitFileSet.add(PathUtil.norm(sourceFile.fileName));
|
|
603
|
+
},
|
|
604
|
+
undefined,
|
|
605
|
+
undefined,
|
|
606
|
+
transformers,
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
});
|
|
623
610
|
|
|
624
|
-
|
|
611
|
+
//-- global style
|
|
612
|
+
if (
|
|
613
|
+
this.#globalStyleFilePath != null &&
|
|
614
|
+
FsUtil.exists(this.#globalStyleFilePath) &&
|
|
615
|
+
!this.#emittedFilesCacheMap.has(this.#globalStyleFilePath)
|
|
616
|
+
) {
|
|
617
|
+
this.#debug(`bundle global style...`);
|
|
618
|
+
|
|
619
|
+
await this.#perf.run("bundle global style", async () => {
|
|
620
|
+
const data = FsUtil.readFile(this.#globalStyleFilePath!);
|
|
621
|
+
const contents = await this.#bundleStylesheetAsync(data, this.#globalStyleFilePath!, this.#globalStyleFilePath);
|
|
622
|
+
const emitFileInfos = this.#emittedFilesCacheMap.getOrCreate(this.#globalStyleFilePath!, []);
|
|
623
|
+
emitFileInfos.push({
|
|
624
|
+
outAbsPath: PathUtil.norm(
|
|
625
|
+
this.#pkgPath,
|
|
626
|
+
path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!).replace(/\.scss$/, ".css"),
|
|
627
|
+
),
|
|
628
|
+
text: contents,
|
|
629
|
+
});
|
|
630
|
+
emitFileSet.add(this.#globalStyleFilePath!);
|
|
631
|
+
});
|
|
632
|
+
}
|
|
625
633
|
|
|
626
634
|
return {
|
|
627
|
-
messages,
|
|
628
|
-
watchFileSet: this.#watchFileSet,
|
|
629
|
-
affectedFileSet: this.#affectedFileSet,
|
|
630
|
-
stylesheetBundlingResultMap: this.#stylesheetBundlingResultMap,
|
|
631
|
-
emittedFilesCacheMap: this.#emittedFilesCacheMap,
|
|
632
635
|
emitFileSet,
|
|
636
|
+
diagnostics,
|
|
633
637
|
};
|
|
634
638
|
}
|
|
635
639
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ESLint } from "eslint";
|
|
2
2
|
import { ISdTsCompilerResult, SdTsCompilerOptions } from "./ts-compiler.type";
|
|
3
3
|
import { TNormPath } from "@simplysm/sd-core-node";
|
|
4
|
+
import { ISdBuildRunnerWorkerRequest } from "./build-runner.type";
|
|
5
|
+
import { ISdBuildMessage, ISdBuildRunnerResult } from "./build.type";
|
|
4
6
|
|
|
5
7
|
export interface TServerWorkerType {
|
|
6
8
|
methods: {
|
|
@@ -25,3 +27,14 @@ export interface TSdTsCompileWorkerType {
|
|
|
25
27
|
};
|
|
26
28
|
events: {};
|
|
27
29
|
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
export interface TSdBuildRunnerWorkerType {
|
|
33
|
+
methods: {
|
|
34
|
+
run: { params: [ISdBuildRunnerWorkerRequest]; returnType: ISdBuildMessage[] | void };
|
|
35
|
+
};
|
|
36
|
+
events: {
|
|
37
|
+
change: void;
|
|
38
|
+
complete: ISdBuildRunnerResult;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createSdWorker, FsUtil, Logger, LoggerSeverity } from "@simplysm/sd-core-node";
|
|
2
|
+
import { ISdBuildMessage } from "../types/build.type";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { SdServerBuildRunner } from "../pkg-builders/server/SdServerBuildRunner";
|
|
5
|
+
import { SdClientBuildRunner } from "../pkg-builders/client/SdClientBuildRunner";
|
|
6
|
+
import { SdTsLibBuildRunner } from "../pkg-builders/lib/SdTsLibBuildRunner";
|
|
7
|
+
import { SdJsLibBuildRunner } from "../pkg-builders/lib/SdJsLibBuildRunner";
|
|
8
|
+
import { TSdBuildRunnerWorkerType } from "../types/workers.type";
|
|
9
|
+
import { ISdBuildRunnerWorkerRequest } from "../types/build-runner.type";
|
|
10
|
+
import { EventEmitter } from "events";
|
|
11
|
+
|
|
12
|
+
Error.stackTraceLimit = Infinity;
|
|
13
|
+
EventEmitter.defaultMaxListeners = 0;
|
|
14
|
+
|
|
15
|
+
if (process.env["SD_DEBUG"] != null) {
|
|
16
|
+
Logger.setConfig({
|
|
17
|
+
console: {
|
|
18
|
+
level: LoggerSeverity.debug,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
} else {
|
|
22
|
+
Logger.setConfig({
|
|
23
|
+
dot: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const worker = createSdWorker<TSdBuildRunnerWorkerType>({
|
|
28
|
+
async run(req: ISdBuildRunnerWorkerRequest): Promise<ISdBuildMessage[] | void> {
|
|
29
|
+
const pkgConf = req.projConf.packages[path.basename(req.pkgPath)]!;
|
|
30
|
+
|
|
31
|
+
const buildRunnerType =
|
|
32
|
+
pkgConf.type === "server"
|
|
33
|
+
? SdServerBuildRunner
|
|
34
|
+
: pkgConf.type === "client"
|
|
35
|
+
? SdClientBuildRunner
|
|
36
|
+
: FsUtil.exists(path.resolve(req.pkgPath, "tsconfig.json"))
|
|
37
|
+
? SdTsLibBuildRunner
|
|
38
|
+
: SdJsLibBuildRunner;
|
|
39
|
+
|
|
40
|
+
const builder = new buildRunnerType(req.projConf, req.pkgPath)
|
|
41
|
+
.on("change", () => {
|
|
42
|
+
worker.send("change");
|
|
43
|
+
})
|
|
44
|
+
.on("complete", (result) => {
|
|
45
|
+
worker.send("complete", result)
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (req.cmd === "build") {
|
|
49
|
+
const res = await builder.buildAsync();
|
|
50
|
+
return res.buildMessages;
|
|
51
|
+
} else {
|
|
52
|
+
await builder.watchAsync();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TNormPath } from "@simplysm/sd-core-node";
|
|
2
|
-
import { SdTsCompilerOptions } from "../types/ts-compiler.type";
|
|
3
|
-
export declare class SdTsCompileWorker {
|
|
4
|
-
private _compileProc;
|
|
5
|
-
private _pkgPath;
|
|
6
|
-
static new(opt: SdTsCompilerOptions): Promise<SdTsCompileWorker>;
|
|
7
|
-
private constructor();
|
|
8
|
-
compileAsync(modifiedFileSet: Set<TNormPath>): Promise<import("../types/ts-compiler.type").ISdTsCompilerResult>;
|
|
9
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { SdWorker } from "@simplysm/sd-core-node";
|
|
2
|
-
export class SdTsCompileWorker {
|
|
3
|
-
static async new(opt) {
|
|
4
|
-
const compileWorker = new SdWorker(import.meta.resolve("../workers/compile-worker"));
|
|
5
|
-
await compileWorker.run("initialize", [opt]);
|
|
6
|
-
return new SdTsCompileWorker(compileWorker, opt.pkgPath);
|
|
7
|
-
}
|
|
8
|
-
constructor(_compileProc, _pkgPath) {
|
|
9
|
-
this._compileProc = _compileProc;
|
|
10
|
-
this._pkgPath = _pkgPath;
|
|
11
|
-
}
|
|
12
|
-
async compileAsync(modifiedFileSet) {
|
|
13
|
-
return await this._compileProc.run("compile", [modifiedFileSet]);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=SdTsCompileWorker.js.map
|