@simplysm/sd-cli 12.5.17 → 12.5.19

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.
@@ -1,7 +1,7 @@
1
1
  import ts, { CompilerOptions } from "typescript";
2
2
  import path from "path";
3
3
  import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
4
- import { NeverEntryError, StringUtil } from "@simplysm/sd-core-common";
4
+ import { StringUtil } from "@simplysm/sd-core-common";
5
5
  import esbuild from "esbuild";
6
6
  import { NgtscProgram, OptimizeFor } from "@angular/compiler-cli";
7
7
  import { createHash } from "crypto";
@@ -9,7 +9,6 @@ import { ComponentStylesheetBundler } from "@angular/build/src/tools/esbuild/ang
9
9
  import { AngularCompilerHost } from "@angular/build/src/tools/angular/angular-host";
10
10
  import { transformSupportedBrowsersToTargets } from "@angular/build/src/tools/esbuild/utils";
11
11
  import browserslist from "browserslist";
12
- import transformKeys from "@simplysm/ts-transformer-keys/transformer";
13
12
  import { replaceBootstrap } from "@angular/build/src/tools/angular/transformers/jit-bootstrap-transformer";
14
13
 
15
14
  export class SdTsCompiler {
@@ -18,7 +17,7 @@ export class SdTsCompiler {
18
17
  readonly #parsedTsconfig: ts.ParsedCommandLine;
19
18
  readonly #isForAngular: boolean;
20
19
 
21
- readonly #revDependencyCacheMap = new Map<string, Set<string>>();
20
+ // readonly #revDependencyCacheMap = new Map<string, Set<string>>();
22
21
  readonly #resourceDependencyCacheMap = new Map<string, Set<string>>();
23
22
  readonly #sourceFileCacheMap = new Map<string, ts.SourceFile>();
24
23
  readonly #emittedFilesCacheMap = new Map<
@@ -34,6 +33,7 @@ export class SdTsCompiler {
34
33
 
35
34
  #ngProgram: NgtscProgram | undefined;
36
35
  #program: ts.Program | undefined;
36
+ #builder: ts.EmitAndSemanticDiagnosticsBuilderProgram | undefined;
37
37
 
38
38
  readonly #modifiedFileSet = new Set<string>();
39
39
 
@@ -196,34 +196,41 @@ export class SdTsCompiler {
196
196
  }
197
197
 
198
198
  invalidate(modifiedFileSet: Set<string>) {
199
- this.#modifiedFileSet.adds(...Array.from(modifiedFileSet).map((item) => path.normalize(item)));
199
+ for (const modifiedFile of Array.from(modifiedFileSet).map((item) => path.normalize(item))) {
200
+ this.#modifiedFileSet.add(modifiedFile);
201
+ this.#modifiedFileSet.adds(...(this.#resourceDependencyCacheMap.get(modifiedFile) ?? []));
202
+ }
200
203
  }
201
204
 
202
205
  async buildAsync(): Promise<ISdTsCompilerResult> {
203
- const affectedFileSet = new Set<string>();
206
+ const affectedSourceFileSet = new Set<ts.SourceFile>();
204
207
  const emitFileSet = new Set<string>();
205
208
 
206
209
  this.#debug(`get affected (old deps & old res deps)...`);
207
210
 
208
211
  for (const modifiedFile of this.#modifiedFileSet) {
209
- affectedFileSet.add(modifiedFile);
210
- affectedFileSet.adds(...(this.#revDependencyCacheMap.get(modifiedFile) ?? []));
211
- affectedFileSet.adds(...(this.#resourceDependencyCacheMap.get(modifiedFile) ?? []));
212
+ // affectedFileSet.add(modifiedFile);
213
+ // affectedFileSet.adds(...(this.#revDependencyCacheMap.get(modifiedFile) ?? []));
214
+ // affectedFileSet.adds(...(this.#resourceDependencyCacheMap.get(modifiedFile) ?? []));
212
215
 
213
216
  this.#emittedFilesCacheMap.delete(path.normalize(modifiedFile));
217
+ this.#sourceFileCacheMap.delete(path.normalize(modifiedFile));
218
+ this.#stylesheetBundlingResultMap.delete(path.normalize(modifiedFile));
219
+ this.#watchFileSet.delete(path.normalize(modifiedFile));
214
220
  }
221
+ this.#stylesheetBundler?.invalidate(this.#modifiedFileSet);
215
222
 
216
- this.#debug(`invalidate & clear cache...`);
223
+ // this.#debug(`invalidate & clear cache...`);
217
224
 
218
- this.#stylesheetBundler?.invalidate(this.#modifiedFileSet);
225
+ // this.#stylesheetBundler?.invalidate(affectedFileSet);
219
226
 
220
- for (const affectedFile of affectedFileSet) {
221
- this.#sourceFileCacheMap.delete(path.normalize(affectedFile));
222
- this.#stylesheetBundlingResultMap.delete(path.normalize(affectedFile));
223
- this.#watchFileSet.delete(path.normalize(affectedFile));
224
- }
227
+ // for (const affectedFile of affectedFileSet) {
228
+ // this.#sourceFileCacheMap.delete(path.normalize(affectedFile));
229
+ // this.#stylesheetBundlingResultMap.delete(path.normalize(affectedFile));
230
+ // this.#watchFileSet.delete(path.normalize(affectedFile));
231
+ // }
225
232
 
226
- this.#revDependencyCacheMap.clear();
233
+ // this.#revDependencyCacheMap.clear();
227
234
  this.#resourceDependencyCacheMap.clear();
228
235
 
229
236
  this.#debug(`create program...`);
@@ -245,6 +252,8 @@ export class SdTsCompiler {
245
252
  );
246
253
  }
247
254
 
255
+ this.#debug(`create builder...`);
256
+
248
257
  const baseGetSourceFiles = this.#program.getSourceFiles;
249
258
  this.#program.getSourceFiles = function (...parameters) {
250
259
  const files: readonly (ts.SourceFile & { version?: string })[] = baseGetSourceFiles(...parameters);
@@ -258,7 +267,7 @@ export class SdTsCompiler {
258
267
  return files;
259
268
  };
260
269
 
261
- this.#debug(`create builder...`);
270
+ this.#builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(this.#program, this.#compilerHost, this.#builder);
262
271
 
263
272
  if (this.#ngProgram) {
264
273
  await this.#ngProgram.compiler.analyzeAsync();
@@ -275,113 +284,169 @@ export class SdTsCompiler {
275
284
 
276
285
  this.#debug(`get affected (new deps)...`);
277
286
 
278
- const sourceFileSet = new Set(
279
- this.#program
280
- .getSourceFiles()
281
- .map((sf) => getOrgSourceFile(sf))
282
- .filterExists(),
283
- );
284
-
285
- const depMap = new Map<
286
- string,
287
- {
288
- fileName: string;
289
- importName: string;
290
- exportName?: string;
291
- }[]
292
- >();
293
- for (const sf of sourceFileSet) {
294
- const refs = this.#findDeps(sf);
295
- depMap.set(path.normalize(sf.fileName), refs);
296
- }
287
+ // const sourceFileSet = new Set(
288
+ // this.#program
289
+ // .getSourceFiles()
290
+ // .map((sf) => getOrgSourceFile(sf))
291
+ // .filterExists(),
292
+ // );
293
+
294
+ // const depMap = new Map<
295
+ // string,
296
+ // {
297
+ // fileName: string;
298
+ // importName: string;
299
+ // exportName?: string;
300
+ // }[]
301
+ // >();
302
+ // for (const sf of sourceFileSet) {
303
+ // const refs = this.#findDeps(sf);
304
+ // depMap.set(path.normalize(sf.fileName), refs);
305
+ // }
306
+ //
307
+ // const allDepMap = new Map<string, Set<string>>();
308
+ // const getAllDeps = (fileName: string, prevSet?: Set<string>) => {
309
+ // if (allDepMap.has(fileName)) {
310
+ // return allDepMap.get(fileName)!;
311
+ // }
312
+ //
313
+ // const result = new Set<string>();
314
+ //
315
+ // const deps = depMap.get(fileName) ?? [];
316
+ // result.adds(...deps.map((item) => item.fileName));
317
+ //
318
+ // for (const dep of deps) {
319
+ // const targetDeps = depMap.get(dep.fileName) ?? [];
320
+ //
321
+ // if (dep.importName === "*") {
322
+ // for (const targetRefItem of targetDeps.filter((item) => item.exportName != null)) {
323
+ // if (prevSet?.has(targetRefItem.fileName)) continue;
324
+ //
325
+ // result.add(targetRefItem.fileName);
326
+ // result.adds(...getAllDeps(targetRefItem.fileName, new Set<string>(prevSet).adds(...result)));
327
+ // }
328
+ // } else {
329
+ // for (const targetRefItem of targetDeps.filter((item) => item.exportName === dep.importName)) {
330
+ // if (prevSet?.has(targetRefItem.fileName)) continue;
331
+ //
332
+ // result.add(targetRefItem.fileName);
333
+ // result.adds(...getAllDeps(targetRefItem.fileName, new Set<string>(prevSet).adds(...result)));
334
+ // }
335
+ // }
336
+ // }
337
+ //
338
+ // return result;
339
+ // };
340
+
341
+ // for (const sf of sourceFileSet) {
342
+ // const deps = getAllDeps(path.normalize(sf.fileName));
343
+ // allDepMap.set(path.normalize(sf.fileName), deps);
344
+ //
345
+ // for (const dep of getAllDeps(path.normalize(sf.fileName))) {
346
+ // const depCache = this.#revDependencyCacheMap.getOrCreate(path.normalize(dep), new Set<string>());
347
+ // depCache.add(path.normalize(sf.fileName));
348
+ // if (this.#modifiedFileSet.has(path.normalize(dep))) {
349
+ // affectedFileSet.add(path.normalize(sf.fileName));
350
+ // }
351
+ // }
352
+ //
353
+ // if (this.#ngProgram) {
354
+ // if (this.#ngProgram.compiler.ignoreForEmit.has(sf)) {
355
+ // continue;
356
+ // }
357
+ //
358
+ // for (const dep of this.#ngProgram.compiler.getResourceDependencies(sf)) {
359
+ // const ref = this.#resourceDependencyCacheMap.getOrCreate(path.normalize(dep), new Set<string>());
360
+ // ref.add(path.normalize(sf.fileName));
361
+ // if (this.#modifiedFileSet.has(path.normalize(dep))) {
362
+ // affectedFileSet.add(path.normalize(sf.fileName));
363
+ // }
364
+ // }
365
+ // }
366
+ // }
367
+
368
+ // if (affectedFileSet.size === 0) {
369
+ // this.#debug(`get affected (init)...`);
370
+ //
371
+ // for (const sf of this.#program.getSourceFiles()) {
372
+ // const orgSf = getOrgSourceFile(sf);
373
+ // if (!orgSf) continue;
374
+ //
375
+ // affectedFileSet.add(path.normalize(orgSf.fileName));
376
+ // }
377
+ // }
297
378
 
298
- const allDepMap = new Map<string, Set<string>>();
299
- const getAllDeps = (fileName: string, prevSet?: Set<string>) => {
300
- if (allDepMap.has(fileName)) {
301
- return allDepMap.get(fileName)!;
302
- }
303
-
304
- const result = new Set<string>();
379
+ this.#debug(`get diagnostics...`);
305
380
 
306
- const deps = depMap.get(fileName) ?? [];
307
- result.adds(...deps.map((item) => item.fileName));
381
+ const diagnostics: ts.Diagnostic[] = [];
308
382
 
309
- for (const dep of deps) {
310
- const targetDeps = depMap.get(dep.fileName) ?? [];
383
+ diagnostics.push(
384
+ ...this.#builder.getConfigFileParsingDiagnostics(),
385
+ ...this.#builder.getOptionsDiagnostics(),
386
+ ...this.#builder.getGlobalDiagnostics(),
387
+ );
311
388
 
312
- if (dep.importName === "*") {
313
- for (const targetRefItem of targetDeps.filter((item) => item.exportName != null)) {
314
- if (prevSet?.has(targetRefItem.fileName)) continue;
389
+ /*diagnostics.push(
390
+ ...this.#program.getConfigFileParsingDiagnostics(),
391
+ ...this.#program.getOptionsDiagnostics(),
392
+ ...this.#program.getGlobalDiagnostics(),
393
+ );*/
315
394
 
316
- result.add(targetRefItem.fileName);
317
- result.adds(...getAllDeps(targetRefItem.fileName, new Set<string>(prevSet).adds(...result)));
318
- }
319
- } else {
320
- for (const targetRefItem of targetDeps.filter((item) => item.exportName === dep.importName)) {
321
- if (prevSet?.has(targetRefItem.fileName)) continue;
395
+ if (this.#ngProgram) {
396
+ diagnostics.push(...this.#ngProgram.compiler.getOptionDiagnostics());
397
+ }
322
398
 
323
- result.add(targetRefItem.fileName);
324
- result.adds(...getAllDeps(targetRefItem.fileName, new Set<string>(prevSet).adds(...result)));
399
+ this.#debug(`get diagnostics of files...`);
400
+
401
+ while (true) {
402
+ const affectedFileResult = this.#builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sf) => {
403
+ if (
404
+ this.#ngProgram &&
405
+ this.#ngProgram.compiler.ignoreForDiagnostics.has(sf) &&
406
+ sf.fileName.endsWith(".ngtypecheck.ts")
407
+ ) {
408
+ const orgSourceFile = getOrgSourceFile(sf);
409
+ if (orgSourceFile) {
410
+ affectedSourceFileSet.add(orgSourceFile);
325
411
  }
412
+ return true;
326
413
  }
327
- }
414
+ return false;
415
+ });
416
+ if (!affectedFileResult) break;
328
417
 
329
- return result;
330
- };
418
+ const affectedSourceFile = affectedFileResult.affected as ts.SourceFile;
419
+
420
+ affectedSourceFileSet.add(affectedSourceFile);
421
+ }
331
422
 
332
- for (const sf of sourceFileSet) {
333
- const deps = getAllDeps(path.normalize(sf.fileName));
334
- allDepMap.set(path.normalize(sf.fileName), deps);
423
+ for (const affectedSourceFile of affectedSourceFileSet) {
424
+ this.#debug(`get diagnostics of file [${affectedSourceFile.fileName}]`);
335
425
 
336
- for (const dep of getAllDeps(path.normalize(sf.fileName))) {
337
- const depCache = this.#revDependencyCacheMap.getOrCreate(path.normalize(dep), new Set<string>());
338
- depCache.add(path.normalize(sf.fileName));
339
- if (this.#modifiedFileSet.has(path.normalize(dep))) {
340
- affectedFileSet.add(path.normalize(sf.fileName));
341
- }
342
- }
426
+ diagnostics.push(
427
+ ...this.#program.getSyntacticDiagnostics(affectedSourceFile),
428
+ ...this.#program.getSemanticDiagnostics(affectedSourceFile),
429
+ );
343
430
 
344
431
  if (this.#ngProgram) {
345
- if (this.#ngProgram.compiler.ignoreForEmit.has(sf)) {
432
+ if (affectedSourceFile.isDeclarationFile) {
346
433
  continue;
347
434
  }
348
435
 
349
- for (const dep of this.#ngProgram.compiler.getResourceDependencies(sf)) {
350
- const ref = this.#resourceDependencyCacheMap.getOrCreate(path.normalize(dep), new Set<string>());
351
- ref.add(path.normalize(sf.fileName));
352
- if (this.#modifiedFileSet.has(path.normalize(dep))) {
353
- affectedFileSet.add(path.normalize(sf.fileName));
354
- }
355
- }
436
+ diagnostics.push(
437
+ ...this.#ngProgram.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram),
438
+ );
356
439
  }
357
440
  }
358
441
 
359
- if (affectedFileSet.size === 0) {
360
- this.#debug(`get affected (init)...`);
361
-
362
- for (const sf of this.#program.getSourceFiles()) {
363
- const orgSf = getOrgSourceFile(sf);
364
- if (!orgSf) continue;
365
-
366
- affectedFileSet.add(path.normalize(orgSf.fileName));
442
+ /*
443
+ for (const affectedFile of affectedFileSet) {
444
+ if (!PathUtil.isChildPath(affectedFile, this.#pkgPath)) {
445
+ continue;
367
446
  }
368
- }
369
-
370
- this.#debug(`get diagnostics...`);
371
-
372
- const diagnostics: ts.Diagnostic[] = [];
373
-
374
- diagnostics.push(
375
- ...this.#program.getConfigFileParsingDiagnostics(),
376
- ...this.#program.getOptionsDiagnostics(),
377
- ...this.#program.getGlobalDiagnostics(),
378
- );
379
447
 
380
- if (this.#ngProgram) {
381
- diagnostics.push(...this.#ngProgram.compiler.getOptionDiagnostics());
382
- }
448
+ this.#debug(`get diagnostics of file [${affectedFile}]`);
383
449
 
384
- for (const affectedFile of affectedFileSet) {
385
450
  const affectedSourceFile = this.#program.getSourceFile(affectedFile);
386
451
  if (
387
452
  !affectedSourceFile ||
@@ -390,10 +455,6 @@ export class SdTsCompiler {
390
455
  continue;
391
456
  }
392
457
 
393
- if (!PathUtil.isChildPath(affectedFile, this.#pkgPath)) {
394
- continue;
395
- }
396
-
397
458
  diagnostics.push(
398
459
  ...this.#program.getSyntacticDiagnostics(affectedSourceFile),
399
460
  ...this.#program.getSemanticDiagnostics(affectedSourceFile),
@@ -408,7 +469,7 @@ export class SdTsCompiler {
408
469
  ...this.#ngProgram.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram),
409
470
  );
410
471
  }
411
- }
472
+ }*/
412
473
 
413
474
  this.#debug(`prepare emit...`);
414
475
 
@@ -421,7 +482,59 @@ export class SdTsCompiler {
421
482
  };
422
483
  (transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
423
484
  }
424
- (transformers.before ??= []).push(transformKeys(this.#program));
485
+ // (transformers.before ??= []).push(transformKeys(this.#program));
486
+
487
+ this.#debug(`prepare emit files...`);
488
+
489
+ while (
490
+ this.#builder.emitNextAffectedFile(
491
+ (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
492
+ if (!sourceFiles || sourceFiles.length === 0) {
493
+ this.#compilerHost.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
494
+ return;
495
+ }
496
+
497
+ const sourceFile = ts.getOriginalNode(sourceFiles[0], ts.isSourceFile);
498
+ if (this.#ngProgram) {
499
+ if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) {
500
+ return;
501
+ }
502
+ this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
503
+ }
504
+
505
+ const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(path.normalize(sourceFile.fileName), []);
506
+ if (PathUtil.isChildPath(sourceFile.fileName, this.#pkgPath)) {
507
+ let realFilePath = fileName;
508
+ let realText = text;
509
+ if (PathUtil.isChildPath(realFilePath, path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"))) {
510
+ realFilePath = path.resolve(
511
+ this.#distPath,
512
+ path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
513
+ );
514
+
515
+ if (fileName.endsWith(".js.map")) {
516
+ const sourceMapContents = JSON.parse(realText);
517
+ // remove "../../"
518
+ sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
519
+ realText = JSON.stringify(sourceMapContents);
520
+ }
521
+ }
522
+
523
+ emitFileInfoCaches.push({
524
+ outAbsPath: realFilePath,
525
+ text: realText,
526
+ });
527
+ } else {
528
+ emitFileInfoCaches.push({ text });
529
+ }
530
+
531
+ emitFileSet.add(path.normalize(sourceFile.fileName));
532
+ },
533
+ undefined,
534
+ undefined,
535
+ transformers,
536
+ )
537
+ ) {}
425
538
 
426
539
  // affected에 새로 추가된 파일은 포함되지 않는 현상이 있어 getSourceFiles로 바꿈
427
540
  // 비교해보니, 딱히 getSourceFiles라서 더 느려지는것 같지는 않음
@@ -435,7 +548,7 @@ export class SdTsCompiler {
435
548
  continue;
436
549
  }*/
437
550
 
438
- for (const sf of sourceFileSet) {
551
+ /*for (const sf of sourceFileSet) {
439
552
  if (this.#emittedFilesCacheMap.has(path.normalize(sf.fileName))) {
440
553
  continue;
441
554
  }
@@ -504,7 +617,7 @@ export class SdTsCompiler {
504
617
  undefined,
505
618
  transformers,
506
619
  );
507
- }
620
+ }*/
508
621
 
509
622
  //-- global style
510
623
  if (
@@ -531,6 +644,7 @@ export class SdTsCompiler {
531
644
 
532
645
  this.#modifiedFileSet.clear();
533
646
 
647
+ const affectedFileSet = new Set(Array.from(affectedSourceFileSet).map((item) => path.normalize(item.fileName)));
534
648
  this.#debug(`build completed`, affectedFileSet, diagnostics.length);
535
649
 
536
650
  //-- result
@@ -550,7 +664,7 @@ export class SdTsCompiler {
550
664
  this.#logger.debug(`[${path.basename(this.#pkgPath)}]`, ...msg);
551
665
  }
552
666
 
553
- #findDeps(sf: ts.SourceFile) {
667
+ /*#findDeps(sf: ts.SourceFile) {
554
668
  const deps: {
555
669
  fileName: string;
556
670
  importName: string;
@@ -604,9 +718,9 @@ export class SdTsCompiler {
604
718
  importName: "*",
605
719
  });
606
720
  }
607
- /*else {
721
+ /!*else {
608
722
  throw new NeverEntryError(`import moduleSymbol: ${sf.fileName} ${node.moduleSpecifier["text"]}`);
609
- }*/
723
+ }*!/
610
724
  } else {
611
725
  const decls = moduleSymbol.getDeclarations();
612
726
  if (!decls) throw new NeverEntryError(`import decls: ${sf.fileName}`);
@@ -634,7 +748,7 @@ export class SdTsCompiler {
634
748
  });
635
749
 
636
750
  return deps;
637
- }
751
+ }*/
638
752
  }
639
753
 
640
754
  export interface ISdTsCompilerResult {
@@ -168,11 +168,7 @@ export class SdCliClientBuilder extends EventEmitter {
168
168
  // oldProgram: this.#program
169
169
  // });
170
170
  // const pkgFilePaths = filePaths.filter(item => PathUtil.isChildPath(item, this._pkgPath));
171
- const lintResults = await SdLinter.lintAsync(
172
- this._pkgPath,
173
- affectedFileSet,
174
- firstProgram,
175
- );
171
+ const lintResults = await SdLinter.lintAsync(this._pkgPath, affectedFileSet, firstProgram);
176
172
 
177
173
  if (!opt.dev && this._cordova) {
178
174
  this._debug("CORDOVA BUILD...");
@@ -47,7 +47,9 @@ export class SdCliProject {
47
47
  if (!projNpmConf.workspaces) {
48
48
  throw new Error("프로젝트 package.json에 workspaces가 설정되어있지 않습니다.");
49
49
  }
50
- const allPkgPaths = await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item));
50
+ const allPkgPaths = (
51
+ await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item))
52
+ ).filter((item) => !item.includes("."));
51
53
  let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
52
54
  if (opt.pkgNames.length !== 0) {
53
55
  pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
@@ -330,7 +332,9 @@ export class SdCliProject {
330
332
  if (!projNpmConf.workspaces) {
331
333
  throw new Error("프로젝트 package.json에 workspaces가 설정되어있지 않습니다.");
332
334
  }
333
- const allPkgPaths = await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item));
335
+ const allPkgPaths = (
336
+ await projNpmConf.workspaces.mapManyAsync(async (item) => await FsUtil.globAsync(item))
337
+ ).filter((item) => !item.includes("."));
334
338
  let pkgPaths = allPkgPaths.filter((pkgPath) => path.basename(pkgPath) in projConf.packages);
335
339
  if (opt.pkgNames.length !== 0) {
336
340
  pkgPaths = pkgPaths.filter((pkgPath) => opt.pkgNames.includes(path.basename(pkgPath)));
package/src/index.ts CHANGED
@@ -11,7 +11,6 @@ export * from "./builders/SdCliClientBuilder";
11
11
  export * from "./builders/SdCliJsLibLinter";
12
12
  export * from "./builders/SdCliServerBuilder";
13
13
  export * from "./builders/SdCliTsLibBuilder";
14
- export * from "./bundle-plugins/KeysTransformer";
15
14
  export * from "./bundle-plugins/sdNgPlugin";
16
15
  export * from "./bundle-plugins/sdServerPlugin";
17
16
  export * from "./commons";
package/tsconfig.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
- "extends": "../../tsconfig.json",
2
+ "extends": "../tsconfig.json",
3
3
  "compilerOptions": {
4
- "lib": [
5
- "ES2021"
6
- ],
7
- "outDir": "./dist"
4
+ "lib": ["ES2021"],
5
+ "outDir": "./dist",
6
+ "types": ["node", "eslint", "yargs"]
8
7
  },
9
- "files": [
10
- "src/index.ts",
11
- "src/sd-cli.ts",
12
- "src/build-cluster.ts",
13
- "src/server-worker.ts"
14
- ]
8
+ "files": ["./src/index.ts", "./src/sd-cli.ts", "./src/build-cluster.ts", "./src/server-worker.ts"]
15
9
  }
@@ -1,2 +0,0 @@
1
- import ts from 'typescript';
2
- export declare function keysTransformer(program: ts.Program): ts.TransformerFactory<ts.SourceFile>;
@@ -1,61 +0,0 @@
1
- import ts from 'typescript';
2
- import path from 'path';
3
- const createArrayExpression = ts.factory.createArrayLiteralExpression;
4
- const createStringLiteral = ts.factory.createStringLiteral;
5
- export function keysTransformer(program) {
6
- return (context) => (file) => visitNodeAndChildren(file, program, context);
7
- }
8
- function visitNodeAndChildren(node, program, context) {
9
- return ts.visitEachChild(visitNode(node, program), childNode => visitNodeAndChildren(childNode, program, context), context);
10
- }
11
- function visitNode(node, program) {
12
- const typeChecker = program.getTypeChecker();
13
- if (isKeysImportExpression(node)) {
14
- return;
15
- }
16
- if (!isKeysCallExpression(node, typeChecker)) {
17
- return node;
18
- }
19
- if (!node.typeArguments) {
20
- return createArrayExpression([]);
21
- }
22
- const type = typeChecker.getTypeFromTypeNode(node.typeArguments[0]);
23
- const properties = typeChecker.getPropertiesOfType(type);
24
- return createArrayExpression(properties.map(property => createStringLiteral(property.name)));
25
- }
26
- const indexJs = path.join(__dirname, 'index.js');
27
- function isKeysImportExpression(node) {
28
- if (!ts.isImportDeclaration(node)) {
29
- return false;
30
- }
31
- const module = node.moduleSpecifier.text;
32
- try {
33
- return indexJs === (module.startsWith('.')
34
- ? require.resolve(path.resolve(path.dirname(node.getSourceFile().fileName), module))
35
- : require.resolve(module));
36
- }
37
- catch {
38
- return false;
39
- }
40
- }
41
- const indexTs = path.join(__dirname, 'index.d.ts');
42
- function isKeysCallExpression(node, typeChecker) {
43
- if (!ts.isCallExpression(node)) {
44
- return false;
45
- }
46
- const declaration = typeChecker.getResolvedSignature(node)?.declaration;
47
- if (!declaration || ts.isJSDocSignature(declaration) || declaration.name?.getText() !== 'keys') {
48
- return false;
49
- }
50
- try {
51
- // require.resolve is required to resolve symlink.
52
- // https://github.com/kimamula/ts-transformer-keys/issues/4#issuecomment-643734716
53
- return require.resolve(declaration.getSourceFile().fileName) === indexTs;
54
- }
55
- catch {
56
- // declaration.getSourceFile().fileName may not be in Node.js require stack and require.resolve may result in an error.
57
- // https://github.com/kimamula/ts-transformer-keys/issues/47
58
- return false;
59
- }
60
- }
61
- //# sourceMappingURL=KeysTransformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"KeysTransformer.js","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