@simplysm/sd-cli 12.11.6 → 12.11.8

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.
Files changed (88) hide show
  1. package/dist/entry/sd-cli-cordova.d.ts +2 -34
  2. package/dist/entry/sd-cli-cordova.js +89 -85
  3. package/dist/entry/sd-cli-cordova.js.map +1 -1
  4. package/dist/entry/sd-cli-electron.d.ts +1 -5
  5. package/dist/entry/sd-cli-electron.js +21 -21
  6. package/dist/entry/sd-cli-electron.js.map +1 -1
  7. package/dist/entry/sd-cli-local-update.d.ts +1 -1
  8. package/dist/entry/sd-cli-local-update.js +3 -3
  9. package/dist/entry/sd-cli-local-update.js.map +1 -1
  10. package/dist/entry/sd-cli-project.d.ts +1 -4
  11. package/dist/entry/sd-cli-project.js +11 -11
  12. package/dist/entry/sd-cli-project.js.map +1 -1
  13. package/dist/fix/convert-private-to-hash.d.ts +1 -0
  14. package/dist/fix/convert-private-to-hash.js +59 -0
  15. package/dist/fix/convert-private-to-hash.js.map +1 -0
  16. package/dist/pkg-builders/client/sd-client.build-runner.d.ts +1 -2
  17. package/dist/pkg-builders/client/sd-client.build-runner.js +11 -9
  18. package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
  19. package/dist/pkg-builders/client/sd-ng.bundler-context.d.ts +3 -5
  20. package/dist/pkg-builders/client/sd-ng.bundler-context.js +10 -9
  21. package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +1 -1
  22. package/dist/pkg-builders/client/sd-ng.bundler.d.ts +2 -22
  23. package/dist/pkg-builders/client/sd-ng.bundler.js +76 -67
  24. package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
  25. package/dist/pkg-builders/commons/scope-path.d.ts +1 -1
  26. package/dist/pkg-builders/commons/scope-path.js +4 -3
  27. package/dist/pkg-builders/commons/scope-path.js.map +1 -1
  28. package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +1 -1
  29. package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +2 -2
  30. package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +1 -1
  31. package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +1 -1
  32. package/dist/pkg-builders/lib/sd-js-lib.build-runner.js +2 -2
  33. package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +1 -1
  34. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +1 -1
  35. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +3 -2
  36. package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
  37. package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +2 -2
  38. package/dist/pkg-builders/lib/sd-ts-lib.builder.js +3 -2
  39. package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +1 -1
  40. package/dist/pkg-builders/sd-multi.build-runner.d.ts +1 -6
  41. package/dist/pkg-builders/sd-multi.build-runner.js +27 -30
  42. package/dist/pkg-builders/sd-multi.build-runner.js.map +1 -1
  43. package/dist/pkg-builders/server/sd-server.build-runner.d.ts +1 -4
  44. package/dist/pkg-builders/server/sd-server.build-runner.js +11 -9
  45. package/dist/pkg-builders/server/sd-server.build-runner.js.map +1 -1
  46. package/dist/pkg-builders/server/sd-server.bundler.d.ts +2 -6
  47. package/dist/pkg-builders/server/sd-server.bundler.js +19 -18
  48. package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
  49. package/dist/sd-cli-entry.js +17 -7
  50. package/dist/sd-cli-entry.js.map +1 -1
  51. package/dist/ts-compiler/sd-dependency-cache.d.ts +1 -8
  52. package/dist/ts-compiler/sd-dependency-cache.js +37 -39
  53. package/dist/ts-compiler/sd-dependency-cache.js.map +1 -1
  54. package/dist/ts-compiler/sd-ts-compiler.d.ts +1 -19
  55. package/dist/ts-compiler/sd-ts-compiler.js +112 -107
  56. package/dist/ts-compiler/sd-ts-compiler.js.map +1 -1
  57. package/dist/utils/sd-cli-performance-time.d.ts +2 -3
  58. package/dist/utils/sd-cli-performance-time.js +9 -9
  59. package/dist/utils/sd-cli-performance-time.js.map +1 -1
  60. package/package.json +8 -8
  61. package/src/entry/sd-cli-cordova.ts +92 -92
  62. package/src/entry/sd-cli-electron.ts +21 -21
  63. package/src/entry/sd-cli-local-update.ts +3 -3
  64. package/src/entry/sd-cli-project.ts +11 -11
  65. package/src/fix/convert-private-to-hash.ts +72 -0
  66. package/src/pkg-builders/client/sd-client.build-runner.ts +11 -11
  67. package/src/pkg-builders/client/sd-ng.bundler-context.ts +12 -12
  68. package/src/pkg-builders/client/sd-ng.bundler.ts +75 -75
  69. package/src/pkg-builders/commons/scope-path.ts +4 -4
  70. package/src/pkg-builders/lib/sd-cli-index.file-generator.ts +2 -2
  71. package/src/pkg-builders/lib/sd-js-lib.build-runner.ts +2 -2
  72. package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +3 -3
  73. package/src/pkg-builders/lib/sd-ts-lib.builder.ts +4 -4
  74. package/src/pkg-builders/sd-multi.build-runner.ts +27 -27
  75. package/src/pkg-builders/server/sd-server.build-runner.ts +11 -11
  76. package/src/pkg-builders/server/sd-server.bundler.ts +20 -20
  77. package/src/sd-cli-entry.ts +19 -8
  78. package/src/ts-compiler/sd-dependency-cache.ts +37 -37
  79. package/src/ts-compiler/sd-ts-compiler.ts +117 -117
  80. package/src/utils/sd-cli-performance-time.ts +10 -10
  81. package/dist/fix/convert-ecma-private-to-ts-private.d.ts +0 -1
  82. package/dist/fix/convert-ecma-private-to-ts-private.js +0 -59
  83. package/dist/fix/convert-ecma-private-to-ts-private.js.map +0 -1
  84. package/dist/fix/prefix-underscore-for-access-modifiers.d.ts +0 -1
  85. package/dist/fix/prefix-underscore-for-access-modifiers.js +0 -52
  86. package/dist/fix/prefix-underscore-for-access-modifiers.js.map +0 -1
  87. package/src/fix/convert-ecma-private-to-ts-private.ts +0 -71
  88. package/src/fix/prefix-underscore-for-access-modifiers.ts +0 -68
