@simplysm/sd-cli 12.5.50 → 12.5.52

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.
@@ -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"));
@@ -99,7 +99,8 @@ export class SdTsCompiler {
99
99
 
100
100
  if (sf) {
101
101
  this.#sourceFileCacheMap.set(PathUtil.norm(fileName), sf);
102
- } else {
102
+ }
103
+ else {
103
104
  this.#sourceFileCacheMap.delete(PathUtil.norm(fileName));
104
105
  }
105
106
 
@@ -120,22 +121,22 @@ export class SdTsCompiler {
120
121
  optimization: !opt.isDevMode,
121
122
  inlineFonts: true,
122
123
  preserveSymlinks: false,
123
- sourcemap: opt.isDevMode ? 'inline' : false,
124
+ sourcemap: opt.isDevMode ? "inline" : false,
124
125
  outputNames: { bundles: "[name]", media: "media/[name]" },
125
126
  includePaths: [],
126
127
  externalDependencies: [],
127
128
  target: transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"])),
128
129
  postcssConfiguration: {
129
- plugins: [["css-has-pseudo"]],
130
+ plugins: [["css-has-pseudo"]]
130
131
  },
131
132
  tailwindConfiguration: undefined,
132
133
  cacheOptions: {
133
134
  enabled: true,
134
135
  path: ".cache/angular",
135
- basePath: ".cache",
136
- },
136
+ basePath: ".cache"
137
+ }
137
138
  },
138
- opt.isDevMode,
139
+ opt.isDevMode
139
140
  );
140
141
 
141
142
  //-- compilerHost
@@ -150,7 +151,7 @@ export class SdTsCompiler {
150
151
  type: string;
151
152
  containingFile: string;
152
153
  resourceFile: string | null;
153
- },
154
+ }
154
155
  ) => {
155
156
  if (context.type !== "style") {
156
157
  return null;
@@ -159,7 +160,7 @@ export class SdTsCompiler {
159
160
  const contents = await this.#bundleStylesheetAsync(
160
161
  data,
161
162
  PathUtil.norm(context.containingFile),
162
- context.resourceFile != null ? PathUtil.norm(context.resourceFile) : undefined,
163
+ context.resourceFile != null ? PathUtil.norm(context.resourceFile) : undefined
163
164
  );
164
165
 
165
166
  return StringUtil.isNullOrEmpty(contents) ? null : { content: contents };
@@ -188,13 +189,13 @@ export class SdTsCompiler {
188
189
  for (const referencedFile of stylesheetResult.referencedFiles) {
189
190
  const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(
190
191
  PathUtil.norm(referencedFile),
191
- new Set<TNormPath>(),
192
+ new Set<TNormPath>()
192
193
  );
193
194
  depCacheSet.add(resourceFile ?? containingFile);
194
195
  }
195
196
 
196
197
  this.#watchFileSet.adds(
197
- ...Array.from(stylesheetResult.referencedFiles.values()).map((item) => PathUtil.norm(item)),
198
+ ...Array.from(stylesheetResult.referencedFiles.values()).map((item) => PathUtil.norm(item))
198
199
  );
199
200
  }
200
201
 
@@ -202,7 +203,7 @@ export class SdTsCompiler {
202
203
  outputFiles: stylesheetResult.outputFiles,
203
204
  metafile: stylesheetResult.metafile,
204
205
  errors: stylesheetResult.errors,
205
- warnings: stylesheetResult.warnings,
206
+ warnings: stylesheetResult.warnings
206
207
  });
207
208
 
208
209
  return stylesheetResult.contents;
@@ -234,13 +235,13 @@ export class SdTsCompiler {
234
235
  messages: [
235
236
  ...prepareResult.messages,
236
237
  ...SdCliConvertMessageUtil.convertToBuildMessagesFromTsDiag(buildResult.diagnostics),
237
- ...SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults),
238
+ ...SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults)
238
239
  ],
239
240
  watchFileSet: this.#watchFileSet,
240
241
  affectedFileSet: this.#affectedFileSet,
241
242
  stylesheetBundlingResultMap: this.#stylesheetBundlingResultMap,
242
243
  emittedFilesCacheMap: this.#emittedFilesCacheMap,
243
- emitFileSet: buildResult.emitFileSet,
244
+ emitFileSet: buildResult.emitFileSet
244
245
  };
