@simplysm/sd-cli 12.5.60 → 12.6.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/entry/SdCliElectron.js +5 -5
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js +11 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -1
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
- package/dist/pkg-builders/client/SdNgBundlerContext.d.ts +9 -1
- package/dist/pkg-builders/client/SdNgBundlerContext.js +2 -1
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -1
- package/dist/pkg-builders/client/createSdNgPlugin.js +1 -1
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js +1 -1
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -1
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +18 -20
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
- package/dist/ts-builder/SdTsCompiler.js +110 -40
- package/dist/ts-builder/SdTsCompiler.js.map +1 -1
- package/dist/types/sd-configs.type.d.ts +1 -0
- package/dist/types/ts-compiler.type.d.ts +1 -1
- package/dist/types/workers.type.d.ts +0 -28
- package/package.json +11 -11
- package/src/entry/SdCliElectron.ts +7 -7
- package/src/index.ts +0 -1
- package/src/pkg-builders/client/SdCliNgRoutesFileGenerator.ts +13 -8
- package/src/pkg-builders/client/SdNgBundler.ts +3 -3
- package/src/pkg-builders/client/SdNgBundlerContext.ts +19 -5
- package/src/pkg-builders/client/createSdNgPlugin.ts +1 -1
- package/src/pkg-builders/lib/SdCliIndexFileGenerator.ts +1 -1
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +23 -22
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +1 -1
- package/src/ts-builder/SdTsCompiler.ts +157 -72
- package/src/types/sd-configs.type.ts +1 -0
- package/src/types/ts-compiler.type.ts +1 -1
- package/src/types/workers.type.ts +13 -17
- package/dist/workers/lint-worker.d.ts +0 -1
- package/dist/workers/lint-worker.js +0 -36
- package/dist/workers/lint-worker.js.map +0 -1
- package/src/workers/lint-worker.ts +0 -44
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { FsUtil, Logger, PathUtil,
|
|
3
|
+
import { FsUtil, Logger, PathUtil, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import { StringUtil } from "@simplysm/sd-core-common";
|
|
5
5
|
import { NgtscProgram, OptimizeFor } from "@angular/compiler-cli";
|
|
6
6
|
import { ComponentStylesheetBundler } from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
|
|
@@ -12,8 +12,8 @@ import { SdCliPerformanceTimer } from "../utils/SdCliPerformanceTime";
|
|
|
12
12
|
import { SdCliConvertMessageUtil } from "../utils/SdCliConvertMessageUtil";
|
|
13
13
|
import { ISdTsCompilerResult, IStylesheetBundlingResult, SdTsCompilerOptions } from "../types/ts-compiler.type";
|
|
14
14
|
import { ISdBuildMessage } from "../types/build.type";
|
|
15
|
-
import { TSdLintWorkerType } from "../types/workers.type";
|
|
16
15
|
import { createWorkerTransformer } from "@angular/build/src/tools/angular/transformers/web-worker-transformer";
|
|
16
|
+
import { ESLint } from "eslint";
|
|
17
17
|
|
|
18
18
|
export class SdTsCompiler {
|
|
19
19
|
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
|
|
@@ -52,7 +52,7 @@ export class SdTsCompiler {
|
|
|
52
52
|
|
|
53
53
|
readonly #isForBundle: boolean;
|
|
54
54
|
|
|
55
|
-
readonly #lintWorker = new SdWorker<TSdLintWorkerType>(import.meta.resolve("../workers/lint-worker"));
|
|
55
|
+
// readonly #lintWorker = new SdWorker<TSdLintWorkerType>(import.meta.resolve("../workers/lint-worker"));
|
|
56
56
|
|
|
57
57
|
#perf!: SdCliPerformanceTimer;
|
|
58
58
|
|
|
@@ -74,7 +74,7 @@ export class SdTsCompiler {
|
|
|
74
74
|
this.#isForAngular = Boolean(tsconfig.angularCompilerOptions);
|
|
75
75
|
this.#parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, opt.pkgPath, {
|
|
76
76
|
...tsconfig.angularCompilerOptions,
|
|
77
|
-
...opt.additionalOptions
|
|
77
|
+
...opt.additionalOptions,
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
this.#distPath = PathUtil.norm(this.#parsedTsconfig.options.outDir ?? path.resolve(opt.pkgPath, "dist"));
|
|
@@ -85,17 +85,24 @@ export class SdTsCompiler {
|
|
|
85
85
|
|
|
86
86
|
const baseGetSourceFile = this.#compilerHost.getSourceFile;
|
|
87
87
|
this.#compilerHost.getSourceFile = (
|
|
88
|
-
fileName,
|
|
89
|
-
languageVersionOrOptions,
|
|
90
|
-
onError,
|
|
91
|
-
shouldCreateNewSourceFile,
|
|
88
|
+
fileName: string,
|
|
89
|
+
languageVersionOrOptions: ts.ScriptTarget | ts.CreateSourceFileOptions,
|
|
90
|
+
onError?: ((message: string) => void) | undefined,
|
|
91
|
+
shouldCreateNewSourceFile?: boolean,
|
|
92
92
|
...args
|
|
93
|
-
) => {
|
|
93
|
+
): ts.SourceFile | undefined => {
|
|
94
94
|
if (!shouldCreateNewSourceFile && this.#sourceFileCacheMap.has(PathUtil.norm(fileName))) {
|
|
95
95
|
return this.#sourceFileCacheMap.get(PathUtil.norm(fileName));
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
const sf = baseGetSourceFile.call(
|
|
98
|
+
const sf: ts.SourceFile | undefined = baseGetSourceFile.call(
|
|
99
|
+
this.#compilerHost,
|
|
100
|
+
fileName,
|
|
101
|
+
languageVersionOrOptions,
|
|
102
|
+
onError,
|
|
103
|
+
true,
|
|
104
|
+
...args,
|
|
105
|
+
);
|
|
99
106
|
|
|
100
107
|
if (sf) {
|
|
101
108
|
this.#sourceFileCacheMap.set(PathUtil.norm(fileName), sf);
|
|
@@ -127,16 +134,17 @@ export class SdTsCompiler {
|
|
|
127
134
|
externalDependencies: [],
|
|
128
135
|
target: transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"])),
|
|
129
136
|
postcssConfiguration: {
|
|
130
|
-
plugins: [["css-has-pseudo"]]
|
|
137
|
+
plugins: [["css-has-pseudo"]],
|
|
131
138
|
},
|
|
132
139
|
tailwindConfiguration: undefined,
|
|
133
140
|
cacheOptions: {
|
|
134
141
|
enabled: true,
|
|
135
142
|
path: ".cache/angular",
|
|
136
|
-
basePath: ".cache"
|
|
137
|
-
}
|
|
143
|
+
basePath: ".cache",
|
|
144
|
+
},
|
|
138
145
|
},
|
|
139
|
-
|
|
146
|
+
"scss",
|
|
147
|
+
opt.isDevMode,
|
|
140
148
|
);
|
|
141
149
|
|
|
142
150
|
//-- compilerHost
|
|
@@ -151,7 +159,7 @@ export class SdTsCompiler {
|
|
|
151
159
|
type: string;
|
|
152
160
|
containingFile: string;
|
|
153
161
|
resourceFile: string | null;
|
|
154
|
-
}
|
|
162
|
+
},
|
|
155
163
|
) => {
|
|
156
164
|
if (context.type !== "style") {
|
|
157
165
|
return null;
|
|
@@ -160,7 +168,7 @@ export class SdTsCompiler {
|
|
|
160
168
|
const contents = await this.#bundleStylesheetAsync(
|
|
161
169
|
data,
|
|
162
170
|
PathUtil.norm(context.containingFile),
|
|
163
|
-
context.resourceFile != null ? PathUtil.norm(context.resourceFile) : undefined
|
|
171
|
+
context.resourceFile != null ? PathUtil.norm(context.resourceFile) : undefined,
|
|
164
172
|
);
|
|
165
173
|
|
|
166
174
|
return StringUtil.isNullOrEmpty(contents) ? null : { content: contents };
|
|
@@ -189,21 +197,21 @@ export class SdTsCompiler {
|
|
|
189
197
|
for (const referencedFile of stylesheetResult.referencedFiles) {
|
|
190
198
|
const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(
|
|
191
199
|
PathUtil.norm(referencedFile),
|
|
192
|
-
new Set<TNormPath>()
|
|
200
|
+
new Set<TNormPath>(),
|
|
193
201
|
);
|
|
194
202
|
depCacheSet.add(resourceFile ?? containingFile);
|
|
195
203
|
}
|
|
196
204
|
|
|
197
205
|
this.#watchFileSet.adds(
|
|
198
|
-
...Array.from(stylesheetResult.referencedFiles.values()).map((item) => PathUtil.norm(item))
|
|
206
|
+
...Array.from(stylesheetResult.referencedFiles.values()).map((item) => PathUtil.norm(item)),
|
|
199
207
|
);
|
|
200
208
|
}
|
|
201
209
|
|
|
202
210
|
this.#stylesheetBundlingResultMap.set(PathUtil.norm(resourceFile ?? containingFile), {
|
|
203
|
-
outputFiles: stylesheetResult.outputFiles,
|
|
204
|
-
metafile: stylesheetResult.metafile,
|
|
211
|
+
outputFiles: stylesheetResult.errors == null ? stylesheetResult.outputFiles : undefined,
|
|
212
|
+
metafile: stylesheetResult.errors == null ? stylesheetResult.metafile : undefined,
|
|
205
213
|
errors: stylesheetResult.errors,
|
|
206
|
-
warnings: stylesheetResult.warnings
|
|
214
|
+
warnings: stylesheetResult.warnings,
|
|
207
215
|
});
|
|
208
216
|
|
|
209
217
|
return stylesheetResult.contents;
|
|
@@ -235,13 +243,13 @@ export class SdTsCompiler {
|
|
|
235
243
|
messages: [
|
|
236
244
|
...prepareResult.messages,
|
|
237
245
|
...SdCliConvertMessageUtil.convertToBuildMessagesFromTsDiag(buildResult.diagnostics),
|
|
238
|
-
...SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults)
|
|
246
|
+
...SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults),
|
|
239
247
|
],
|
|
240
248
|
watchFileSet: this.#watchFileSet,
|
|
241
249
|
affectedFileSet: this.#affectedFileSet,
|
|
242
250
|
stylesheetBundlingResultMap: this.#stylesheetBundlingResultMap,
|
|
243
251
|
emittedFilesCacheMap: this.#emittedFilesCacheMap,
|
|
244
|
-
emitFileSet: buildResult.emitFileSet
|
|
252
|
+
emitFileSet: buildResult.emitFileSet,
|
|
245
253
|
};
|
|
246
254
|
}
|
|
247
255
|
|
|
@@ -283,7 +291,7 @@ export class SdTsCompiler {
|
|
|
283
291
|
this.#parsedTsconfig.fileNames,
|
|
284
292
|
this.#parsedTsconfig.options,
|
|
285
293
|
this.#compilerHost,
|
|
286
|
-
this.#ngProgram
|
|
294
|
+
this.#ngProgram,
|
|
287
295
|
);
|
|
288
296
|
this.#program = this.#ngProgram.getTsProgram();
|
|
289
297
|
}
|
|
@@ -292,7 +300,7 @@ export class SdTsCompiler {
|
|
|
292
300
|
this.#parsedTsconfig.fileNames,
|
|
293
301
|
this.#parsedTsconfig.options,
|
|
294
302
|
this.#compilerHost,
|
|
295
|
-
this.#program
|
|
303
|
+
this.#program,
|
|
296
304
|
);
|
|
297
305
|
}
|
|
298
306
|
});
|
|
@@ -315,7 +323,7 @@ export class SdTsCompiler {
|
|
|
315
323
|
const sourceFileSet = new Set(
|
|
316
324
|
this.#program!.getSourceFiles()
|
|
317
325
|
.map((sf) => getOrgSourceFile(sf))
|
|
318
|
-
.filterExists()
|
|
326
|
+
.filterExists(),
|
|
319
327
|
);
|
|
320
328
|
|
|
321
329
|
this.#debug(`get new deps...`);
|
|
@@ -332,7 +340,7 @@ export class SdTsCompiler {
|
|
|
332
340
|
}[]
|
|
333
341
|
>();
|
|
334
342
|
for (const sf of sourceFileSet) {
|
|
335
|
-
if (!PathUtil.isChildPath(sf.fileName,
|
|
343
|
+
if (!this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(sf.fileName, scopePath))) {
|
|
336
344
|
continue;
|
|
337
345
|
}
|
|
338
346
|
|
|
@@ -343,8 +351,8 @@ export class SdTsCompiler {
|
|
|
343
351
|
refs
|
|
344
352
|
.filter((item) => "fileName" in item)
|
|
345
353
|
.filter((item) =>
|
|
346
|
-
this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(item.fileName, scopePath))
|
|
347
|
-
)
|
|
354
|
+
this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(item.fileName, scopePath)),
|
|
355
|
+
),
|
|
348
356
|
);
|
|
349
357
|
}
|
|
350
358
|
|
|
@@ -426,9 +434,9 @@ export class SdTsCompiler {
|
|
|
426
434
|
[
|
|
427
435
|
item,
|
|
428
436
|
// .d.ts면 .js파일도 affected에 추가
|
|
429
|
-
item.endsWith(".d.ts") ? PathUtil.norm(item.replace(/\.d\.ts$/, ".js")) : undefined
|
|
430
|
-
].filterExists()
|
|
431
|
-
)
|
|
437
|
+
item.endsWith(".d.ts") ? PathUtil.norm(item.replace(/\.d\.ts$/, ".js")) : undefined,
|
|
438
|
+
].filterExists(),
|
|
439
|
+
),
|
|
432
440
|
);
|
|
433
441
|
}
|
|
434
442
|
|
|
@@ -454,17 +462,44 @@ export class SdTsCompiler {
|
|
|
454
462
|
}
|
|
455
463
|
|
|
456
464
|
return {
|
|
457
|
-
messages
|
|
465
|
+
messages,
|
|
458
466
|
};
|
|
459
467
|
}
|
|
460
468
|
|
|
461
469
|
async #lintAsync() {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
const lintFilePaths = Array.from(this.#affectedFileSet)
|
|
471
|
+
.filter((item) => PathUtil.isChildPath(item, this.#pkgPath))
|
|
472
|
+
.filter((item) => (
|
|
473
|
+
(!item.endsWith(".d.ts") && item.endsWith(".ts")) ||
|
|
474
|
+
item.endsWith(".js")
|
|
475
|
+
))
|
|
476
|
+
.filter((item) => FsUtil.exists(item));
|
|
477
|
+
|
|
478
|
+
if (lintFilePaths.length === 0) {
|
|
479
|
+
return [];
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const linter = new ESLint({
|
|
483
|
+
cwd: this.#pkgPath,
|
|
484
|
+
cache: false,
|
|
485
|
+
overrideConfig: {
|
|
486
|
+
languageOptions: {
|
|
487
|
+
parserOptions: {
|
|
488
|
+
// parser: tseslint.parser,
|
|
489
|
+
project: null,
|
|
490
|
+
programs: [this.#program],
|
|
491
|
+
},
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
});
|
|
495
|
+
return await linter.lintFiles(lintFilePaths);
|
|
496
|
+
|
|
497
|
+
// return await this.#lintWorker.run("lint", [
|
|
498
|
+
// {
|
|
499
|
+
// cwd: this.#pkgPath,
|
|
500
|
+
// fileSet: this.#affectedFileSet,
|
|
501
|
+
// },
|
|
502
|
+
// ]);
|
|
468
503
|
}
|
|
469
504
|
|
|
470
505
|
async #buildAsync() {
|
|
@@ -477,7 +512,7 @@ export class SdTsCompiler {
|
|
|
477
512
|
diagnostics.push(
|
|
478
513
|
...this.#program!.getConfigFileParsingDiagnostics(),
|
|
479
514
|
...this.#program!.getOptionsDiagnostics(),
|
|
480
|
-
...this.#program!.getGlobalDiagnostics()
|
|
515
|
+
...this.#program!.getGlobalDiagnostics(),
|
|
481
516
|
);
|
|
482
517
|
|
|
483
518
|
if (this.#ngProgram) {
|
|
@@ -506,7 +541,7 @@ export class SdTsCompiler {
|
|
|
506
541
|
this.#perf.run("get file diagnostics", () => {
|
|
507
542
|
diagnostics.push(
|
|
508
543
|
...this.#program!.getSyntacticDiagnostics(affectedSourceFile),
|
|
509
|
-
...this.#program!.getSemanticDiagnostics(affectedSourceFile)
|
|
544
|
+
...this.#program!.getSemanticDiagnostics(affectedSourceFile),
|
|
510
545
|
);
|
|
511
546
|
});
|
|
512
547
|
|
|
@@ -517,7 +552,7 @@ export class SdTsCompiler {
|
|
|
517
552
|
}
|
|
518
553
|
|
|
519
554
|
diagnostics.push(
|
|
520
|
-
...this.#ngProgram!.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram)
|
|
555
|
+
...this.#ngProgram!.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram),
|
|
521
556
|
);
|
|
522
557
|
});
|
|
523
558
|
}
|
|
@@ -531,7 +566,7 @@ export class SdTsCompiler {
|
|
|
531
566
|
if (this.#ngProgram) {
|
|
532
567
|
transformers = {
|
|
533
568
|
...transformers,
|
|
534
|
-
...this.#ngProgram.compiler.prepareEmit().transformers
|
|
569
|
+
...this.#ngProgram.compiler.prepareEmit().transformers,
|
|
535
570
|
};
|
|
536
571
|
(transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
|
|
537
572
|
(transformers.before ??= []).push(
|
|
@@ -539,7 +574,7 @@ export class SdTsCompiler {
|
|
|
539
574
|
const fullPath = path.resolve(path.dirname(importer), file);
|
|
540
575
|
const relPath = path.relative(path.resolve(this.#pkgPath, "src"), fullPath);
|
|
541
576
|
return relPath.replace(/\.ts$/, "").replaceAll("\\", "/") + ".js";
|
|
542
|
-
})
|
|
577
|
+
}),
|
|
543
578
|
);
|
|
544
579
|
}
|
|
545
580
|
// (transformers.before ??= []).push(transformKeys(this.#program));
|
|
@@ -604,7 +639,7 @@ export class SdTsCompiler {
|
|
|
604
639
|
) {
|
|
605
640
|
realFilePath = PathUtil.norm(
|
|
606
641
|
this.#distPath,
|
|
607
|
-
path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath)
|
|
642
|
+
path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
|
|
608
643
|
);
|
|
609
644
|
|
|
610
645
|
if (fileName.endsWith(".js.map")) {
|
|
@@ -617,7 +652,7 @@ export class SdTsCompiler {
|
|
|
617
652
|
|
|
618
653
|
emitFileInfoCaches.push({
|
|
619
654
|
outAbsPath: realFilePath,
|
|
620
|
-
text: realText
|
|
655
|
+
text: realText,
|
|
621
656
|
});
|
|
622
657
|
}
|
|
623
658
|
else {
|
|
@@ -628,7 +663,7 @@ export class SdTsCompiler {
|
|
|
628
663
|
},
|
|
629
664
|
undefined,
|
|
630
665
|
undefined,
|
|
631
|
-
transformers
|
|
666
|
+
transformers,
|
|
632
667
|
);
|
|
633
668
|
}
|
|
634
669
|
});
|
|
@@ -648,9 +683,9 @@ export class SdTsCompiler {
|
|
|
648
683
|
emitFileInfos.push({
|
|
649
684
|
outAbsPath: PathUtil.norm(
|
|
650
685
|
this.#pkgPath,
|
|
651
|
-
path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!).replace(/\.scss$/, ".css")
|
|
686
|
+
path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!).replace(/\.scss$/, ".css"),
|
|
652
687
|
),
|
|
653
|
-
text: contents
|
|
688
|
+
text: contents,
|
|
654
689
|
});
|
|
655
690
|
emitFileSet.add(this.#globalStyleFilePath!);
|
|
656
691
|
});
|
|
@@ -658,7 +693,7 @@ export class SdTsCompiler {
|
|
|
658
693
|
|
|
659
694
|
return {
|
|
660
695
|
emitFileSet,
|
|
661
|
-
diagnostics
|
|
696
|
+
diagnostics,
|
|
662
697
|
};
|
|
663
698
|
}
|
|
664
699
|
|
|
@@ -667,13 +702,11 @@ export class SdTsCompiler {
|
|
|
667
702
|
}
|
|
668
703
|
|
|
669
704
|
#findDeps(sf: ts.SourceFile) {
|
|
670
|
-
const deps: (
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
} | ISdBuildMessage
|
|
676
|
-
)[] = [];
|
|
705
|
+
const deps: ({
|
|
706
|
+
fileName: TNormPath;
|
|
707
|
+
importName: string;
|
|
708
|
+
exportName?: string;
|
|
709
|
+
} | ISdBuildMessage)[] = [];
|
|
677
710
|
|
|
678
711
|
const tc = this.#program!.getTypeChecker();
|
|
679
712
|
|
|
@@ -690,7 +723,7 @@ export class SdTsCompiler {
|
|
|
690
723
|
code: undefined,
|
|
691
724
|
severity: "error",
|
|
692
725
|
message: "export moduleSymbol not found",
|
|
693
|
-
type: "deps"
|
|
726
|
+
type: "deps",
|
|
694
727
|
});
|
|
695
728
|
return;
|
|
696
729
|
}
|
|
@@ -705,7 +738,7 @@ export class SdTsCompiler {
|
|
|
705
738
|
code: undefined,
|
|
706
739
|
severity: "error",
|
|
707
740
|
message: "export decls not found",
|
|
708
|
-
type: "deps"
|
|
741
|
+
type: "deps",
|
|
709
742
|
});
|
|
710
743
|
return;
|
|
711
744
|
}
|
|
@@ -717,7 +750,7 @@ export class SdTsCompiler {
|
|
|
717
750
|
deps.push({
|
|
718
751
|
fileName: PathUtil.norm(decl.getSourceFile().fileName),
|
|
719
752
|
importName: el.name.text,
|
|
720
|
-
exportName: el.propertyName?.text ?? el.name.text
|
|
753
|
+
exportName: el.propertyName?.text ?? el.name.text,
|
|
721
754
|
});
|
|
722
755
|
}
|
|
723
756
|
}
|
|
@@ -732,7 +765,7 @@ export class SdTsCompiler {
|
|
|
732
765
|
code: undefined,
|
|
733
766
|
severity: "error",
|
|
734
767
|
message: "moduleSymbol exports not found",
|
|
735
|
-
type: "deps"
|
|
768
|
+
type: "deps",
|
|
736
769
|
});
|
|
737
770
|
return;
|
|
738
771
|
}
|
|
@@ -742,7 +775,7 @@ export class SdTsCompiler {
|
|
|
742
775
|
deps.push({
|
|
743
776
|
fileName: PathUtil.norm(decl.getSourceFile().fileName),
|
|
744
777
|
importName: key.toString(),
|
|
745
|
-
exportName: key.toString()
|
|
778
|
+
exportName: key.toString(),
|
|
746
779
|
});
|
|
747
780
|
}
|
|
748
781
|
}
|
|
@@ -754,10 +787,23 @@ export class SdTsCompiler {
|
|
|
754
787
|
if (!moduleSymbol) {
|
|
755
788
|
if (ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith("./")) {
|
|
756
789
|
deps.push({
|
|
757
|
-
fileName: PathUtil.norm(path.resolve(path.dirname(sf.fileName), node.moduleSpecifier.text)),
|
|
758
|
-
importName: "*"
|
|
790
|
+
fileName: PathUtil.norm(path.resolve(path.dirname(sf.fileName), node.moduleSpecifier.text + ".ts")),
|
|
791
|
+
importName: "*",
|
|
759
792
|
});
|
|
793
|
+
|
|
794
|
+
// const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
|
|
795
|
+
// deps.push({
|
|
796
|
+
// filePath: PathUtil.norm(sf.fileName),
|
|
797
|
+
// line: pos.line,
|
|
798
|
+
// char: pos.character,
|
|
799
|
+
// code: undefined,
|
|
800
|
+
// severity: "error",
|
|
801
|
+
// message: `import moduleSymbol not found (${node.moduleSpecifier.text})`,
|
|
802
|
+
// type: "deps",
|
|
803
|
+
// });
|
|
804
|
+
// return;
|
|
760
805
|
}
|
|
806
|
+
|
|
761
807
|
/*else {
|
|
762
808
|
throw new NeverEntryError(`import moduleSymbol: ${sf.fileName} ${node.moduleSpecifier["text"]}`);
|
|
763
809
|
}*/
|
|
@@ -772,8 +818,8 @@ export class SdTsCompiler {
|
|
|
772
818
|
char: pos.character,
|
|
773
819
|
code: undefined,
|
|
774
820
|
severity: "error",
|
|
775
|
-
message:
|
|
776
|
-
type: "deps"
|
|
821
|
+
message: `import decls not found (${moduleSymbol.name})`,
|
|
822
|
+
type: "deps",
|
|
777
823
|
});
|
|
778
824
|
return;
|
|
779
825
|
}
|
|
@@ -784,7 +830,7 @@ export class SdTsCompiler {
|
|
|
784
830
|
for (const decl of decls) {
|
|
785
831
|
deps.push({
|
|
786
832
|
fileName: PathUtil.norm(decl.getSourceFile().fileName),
|
|
787
|
-
importName: el.name.text
|
|
833
|
+
importName: el.name.text,
|
|
788
834
|
});
|
|
789
835
|
}
|
|
790
836
|
}
|
|
@@ -793,7 +839,7 @@ export class SdTsCompiler {
|
|
|
793
839
|
for (const decl of decls) {
|
|
794
840
|
deps.push({
|
|
795
841
|
fileName: PathUtil.norm(decl.getSourceFile().fileName),
|
|
796
|
-
importName: "*"
|
|
842
|
+
importName: "*",
|
|
797
843
|
});
|
|
798
844
|
}
|
|
799
845
|
}
|
|
@@ -802,10 +848,49 @@ export class SdTsCompiler {
|
|
|
802
848
|
|
|
803
849
|
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
804
850
|
if (ts.isStringLiteral(node.arguments[0]) && node.arguments[0].text.startsWith("./")) {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
851
|
+
|
|
852
|
+
const moduleSymbol = tc.getSymbolAtLocation(node.arguments[0]);
|
|
853
|
+
if (!moduleSymbol) {
|
|
854
|
+
deps.push({
|
|
855
|
+
fileName: PathUtil.norm(path.resolve(path.dirname(sf.fileName), node.arguments[0].text + ".ts")),
|
|
856
|
+
importName: "*",
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
|
|
860
|
+
// deps.push({
|
|
861
|
+
// filePath: PathUtil.norm(sf.fileName),
|
|
862
|
+
// line: pos.line,
|
|
863
|
+
// char: pos.character,
|
|
864
|
+
// code: undefined,
|
|
865
|
+
// severity: "error",
|
|
866
|
+
// message: `import() moduleSymbol not found (${node.arguments[0].text})`,
|
|
867
|
+
// type: "deps",
|
|
868
|
+
// });
|
|
869
|
+
// return;
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
const decls = moduleSymbol.getDeclarations();
|
|
873
|
+
if (!decls) {
|
|
874
|
+
const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
|
|
875
|
+
deps.push({
|
|
876
|
+
filePath: PathUtil.norm(sf.fileName),
|
|
877
|
+
line: pos.line,
|
|
878
|
+
char: pos.character,
|
|
879
|
+
code: undefined,
|
|
880
|
+
severity: "error",
|
|
881
|
+
message: `import() decls not found (${node.arguments[0].text})`,
|
|
882
|
+
type: "deps",
|
|
883
|
+
});
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
for (const decl of decls) {
|
|
888
|
+
deps.push({
|
|
889
|
+
fileName: PathUtil.norm(decl.getSourceFile().fileName),
|
|
890
|
+
importName: "*",
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
}
|
|
809
894
|
}
|
|
810
895
|
}
|
|
811
896
|
|
|
@@ -26,7 +26,7 @@ export interface ISdTsCompilerResult {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface IStylesheetBundlingResult {
|
|
29
|
-
outputFiles
|
|
29
|
+
outputFiles?: esbuild.OutputFile[];
|
|
30
30
|
metafile?: esbuild.Metafile;
|
|
31
31
|
errors?: esbuild.Message[];
|
|
32
32
|
warnings?: esbuild.Message[];
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { ESLint } from "eslint";
|
|
2
|
-
import { ISdTsCompilerResult, SdTsCompilerOptions } from "./ts-compiler.type";
|
|
3
|
-
import { TNormPath } from "@simplysm/sd-core-node";
|
|
4
1
|
import { ISdBuildRunnerWorkerRequest } from "./build-runner.type";
|
|
5
2
|
import { ISdBuildMessage, ISdBuildRunnerResult } from "./build.type";
|
|
6
3
|
|
|
@@ -13,21 +10,20 @@ export interface TServerWorkerType {
|
|
|
13
10
|
events: {};
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
export interface TSdLintWorkerType {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface TSdTsCompileWorkerType {
|
|
24
|
-
methods: {
|
|
25
|
-
initialize: { params: [SdTsCompilerOptions]; returnType: void };
|
|
26
|
-
compile: { params: [Set<TNormPath>]; returnType: ISdTsCompilerResult };
|
|
27
|
-
};
|
|
28
|
-
events: {};
|
|
29
|
-
}
|
|
13
|
+
// export interface TSdLintWorkerType {
|
|
14
|
+
// methods: {
|
|
15
|
+
// lint: { params: [{ cwd: string; fileSet: Set<string> }]; returnType: ESLint.LintResult[] };
|
|
16
|
+
// };
|
|
17
|
+
// events: {};
|
|
18
|
+
// }
|
|
30
19
|
|
|
20
|
+
// export interface TSdTsCompileWorkerType {
|
|
21
|
+
// methods: {
|
|
22
|
+
// initialize: { params: [SdTsCompilerOptions]; returnType: void };
|
|
23
|
+
// compile: { params: [Set<TNormPath>]; returnType: ISdTsCompilerResult };
|
|
24
|
+
// };
|
|
25
|
+
// events: {};
|
|
26
|
+
// }
|
|
31
27
|
|
|
32
28
|
export interface TSdBuildRunnerWorkerType {
|
|
33
29
|
methods: {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createSdWorker, FsUtil, Logger, LoggerSeverity, PathUtil } from "@simplysm/sd-core-node";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { ESLint } from "eslint";
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
Error.stackTraceLimit = Infinity;
|
|
6
|
-
EventEmitter.defaultMaxListeners = 0;
|
|
7
|
-
if (process.env["SD_DEBUG"] != null) {
|
|
8
|
-
Logger.setConfig({
|
|
9
|
-
console: {
|
|
10
|
-
level: LoggerSeverity.debug,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
Logger.setConfig({
|
|
16
|
-
dot: true,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
createSdWorker({
|
|
20
|
-
async lint(opt) {
|
|
21
|
-
const isTsPackage = FsUtil.exists(path.resolve(opt.cwd, "tsconfig.json"));
|
|
22
|
-
const lintFilePaths = Array.from(opt.fileSet)
|
|
23
|
-
.filter((item) => PathUtil.isChildPath(item, opt.cwd))
|
|
24
|
-
.filter((item) => (isTsPackage && !item.endsWith(".d.ts") && item.endsWith(".ts")) ||
|
|
25
|
-
item.endsWith(".js") ||
|
|
26
|
-
item.endsWith(".tsx") ||
|
|
27
|
-
item.endsWith(".jsx"))
|
|
28
|
-
.filter((item) => FsUtil.exists(item));
|
|
29
|
-
if (lintFilePaths.length === 0) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
|
-
const linter = new ESLint({ cwd: opt.cwd, cache: false });
|
|
33
|
-
return await linter.lintFiles(lintFilePaths);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=lint-worker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lint-worker.js","sourceRoot":"","sources":["../../src/workers/lint-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;AACjC,YAAY,CAAC,mBAAmB,GAAG,CAAC,CAAC;AAErC,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;IACpC,MAAM,CAAC,SAAS,CAAC;QACf,OAAO,EAAE;YACP,KAAK,EAAE,cAAc,CAAC,KAAK;SAC5B;KACF,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,MAAM,CAAC,SAAS,CAAC;QACf,GAAG,EAAE,IAAI;KACV,CAAC,CAAC;AACL,CAAC;AAED,cAAc,CAAoB;IAChC,KAAK,CAAC,IAAI,CAAC,GAA0C;QACnD,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;QAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;aAC1C,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;aACrD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YACpB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACrB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACxB;aACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAEzC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1D,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createSdWorker, FsUtil, Logger, LoggerSeverity, PathUtil } from "@simplysm/sd-core-node";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { ESLint } from "eslint";
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { TSdLintWorkerType } from "../types/workers.type";
|
|
6
|
-
|
|
7
|
-
Error.stackTraceLimit = Infinity;
|
|
8
|
-
EventEmitter.defaultMaxListeners = 0;
|
|
9
|
-
|
|
10
|
-
if (process.env["SD_DEBUG"] != null) {
|
|
11
|
-
Logger.setConfig({
|
|
12
|
-
console: {
|
|
13
|
-
level: LoggerSeverity.debug,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
} else {
|
|
17
|
-
Logger.setConfig({
|
|
18
|
-
dot: true,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
createSdWorker<TSdLintWorkerType>({
|
|
23
|
-
async lint(opt: { cwd: string; fileSet: Set<string> }) {
|
|
24
|
-
const isTsPackage = FsUtil.exists(path.resolve(opt.cwd, "tsconfig.json"));
|
|
25
|
-
|
|
26
|
-
const lintFilePaths = Array.from(opt.fileSet)
|
|
27
|
-
.filter((item) => PathUtil.isChildPath(item, opt.cwd))
|
|
28
|
-
.filter(
|
|
29
|
-
(item) =>
|
|
30
|
-
(isTsPackage && !item.endsWith(".d.ts") && item.endsWith(".ts")) ||
|
|
31
|
-
item.endsWith(".js") ||
|
|
32
|
-
item.endsWith(".tsx") ||
|
|
33
|
-
item.endsWith(".jsx"),
|
|
34
|
-
)
|
|
35
|
-
.filter((item) => FsUtil.exists(item));
|
|
36
|
-
|
|
37
|
-
if (lintFilePaths.length === 0) {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const linter = new ESLint({ cwd: opt.cwd, cache: false });
|
|
42
|
-
return await linter.lintFiles(lintFilePaths);
|
|
43
|
-
},
|
|
44
|
-
});
|