@@ -27,19 +27,19 @@ import { transformSupportedBrowsersToTargets } from "@angular/build/src/tools/es
27
27
  import browserslist from "browserslist";
28
28
 
29
29
  export class SdTsCompiler {
30
- private _logger = SdLogger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
30
+ #logger = SdLogger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
31
31
 
32
- private _isForAngular: boolean;
32
+ #isForAngular: boolean;
33
33
 
34
- private _stylesheetBundler: ComponentStylesheetBundler;
34
+ #stylesheetBundler: ComponentStylesheetBundler;
35
35
 
36
- private _ngProgram: NgtscProgram | undefined;
37
- private _program: ts.Program | undefined;
36
+ #ngProgram: NgtscProgram | undefined;
37
+ #program: ts.Program | undefined;
38
38
 
39
39
  // 빌드정보 캐싱
40
- private _depCache = new SdDependencyCache();
41
- private _sourceFileCacheMap = new Map<TNormPath, ts.SourceFile>();
42
- private _emittedFilesCacheMap = new Map<
40
+ #depCache = new SdDependencyCache();
41
+ #sourceFileCacheMap = new Map<TNormPath, ts.SourceFile>();
42
+ #emittedFilesCacheMap = new Map<
43
43
  TNormPath,
44
44
  {
45
45
  outAbsPath?: TNormPath;
@@ -48,18 +48,18 @@ export class SdTsCompiler {
48
48
  >();
49
49
 
50
50
  // 빌드결과 캐싱
51
- private _stylesheetBundlingResultMap = new Map<TNormPath, TStylesheetBundlingResult>();
51
+ #stylesheetBundlingResultMap = new Map<TNormPath, TStylesheetBundlingResult>();
52
52
 
53
- private _perf!: SdCliPerformanceTimer;
53
+ #perf!: SdCliPerformanceTimer;
54
54
 
55
55
  constructor(private readonly _opt: SdTsCompilerOptions) {
56
- this._debug("초기화 중...");
56
+ this.#debug("초기화 중...");
57
57
 
58
58
  const tsconfigPath = path.resolve(this._opt.pkgPath, "tsconfig.json");
59
59
  const tsconfig = FsUtils.readJson(tsconfigPath);
60
- this._isForAngular = Boolean(tsconfig.angularCompilerOptions);
60
+ this.#isForAngular = Boolean(tsconfig.angularCompilerOptions);
61
61
 
62
- this._stylesheetBundler = new ComponentStylesheetBundler(
62
+ this.#stylesheetBundler = new ComponentStylesheetBundler(
63
63
  {
64
64
  workspaceRoot: this._opt.pkgPath,
65
65
  optimization: !this._opt.isDevMode,
@@ -87,7 +87,7 @@ export class SdTsCompiler {
87
87
  );
88
88
  }
89
89
 
90
- private _parseTsConfig() {
90
+ #parseTsConfig() {
91
91
  const tsconfigPath = path.resolve(this._opt.pkgPath, "tsconfig.json");
92
92
  const tsconfig = FsUtils.readJson(tsconfigPath);
93
93
  const parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, this._opt.pkgPath, {
@@ -107,7 +107,7 @@ export class SdTsCompiler {
107
107
  };
108
108
  }
109
109
 
110
- private _createCompilerHost(
110
+ #createCompilerHost(
111
111
  compilerOptions: ts.CompilerOptions,
112
112
  modifiedFileSet: Set<TNormPath>,
113
113
  ) {
@@ -123,8 +123,8 @@ export class SdTsCompiler {
123
123
  ): ts.SourceFile | undefined => {
124
124
  const fileNPath = PathUtils.norm(fileName);
125
125
 
126
- if (!shouldCreateNewSourceFile && this._sourceFileCacheMap.has(fileNPath)) {
127
- return this._sourceFileCacheMap.get(fileNPath);
126
+ if (!shouldCreateNewSourceFile && this.#sourceFileCacheMap.has(fileNPath)) {
127
+ return this.#sourceFileCacheMap.get(fileNPath);
128
128
  }
129
129
 
130
130
  const sf: ts.SourceFile | undefined = baseGetSourceFile.call(
@@ -137,14 +137,14 @@ export class SdTsCompiler {
137
137
  );
138
138
 
139
139
  if (!sf) {
140
- this._sourceFileCacheMap.delete(fileNPath);
140
+ this.#sourceFileCacheMap.delete(fileNPath);
141
141
  return undefined;
142
142
  }
143
143
 
144
144
  return sf;
145
145
  };
146
146
 
147
- if (this._isForAngular) {
147
+ if (this.#isForAngular) {
148
148
  (compilerHost as AngularCompilerHost).readResource = (fileName: string) => {
149
149
  return compilerHost.readFile(fileName) ?? "";
150
150
  };
@@ -161,7 +161,7 @@ export class SdTsCompiler {
161
161
  return null;
162
162
  }
163
163
 
164
- const stylesheetBundlingResult = await this._bundleStylesheetAsync(
164
+ const stylesheetBundlingResult = await this.#bundleStylesheetAsync(
165
165
  data,
166
166
  PathUtils.norm(context.containingFile),
167
167
  context.resourceFile != null ? PathUtils.norm(context.resourceFile) : undefined,
@@ -197,7 +197,7 @@ export class SdTsCompiler {
197
197
  // return this._stylesheetBundlingWorker;
198
198
  // }
199
199
 
200
- private async _bundleStylesheetAsync(
200
+ async #bundleStylesheetAsync(
201
201
  data: string,
202
202
  containingFile: TNormPath,
203
203
  resourceFile: TNormPath | null = null,
@@ -208,10 +208,10 @@ export class SdTsCompiler {
208
208
 
209
209
  // this.#debug(`bundle stylesheet...(${containingFile}, ${resourceFile})`);
210
210
 
211
- return await this._perf.run("스타일 번들링", async () => {
211
+ return await this.#perf.run("스타일 번들링", async () => {
212
212
  const fileNPath = PathUtils.norm(resourceFile ?? containingFile);
213
- if (this._stylesheetBundlingResultMap.has(fileNPath)) {
214
- return this._stylesheetBundlingResultMap.get(fileNPath)!;
213
+ if (this.#stylesheetBundlingResultMap.has(fileNPath)) {
214
+ return this.#stylesheetBundlingResultMap.get(fileNPath)!;
215
215
  }
216
216
 
217
217
  try {
@@ -221,13 +221,13 @@ export class SdTsCompiler {
221
221
  // const result = await worker.run("bundle", [data, containingFile, resourceFile]);
222
222
 
223
223
  const result = resourceFile != null
224
- ? await this._stylesheetBundler.bundleFile(resourceFile)
225
- : await this._stylesheetBundler.bundleInline(data, containingFile, "scss");
224
+ ? await this.#stylesheetBundler.bundleFile(resourceFile)
225
+ : await this.#stylesheetBundler.bundleInline(data, containingFile, "scss");
226
226
 
227
227
  for (const referencedFile of result.referencedFiles ?? []) {
228
228
  // for (const referencedFile of result.referencedFiles) {
229
229
  // 참조하는 파일과 참조된 파일 사이의 의존성 관계 추가
230
- this._depCache.addImport(fileNPath, PathUtils.norm(referencedFile), 0);
230
+ this.#depCache.addImport(fileNPath, PathUtils.norm(referencedFile), 0);
231
231
  }
232
232
 
233
233
  // this._stylesheetBundlingResultMap.set(fileNPath, {
@@ -253,26 +253,26 @@ export class SdTsCompiler {
253
253
  ],
254
254
  warnings: [],
255
255
  };
256
- this._stylesheetBundlingResultMap.set(fileNPath, result);
256
+ this.#stylesheetBundlingResultMap.set(fileNPath, result);
257
257
  return result;
258
258
  }
259
259
  });
260
260
  }
261
261
 
262
262
  async compileAsync(modifiedFileSet: Set<TNormPath>): Promise<ISdTsCompilerResult> {
263
- this._perf = new SdCliPerformanceTimer("esbuild compile");
263
+ this.#perf = new SdCliPerformanceTimer("esbuild compile");
264
264
 
265
- const prepareResult = await this._prepareAsync(modifiedFileSet);
265
+ const prepareResult = await this.#prepareAsync(modifiedFileSet);
266
266
 
267
267
  const [globalStyleSheet, buildResult, lintResults] = await Promise.all([
268
- this._buildGlobalStyleAsync(),
269
- this._build(prepareResult),
270
- this._lintAsync(prepareResult),
268
+ this.#buildGlobalStyleAsync(),
269
+ this.#build(prepareResult),
270
+ this.#lintAsync(prepareResult),
271
271
  ]);
272
272
 
273
- this._debug(`빌드 완료됨`, this._perf.toString());
274
- this._debug(`영향 받은 파일: ${prepareResult.affectedFileSet.size}개`);
275
- this._debug(`감시 중인 파일: ${prepareResult.watchFileSet.size}개`);
273
+ this.#debug(`빌드 완료됨`, this.#perf.toString());
274
+ this.#debug(`영향 받은 파일: ${prepareResult.affectedFileSet.size}개`);
275
+ this.#debug(`감시 중인 파일: ${prepareResult.watchFileSet.size}개`);
276
276
 
277
277
  return {
278
278
  messages: [
@@ -281,24 +281,24 @@ export class SdTsCompiler {
281
281
  ],
282
282
  affectedFileSet: prepareResult.affectedFileSet,
283
283
  watchFileSet: prepareResult.watchFileSet,
284
- stylesheetBundlingResultMap: this._stylesheetBundlingResultMap,
285
- emittedFilesCacheMap: this._emittedFilesCacheMap,
284
+ stylesheetBundlingResultMap: this.#stylesheetBundlingResultMap,
285
+ emittedFilesCacheMap: this.#emittedFilesCacheMap,
286
286
  emitFileSet: new Set([...buildResult.emitFileSet, globalStyleSheet].filterExists()),
287
287
  };
288
288
  }
289
289
 
290
- private async _prepareAsync(modifiedFileSet: Set<TNormPath>): Promise<IPrepareResult> {
290
+ async #prepareAsync(modifiedFileSet: Set<TNormPath>): Promise<IPrepareResult> {
291
291
  // const worker = await this._getOrCreateStyleBundleWorkerAsync();
292
292
 
293
- const tsconfig = this._parseTsConfig();
293
+ const tsconfig = this.#parseTsConfig();
294
294
 
295
295
  if (modifiedFileSet.size !== 0) {
296
- this._debug(`캐시 무효화 및 초기화 중...`);
296
+ this.#debug(`캐시 무효화 및 초기화 중...`);
297
297
 
298
298
  // this._perf.run("캐시 무효화 및 초기화", () => {
299
- this._perf.run("캐시 무효화 및 초기화", () => {
299
+ this.#perf.run("캐시 무효화 및 초기화", () => {
300
300
  // 기존 의존성에 의해 영향받는 파일들 계산
301
- const affectedFileSet = this._depCache.getAffectedFileSet(modifiedFileSet);
301
+ const affectedFileSet = this.#depCache.getAffectedFileSet(modifiedFileSet);
302
302
 
303
303
  const getTreeText = (node: ISdAffectedFileTreeNode, indent = "") => {
304
304
  let result = indent + node.fileNPath + "\n";
@@ -309,84 +309,84 @@ export class SdTsCompiler {
309
309
  return result;
310
310
  };
311
311
 
312
- const affectedFileTree = this._depCache.getAffectedFileTree(modifiedFileSet);
313
- this._debug(`
312
+ const affectedFileTree = this.#depCache.getAffectedFileTree(modifiedFileSet);
313
+ this.#debug(`
314
314
  영향받은 기존파일:
315
315
  ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
316
316
 
317
317
  // 스타일 번들러에서 영향받은 파일 관련 항목 무효화
318
- this._stylesheetBundler.invalidate(affectedFileSet);
318
+ this.#stylesheetBundler.invalidate(affectedFileSet);
319
319
  // await worker.run("invalidate", [affectedFileSet]);
320
320
 
321
321
  // 의존성 캐시에서 영향받은 파일 관련 항목 무효화
322
- this._depCache.invalidates(affectedFileSet);
322
+ this.#depCache.invalidates(affectedFileSet);
323
323
 
324
324
  // 내부 캐시에서 영향받은 파일 관련 항목 무효화
325
325
  for (const affectedFile of affectedFileSet) {
326
- this._emittedFilesCacheMap.delete(affectedFile);
327
- this._sourceFileCacheMap.delete(affectedFile);
328
- this._stylesheetBundlingResultMap.delete(affectedFile);
326
+ this.#emittedFilesCacheMap.delete(affectedFile);
327
+ this.#sourceFileCacheMap.delete(affectedFile);
328
+ this.#stylesheetBundlingResultMap.delete(affectedFile);
329
329
  }
330
330
  });
331
331
  }
332
332
 
333
- this._debug(`ts.Program 생성 중...`);
333
+ this.#debug(`ts.Program 생성 중...`);
334
334
 
335
- const compilerHost = this._perf.run("ts.CompilerHost 생성", () => {
336
- return this._createCompilerHost(tsconfig.options, modifiedFileSet);
335
+ const compilerHost = this.#perf.run("ts.CompilerHost 생성", () => {
336
+ return this.#createCompilerHost(tsconfig.options, modifiedFileSet);
337
337
  });
338
338
 
339
- this._perf.run("ts.Program 생성", () => {
340
- if (this._isForAngular) {
341
- this._ngProgram = new NgtscProgram(
339
+ this.#perf.run("ts.Program 생성", () => {
340
+ if (this.#isForAngular) {
341
+ this.#ngProgram = new NgtscProgram(
342
342
  tsconfig.fileNames,
343
343
  tsconfig.options,
344
344
  compilerHost,
345
- this._ngProgram,
345
+ this.#ngProgram,
346
346
  );
347
- this._program = this._ngProgram.getTsProgram();
347
+ this.#program = this.#ngProgram.getTsProgram();
348
348
  }
349
349
  else {
350
- this._program = ts.createProgram(
350
+ this.#program = ts.createProgram(
351
351
  tsconfig.fileNames,
352
352
  tsconfig.options,
353
353
  compilerHost,
354
- this._program,
354
+ this.#program,
355
355
  );
356
356
  }
357
357
  });
358
358
 
359
- if (this._ngProgram) {
360
- await this._perf.run("Angular 템플릿 분석", async () => {
361
- await this._ngProgram!.compiler.analyzeAsync();
359
+ if (this.#ngProgram) {
360
+ await this.#perf.run("Angular 템플릿 분석", async () => {
361
+ await this.#ngProgram!.compiler.analyzeAsync();
362
362
  });
363
363
  }
364
364
 
365
- this._debug(`새 의존성 분석 중...`);
365
+ this.#debug(`새 의존성 분석 중...`);
366
366
 
367
- this._perf.run("새 의존성 분석", () => {
367
+ this.#perf.run("새 의존성 분석", () => {
368
368
  // SdTsDependencyAnalyzer를 통해 의존성 분석 및 SdDepCache 업데이트
369
369
  SdDependencyAnalyzer.analyze(
370
- this._program!,
370
+ this.#program!,
371
371
  compilerHost,
372
372
  this._opt.watchScopePathSet,
373
- this._depCache,
373
+ this.#depCache,
374
374
  );
375
375
 
376
376
  // Angular 리소스 의존성 추가
377
- if (this._ngProgram) {
377
+ if (this.#ngProgram) {
378
378
  SdDependencyAnalyzer.analyzeAngularResources(
379
- this._ngProgram,
379
+ this.#ngProgram,
380
380
  this._opt.watchScopePathSet,
381
- this._depCache,
381
+ this.#depCache,
382
382
  );
383
383
  }
384
384
  });
385
385
 
386
386
  const affectedFileSet = modifiedFileSet.size === 0
387
- ? this._depCache.getFiles()
388
- : this._depCache.getAffectedFileSet(modifiedFileSet);
389
- const watchFileSet = this._depCache.getFiles();
387
+ ? this.#depCache.getFiles()
388
+ : this.#depCache.getAffectedFileSet(modifiedFileSet);
389
+ const watchFileSet = this.#depCache.getFiles();
390
390
 
391
391
  return {
392
392
  tsconfig,
@@ -396,7 +396,7 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
396
396
  };
397
397
  }
398
398
 
399
- private async _lintAsync(prepareResult: IPrepareResult) {
399
+ async #lintAsync(prepareResult: IPrepareResult) {
400
400
  const lintFilePaths = Array.from(prepareResult.affectedFileSet)
401
401
  .filter((item) => PathUtils.isChildPath(item, this._opt.pkgPath))
402
402
  .filter((item) => (
@@ -416,7 +416,7 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
416
416
  languageOptions: {
417
417
  parserOptions: {
418
418
  project: null,
419
- programs: [this._program],
419
+ programs: [this.#program],
420
420
  },
421
421
  },
422
422
  },
@@ -424,23 +424,23 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
424
424
  return await linter.lintFiles(lintFilePaths);
425
425
  }
426
426
 
427
- private async _buildGlobalStyleAsync() {
427
+ async #buildGlobalStyleAsync() {
428
428
  //-- global style
429
429
  if (
430
430
  this._opt.globalStyleFilePath != null &&
431
431
  FsUtils.exists(this._opt.globalStyleFilePath) &&
432
- !this._emittedFilesCacheMap.has(this._opt.globalStyleFilePath)
432
+ !this.#emittedFilesCacheMap.has(this._opt.globalStyleFilePath)
433
433
  ) {
434
- this._debug(`전역 스타일 번들링 중...`);
434
+ this.#debug(`전역 스타일 번들링 중...`);
435
435
 
436
- await this._perf.run("전역 스타일 번들링", async () => {
436
+ await this.#perf.run("전역 스타일 번들링", async () => {
437
437
  const data = await FsUtils.readFileAsync(this._opt.globalStyleFilePath!);
438
- const stylesheetBundlingResult = await this._bundleStylesheetAsync(
438
+ const stylesheetBundlingResult = await this.#bundleStylesheetAsync(
439
439
  data,
440
440
  this._opt.globalStyleFilePath!,
441
441
  this._opt.globalStyleFilePath,
442
442
  );
443
- const emitFileInfos = this._emittedFilesCacheMap.getOrCreate(
443
+ const emitFileInfos = this.#emittedFilesCacheMap.getOrCreate(
444
444
  this._opt.globalStyleFilePath!,
445
445
  [],
446
446
  );
@@ -460,52 +460,52 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
460
460
  return undefined;
461
461
  }
462
462
 
463
- private _build(prepareResult: IPrepareResult) {
463
+ #build(prepareResult: IPrepareResult) {
464
464
  const emitFileSet = new Set<TNormPath>();
465
465
  const diagnostics: ts.Diagnostic[] = [];
466
466
 
467
- this._debug(`프로그램 진단 수집 중...`);
467
+ this.#debug(`프로그램 진단 수집 중...`);
468
468
 
469
- this._perf.run("프로그램 진단 수집", () => {
469
+ this.#perf.run("프로그램 진단 수집", () => {
470
470
  diagnostics.push(
471
- ...this._program!.getConfigFileParsingDiagnostics(),
472
- ...this._program!.getOptionsDiagnostics(),
473
- ...this._program!.getGlobalDiagnostics(),
471
+ ...this.#program!.getConfigFileParsingDiagnostics(),
472
+ ...this.#program!.getOptionsDiagnostics(),
473
+ ...this.#program!.getGlobalDiagnostics(),
474
474
  );
475
475
 
476
- if (this._ngProgram) {
477
- diagnostics.push(...this._ngProgram.compiler.getOptionDiagnostics());
476
+ if (this.#ngProgram) {
477
+ diagnostics.push(...this.#ngProgram.compiler.getOptionDiagnostics());
478
478
  }
479
479
  });
480
480
 
481
- this._debug(`개별 파일 진단 수집 중...`);
481
+ this.#debug(`개별 파일 진단 수집 중...`);
482
482
 
483
483
  for (const affectedFile of prepareResult.affectedFileSet) {
484
484
  if (!PathUtils.isChildPath(affectedFile, this._opt.pkgPath)) continue;
485
485
 
486
- const affectedSourceFile = this._program!.getSourceFile(affectedFile);
486
+ const affectedSourceFile = this.#program!.getSourceFile(affectedFile);
487
487
  if (
488
488
  !affectedSourceFile ||
489
- (this._ngProgram && this._ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))
489
+ (this.#ngProgram && this.#ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))
490
490
  ) {
491
491
  continue;
492
492
  }
493
493
 
494
494
  // this.#debug(`get diagnostics of file ${affectedFile}...`);
495
495
 
496
- this._perf.run("개별 파일 진단 수집", () => {
496
+ this.#perf.run("개별 파일 진단 수집", () => {
497
497
  diagnostics.push(
498
- ...this._program!.getSyntacticDiagnostics(affectedSourceFile),
499
- ...this._program!.getSemanticDiagnostics(affectedSourceFile),
498
+ ...this.#program!.getSyntacticDiagnostics(affectedSourceFile),
499
+ ...this.#program!.getSemanticDiagnostics(affectedSourceFile),
500
500
  );
501
501
  });
502
502
 
503
- if (this._ngProgram) {
504
- this._perf.run("개별 파일 진단 수집(Angular)", () => {
503
+ if (this.#ngProgram) {
504
+ this.#perf.run("개별 파일 진단 수집(Angular)", () => {
505
505
  if (affectedSourceFile.isDeclarationFile) return;
506
506
 
507
507
  diagnostics.push(
508
- ...this._ngProgram!.compiler.getDiagnosticsForFile(
508
+ ...this.#ngProgram!.compiler.getDiagnosticsForFile(
509
509
  affectedSourceFile,
510
510
  OptimizeFor.WholeProgram,
511
511
  ),
@@ -514,13 +514,13 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
514
514
  }
515
515
  }
516
516
 
517
- this._perf.run("파일 출력 (emit)", () => {
518
- this._debug(`파일 출력 준비 중...`);
517
+ this.#perf.run("파일 출력 (emit)", () => {
518
+ this.#debug(`파일 출력 준비 중...`);
519
519
 
520
520
  let transformers: ts.CustomTransformers = {};
521
521
 
522
- if (this._ngProgram) {
523
- const angularTransfomers = this._ngProgram.compiler.prepareEmit().transformers;
522
+ if (this.#ngProgram) {
523
+ const angularTransfomers = this.#ngProgram.compiler.prepareEmit().transformers;
524
524
  (transformers.before ??= []).push(
525
525
  ...(angularTransfomers.before ?? []),
526
526
  );
@@ -531,7 +531,7 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
531
531
  ...(angularTransfomers.afterDeclarations ?? []),
532
532
  );
533
533
 
534
- (transformers.before ??= []).push(replaceBootstrap(() => this._program!.getTypeChecker()));
534
+ (transformers.before ??= []).push(replaceBootstrap(() => this.#program!.getTypeChecker()));
535
535
  (transformers.before ??= []).push(
536
536
  createWorkerTransformer((file, importer) => {
537
537
  const fullPath = path.resolve(path.dirname(importer), file);
@@ -541,18 +541,18 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
541
541
  );
542
542
  }
543
543
 
544
- this._debug(`파일 출력 중...`);
544
+ this.#debug(`파일 출력 중...`);
545
545
 
546
546
  // affected에 새로 추가된 파일은 포함되지 않는 현상이 있어 sourceFileSet으로 바꿈
547
547
  // 비교해보니, 딱히 getSourceFiles라서 더 느려지는것 같지는 않음
548
548
  // 그래도 affected로 다시 테스트 (조금이라도 더 빠르게)
549
549
  for (const affectedFile of prepareResult.affectedFileSet) {
550
- if (this._emittedFilesCacheMap.has(affectedFile)) continue;
550
+ if (this.#emittedFilesCacheMap.has(affectedFile)) continue;
551
551
 
552
- const sf = this._program!.getSourceFile(affectedFile);
552
+ const sf = this.#program!.getSourceFile(affectedFile);
553
553
  if (!sf || sf.isDeclarationFile) continue;
554
- if (this._ngProgram?.compiler.ignoreForEmit.has(sf)) continue;
555
- if (this._ngProgram?.compiler.incrementalCompilation.safeToSkipEmit(sf)) continue;
554
+ if (this.#ngProgram?.compiler.ignoreForEmit.has(sf)) continue;
555
+ if (this.#ngProgram?.compiler.incrementalCompilation.safeToSkipEmit(sf)) continue;
556
556
 
557
557
  // 번들이 아닌 외부패키지는 보통 emit안해도 됨
558
558
  // but esbuild를 통해 bundle로 묶어야 하는놈들은 모든 output이 있어야 함.
@@ -560,7 +560,7 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
560
560
  continue;
561
561
  }
562
562
 
563
- this._program!.emit(
563
+ this.#program!.emit(
564
564
  sf,
565
565
  (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
566
566
  if (!sourceFiles || sourceFiles.length === 0) {
@@ -576,18 +576,18 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
576
576
  }
577
577
 
578
578
  const sourceFile = ts.getOriginalNode(sourceFiles[0], ts.isSourceFile);
579
- if (this._ngProgram) {
580
- if (this._ngProgram.compiler.ignoreForEmit.has(sourceFile)) return;
581
- this._ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
579
+ if (this.#ngProgram) {
580
+ if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) return;
581
+ this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
582
582
  }
583
583
 
584
- const emitFileInfoCaches = this._emittedFilesCacheMap.getOrCreate(
584
+ const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(
585
585
  PathUtils.norm(sourceFile.fileName),
586
586
  [],
587
587
  );
588
588
 
589
589
  if (PathUtils.isChildPath(sourceFile.fileName, this._opt.pkgPath)) {
590
- const real = this._convertOutputToReal(
590
+ const real = this.#convertOutputToReal(
591
591
  fileName,
592
592
  prepareResult.tsconfig.distPath,
593
593
  text,
@@ -617,7 +617,7 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
617
617
  };
618
618
  }
619
619
 
620
- private _convertOutputToReal(filePath: string, distPath: string, text: string) {
620
+ #convertOutputToReal(filePath: string, distPath: string, text: string) {
621
621
  let realFilePath = PathUtils.norm(filePath);
622
622
  let realText = text;
623
623
 
@@ -637,8 +637,8 @@ ${affectedFileTree.map(item => getTreeText(item)).join("\n")}`.trim());
637
637
  return { filePath: realFilePath, text: realText };
638
638
  }
639
639
 
640
- private _debug(...msg: any[]): void {
641
- this._logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
640
+ #debug(...msg: any[]): void {
641
+ this.#logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
642
642
  }
643
643
  }
644
644
 
@@ -1,27 +1,27 @@
1
1
  export class SdCliPerformanceTimer {
2
- private _startingMap = new Map<string, { time: number; cpu: NodeJS.CpuUsage }>();
3
- private _resultMap = new Map<string, { time: number; cpu: number }>();
2
+ #startingMap = new Map<string, { time: number; cpu: NodeJS.CpuUsage }>();
3
+ #resultMap = new Map<string, { time: number; cpu: number }>();
4
4
 
5
- constructor(private _name: string) {
5
+ constructor(private readonly _name: string) {
6
6
  }
7
7
 
8
8
  start(name: string) {
9
- this._startingMap.set(name, {
9
+ this.#startingMap.set(name, {
10
10
  time: new Date().getTime(),
11
11
  cpu: process.cpuUsage(),
12
12
  });
13
13
  }
14
14
 
15
15
  end(name: string) {
16
- const start = this._startingMap.get(name);
16
+ const start = this.#startingMap.get(name);
17
17
  if (start == null) throw new Error(`No start record for '${name}'`);
18
18
 
19
19
  const time = new Date().getTime() - start.time;
20
20
  const cpuUsage = process.cpuUsage(start.cpu);
21
21
  const cpu = (cpuUsage.user + cpuUsage.system) / 1000; // μs -> ms
22
22
 
23
- this._resultMap.set(name, { time, cpu });
24
- this._startingMap.delete(name);
23
+ this.#resultMap.set(name, { time, cpu });
24
+ this.#startingMap.delete(name);
25
25
  }
26
26
 
27
27
  run<R>(name: string, fn: () => R): R {
@@ -32,8 +32,8 @@ export class SdCliPerformanceTimer {
32
32
  const duration = new Date().getTime() - start;
33
33
  const cpu = (process.cpuUsage(startCpu).user + process.cpuUsage(startCpu).system) / 1000;
34
34
 
35
- const prev = this._resultMap.get(name);
36
- this._resultMap.set(name, {
35
+ const prev = this.#resultMap.get(name);
36
+ this.#resultMap.set(name, {
37
37
  time: (prev?.time ?? 0) + duration,
38
38
  cpu: (prev?.cpu ?? 0) + cpu,
39
39
  });
@@ -52,7 +52,7 @@ export class SdCliPerformanceTimer {
52
52
  toString() {
53
53
  return `${this._name} 성능 보고서
54
54
  ------------------------------------
55
- ${Array.from(this._resultMap.entries())
55
+ ${Array.from(this.#resultMap.entries())
56
56
  .map(([key, val]) =>
57
57
  `${key}: ${val.time.toLocaleString()}ms (${val.cpu.toLocaleString()}ms CPU)`,
58
58
  )
@@ -1 +0,0 @@
1
- export default function convertEcmaPrivateToTsPrivate(): void;
@@ -1,59 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { SyntaxKind } from "ts-morph";
3
- import getTsMortphSourceFiles from "./core/get-ts-morph-source-files";
4
- export default function convertEcmaPrivateToTsPrivate() {
5
- const sourceFiles = getTsMortphSourceFiles();
6
- for (const sourceFile of sourceFiles) {
7
- for (const classDec of sourceFile.getClasses()) {
8
- let changed = false;
9
- // (1) #x → private _x
10
- for (const prop of classDec.getInstanceProperties()) {
11
- const nameNode = prop.getNameNode();
12
- if (nameNode.getKind() !== SyntaxKind.PrivateIdentifier)
13
- continue;
14
- const baseName = nameNode.getText().slice(1);
15
- const newName = `_${baseName}`;
16
- nameNode.replaceWithText(newName);
17
- if (!prop.hasModifier(SyntaxKind.PrivateKeyword)) {
18
- prop.toggleModifier("private", true);
19
- }
20
- console.log(`[private-field] ${sourceFile.getBaseName()} :: #${baseName} → private ${newName}`);
21
- changed = true;
22
- }
23
- // (2) #foo() → private _foo()
24
- for (const member of classDec.getMembers()) {
25
- if (member.getKind() !== SyntaxKind.MethodDeclaration)
26
- continue;
27
- const method = member;
28
- const nameNode = method.getNameNode();
29
- if (nameNode.getKind() !== SyntaxKind.PrivateIdentifier)
30
- continue;
31
- const baseName = nameNode.getText().slice(1);
32
- const newName = `_${baseName}`;
33
- nameNode.replaceWithText(newName);
34
- if (!method.hasModifier(SyntaxKind.PrivateKeyword)) {
35
- method.toggleModifier("private", true);
36
- }
37
- console.log(`[private-method] ${sourceFile.getBaseName()} :: #${baseName}() → private ${newName}()`);
38
- changed = true;
39
- }
40
- // (3) this.#x → this._x
41
- classDec.getDescendantsOfKind(SyntaxKind.PropertyAccessExpression)
42
- .forEach((expr) => {
43
- const nameNode = expr.getNameNode();
44
- if (nameNode.getKind() !== SyntaxKind.PrivateIdentifier)
45
- return;
46
- const baseName = nameNode.getText().slice(1);
47
- const newName = `_${baseName}`;
48
- nameNode.replaceWithText(newName);
49
- console.log(`[ref] ${sourceFile.getBaseName()} :: this.#${baseName} → this.${newName}`);
50
- changed = true;
51
- });
52
- if (changed) {
53
- sourceFile.saveSync();
54
- }
55
- }
56
- }
57
- console.log("[완료] #field/#method → private _field/_method 변환 완료");
58
- }
59
- //# sourceMappingURL=convert-ecma-private-to-ts-private.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-ecma-private-to-ts-private.js","sourceRoot":"","sources":["../../src/fix/convert-ecma-private-to-ts-private.ts"],"names":[],"mappings":"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"}