245
246
  }
246
247
 
@@ -282,15 +283,16 @@ export class SdTsCompiler {
282
283
  this.#parsedTsconfig.fileNames,
283
284
  this.#parsedTsconfig.options,
284
285
  this.#compilerHost,
285
- this.#ngProgram,
286
+ this.#ngProgram
286
287
  );
287
288
  this.#program = this.#ngProgram.getTsProgram();
288
- } else {
289
+ }
290
+ else {
289
291
  this.#program = ts.createProgram(
290
292
  this.#parsedTsconfig.fileNames,
291
293
  this.#parsedTsconfig.options,
292
294
  this.#compilerHost,
293
- this.#program,
295
+ this.#program
294
296
  );
295
297
  }
296
298
  });
@@ -313,7 +315,7 @@ export class SdTsCompiler {
313
315
  const sourceFileSet = new Set(
314
316
  this.#program!.getSourceFiles()
315
317
  .map((sf) => getOrgSourceFile(sf))
316
- .filterExists(),
318
+ .filterExists()
317
319
  );
318
320
 
319
321
  this.#debug(`get new deps...`);
@@ -341,8 +343,8 @@ export class SdTsCompiler {
341
343
  refs
342
344
  .filter((item) => "fileName" in item)
343
345
  .filter((item) =>
344
- this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(item.fileName, scopePath)),
345
- ),
346
+ this.#watchScopePaths.some((scopePath) => PathUtil.isChildPath(item.fileName, scopePath))
347
+ )
346
348
  );
347
349
  }
348
350
 
@@ -367,7 +369,8 @@ export class SdTsCompiler {
367
369
  result.add(targetRefItem.fileName);
368
370
  result.adds(...getAllDeps(targetRefItem.fileName, new Set<TNormPath>(prevSet).adds(...result)));
369
371
  }
370
- } else {
372
+ }
373
+ else {
371
374
  for (const targetRefItem of targetDeps.filter((item) => item.exportName === dep.importName)) {
372
375
  if (prevSet?.has(targetRefItem.fileName)) continue;
373
376
 
@@ -423,9 +426,9 @@ export class SdTsCompiler {
423
426
  [
424
427
  item,
425
428
  // .d.ts면 .js파일도 affected에 추가
426
- item.endsWith(".d.ts") ? PathUtil.norm(item.replace(/\.d\.ts$/, ".js")) : undefined,
427
- ].filterExists(),
428
- ),
429
+ item.endsWith(".d.ts") ? PathUtil.norm(item.replace(/\.d\.ts$/, ".js")) : undefined
430
+ ].filterExists()
431
+ )
429
432
  );
430
433
  }
431
434
 
@@ -451,7 +454,7 @@ export class SdTsCompiler {
451
454
  }
452
455
 
453
456
  return {
454
- messages,
457
+ messages
455
458
  };
456
459
  }
457
460
 
@@ -459,8 +462,8 @@ export class SdTsCompiler {
459
462
  return await this.#lintWorker.run("lint", [
460
463
  {
461
464
  cwd: this.#pkgPath,
462
- fileSet: this.#affectedFileSet,
463
- },
465
+ fileSet: this.#affectedFileSet
466
+ }
464
467
  ]);
465
468
  }
466
469
 
@@ -474,7 +477,7 @@ export class SdTsCompiler {
474
477
  diagnostics.push(
475
478
  ...this.#program!.getConfigFileParsingDiagnostics(),
476
479
  ...this.#program!.getOptionsDiagnostics(),
477
- ...this.#program!.getGlobalDiagnostics(),
480
+ ...this.#program!.getGlobalDiagnostics()
478
481
  );
479
482
 
480
483
  if (this.#ngProgram) {
@@ -503,7 +506,7 @@ export class SdTsCompiler {
503
506
  this.#perf.run("get file diagnostics", () => {
504
507
  diagnostics.push(
505
508
  ...this.#program!.getSyntacticDiagnostics(affectedSourceFile),
506
- ...this.#program!.getSemanticDiagnostics(affectedSourceFile),
509
+ ...this.#program!.getSemanticDiagnostics(affectedSourceFile)
507
510
  );
508
511
  });
509
512
 
@@ -514,7 +517,7 @@ export class SdTsCompiler {
514
517
  }
515
518
 
516
519
  diagnostics.push(
517
- ...this.#ngProgram!.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram),
520
+ ...this.#ngProgram!.compiler.getDiagnosticsForFile(affectedSourceFile, OptimizeFor.WholeProgram)
518
521
  );
519
522
  });
520
523
  }
@@ -528,7 +531,7 @@ export class SdTsCompiler {
528
531
  if (this.#ngProgram) {
529
532
  transformers = {
530
533
  ...transformers,
531
- ...this.#ngProgram.compiler.prepareEmit().transformers,
534
+ ...this.#ngProgram.compiler.prepareEmit().transformers
532
535
  };
533
536
  (transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
534
537
  (transformers.before ??= []).push(
@@ -536,7 +539,7 @@ export class SdTsCompiler {
536
539
  const fullPath = path.resolve(path.dirname(importer), file);
537
540
  const relPath = path.relative(path.resolve(this.#pkgPath, "src"), fullPath);
538
541
  return relPath.replace(/\.ts$/, "").replaceAll("\\", "/") + ".js";
539
- }),
542
+ })
540
543
  );
541
544
  }
542
545
  // (transformers.before ??= []).push(transformKeys(this.#program));
@@ -601,7 +604,7 @@ export class SdTsCompiler {
601
604
  ) {
602
605
  realFilePath = PathUtil.norm(
603
606
  this.#distPath,
604
- path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
607
+ path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath)
605
608
  );
606
609
 
607
610
  if (fileName.endsWith(".js.map")) {
@@ -614,9 +617,10 @@ export class SdTsCompiler {
614
617
 
615
618
  emitFileInfoCaches.push({
616
619
  outAbsPath: realFilePath,
617
- text: realText,
620
+ text: realText
618
621
  });
619
- } else {
622
+ }
623
+ else {
620
624
  emitFileInfoCaches.push({ text });
621
625
  }
622
626
 
@@ -624,7 +628,7 @@ export class SdTsCompiler {
624
628
  },
625
629
  undefined,
626
630
  undefined,
627
- transformers,
631
+ transformers
628
632
  );
629
633
  }
630
634
  });
@@ -644,9 +648,9 @@ export class SdTsCompiler {
644
648
  emitFileInfos.push({
645
649
  outAbsPath: PathUtil.norm(
646
650
  this.#pkgPath,
647
- path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!).replace(/\.scss$/, ".css"),
651
+ path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath!).replace(/\.scss$/, ".css")
648
652
  ),
649
- text: contents,
653
+ text: contents
650
654
  });
651
655
  emitFileSet.add(this.#globalStyleFilePath!);
652
656
  });
@@ -654,7 +658,7 @@ export class SdTsCompiler {
654
658
 
655
659
  return {
656
660
  emitFileSet,
657
- diagnostics,
661
+ diagnostics
658
662
  };
659
663
  }
660
664
 
@@ -664,18 +668,16 @@ export class SdTsCompiler {
664
668
 
665
669
  #findDeps(sf: ts.SourceFile) {
666
670
  const deps: (
667
- | {
668
- fileName: TNormPath;
669
- importName: string;
670
- exportName?: string;
671
- }
672
- // | ts.Diagnostic
673
- | ISdBuildMessage
674
- )[] = [];
671
+ {
672
+ fileName: TNormPath;
673
+ importName: string;
674
+ exportName?: string;
675
+ } | ISdBuildMessage
676
+ )[] = [];
675
677
 
676
678
  const tc = this.#program!.getTypeChecker();
677
679
 
678
- sf.forEachChild((node) => {
680
+ const visit = (node: ts.Node) => {
679
681
  if (ts.isExportDeclaration(node)) {
680
682
  if (node.moduleSpecifier) {
681
683
  const moduleSymbol = tc.getSymbolAtLocation(node.moduleSpecifier);
@@ -688,7 +690,7 @@ export class SdTsCompiler {
688
690
  code: undefined,
689
691
  severity: "error",
690
692
  message: "export moduleSymbol not found",
691
- type: "deps",
693
+ type: "deps"
692
694
  });
693
695
  return;
694
696
  }
@@ -703,7 +705,7 @@ export class SdTsCompiler {
703
705
  code: undefined,
704
706
  severity: "error",
705
707
  message: "export decls not found",
706
- type: "deps",
708
+ type: "deps"
707
709
  });
708
710
  return;
709
711
  }
@@ -715,11 +717,12 @@ export class SdTsCompiler {
715
717
  deps.push({
716
718
  fileName: PathUtil.norm(decl.getSourceFile().fileName),
717
719
  importName: el.name.text,
718
- exportName: el.propertyName?.text ?? el.name.text,
720
+ exportName: el.propertyName?.text ?? el.name.text
719
721
  });
720
722
  }
721
723
  }
722
- } else {
724
+ }
725
+ else {
723
726
  if (!moduleSymbol.exports) {
724
727
  const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
725
728
  deps.push({
@@ -729,7 +732,7 @@ export class SdTsCompiler {
729
732
  code: undefined,
730
733
  severity: "error",
731
734
  message: "moduleSymbol exports not found",
732
- type: "deps",
735
+ type: "deps"
733
736
  });
734
737
  return;
735
738
  }
@@ -739,25 +742,27 @@ export class SdTsCompiler {
739
742
  deps.push({
740
743
  fileName: PathUtil.norm(decl.getSourceFile().fileName),
741
744
  importName: key.toString(),
742
- exportName: key.toString(),
745
+ exportName: key.toString()
743
746
  });
744
747
  }
745
748
  }
746
749
  }
747
750
  }
748
- } else if (ts.isImportDeclaration(node)) {
751
+ }
752
+ else if (ts.isImportDeclaration(node)) {
749
753
  const moduleSymbol = tc.getSymbolAtLocation(node.moduleSpecifier);
750
754
  if (!moduleSymbol) {
751
755
  if (ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith("./")) {
752
756
  deps.push({
753
757
  fileName: PathUtil.norm(path.resolve(path.dirname(sf.fileName), node.moduleSpecifier.text)),
754
- importName: "*",
758
+ importName: "*"
755
759
  });
756
760
  }
757
761
  /*else {
758
762
  throw new NeverEntryError(`import moduleSymbol: ${sf.fileName} ${node.moduleSpecifier["text"]}`);
759
763
  }*/
760
- } else {
764
+ }
765
+ else {
761
766
  const decls = moduleSymbol.getDeclarations();
762
767
  if (!decls) {
763
768
  const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
@@ -768,7 +773,7 @@ export class SdTsCompiler {
768
773
  code: undefined,
769
774
  severity: "error",
770
775
  message: "import decls not found",
771
- type: "deps",
776
+ type: "deps"
772
777
  });
773
778
  return;
774
779
  }
@@ -779,21 +784,35 @@ export class SdTsCompiler {
779
784
  for (const decl of decls) {
780
785
  deps.push({
781
786
  fileName: PathUtil.norm(decl.getSourceFile().fileName),
782
- importName: el.name.text,
787
+ importName: el.name.text
783
788
  });
784
789
  }
785
790
  }
786
- } else {
791
+ }
792
+ else {
787
793
  for (const decl of decls) {
788
794
  deps.push({
789
795
  fileName: PathUtil.norm(decl.getSourceFile().fileName),
790
- importName: "*",
796
+ importName: "*"
791
797
  });
792
798
  }
793
799
  }
794
800
  }
795
801
  }
796
- });
802
+
803
+ if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
804
+ if (ts.isStringLiteral(node.arguments[0]) && node.arguments[0].text.startsWith("./")) {
805
+ deps.push({
806
+ fileName: PathUtil.norm(path.resolve(path.dirname(sf.fileName), node.arguments[0].text)),
807
+ importName: "*"
808
+ });
809
+ }
810
+ }
811
+
812
+ node.forEachChild(visit);
813
+ };
814
+
815
+ sf.forEachChild(visit);
797
816
 
798
817
  return deps;
799
818
  }
package/tsconfig.json CHANGED
@@ -2,14 +2,6 @@
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "lib": ["ES2021"],
5
- "outDir": "./dist",
6
- "types": ["node", "eslint", "yargs"]
7
- },
8
- "files": [
9
- "./src/index.ts",
10
- "./src/sd-cli.ts",
11
- "./src/workers/build-runner-worker.ts",
12
- "./src/workers/lint-worker.ts",
13
- "./src/workers/server-worker.ts"
14
- ]
5
+ "outDir": "./dist"
6
+ }
15
7
  }