@simplysm/sd-cli 12.15.39 → 12.15.41

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 (58) hide show
  1. package/dist/entry/SdCliCordova.d.ts +33 -1
  2. package/dist/entry/SdCliCordova.js +84 -88
  3. package/dist/entry/SdCliElectron.d.ts +5 -1
  4. package/dist/entry/SdCliElectron.js +21 -21
  5. package/dist/entry/SdCliLocalUpdate.d.ts +1 -1
  6. package/dist/entry/SdCliLocalUpdate.js +3 -3
  7. package/dist/entry/SdCliProject.d.ts +4 -1
  8. package/dist/entry/SdCliProject.js +11 -11
  9. package/dist/pkg-builders/SdProjectBuildRunner.d.ts +6 -1
  10. package/dist/pkg-builders/SdProjectBuildRunner.js +27 -27
  11. package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +2 -1
  12. package/dist/pkg-builders/client/SdClientBuildRunner.js +8 -10
  13. package/dist/pkg-builders/client/SdNgBundler.d.ts +22 -1
  14. package/dist/pkg-builders/client/SdNgBundler.js +70 -80
  15. package/dist/pkg-builders/client/SdNgBundlerContext.d.ts +3 -1
  16. package/dist/pkg-builders/client/SdNgBundlerContext.js +9 -10
  17. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +2 -1
  18. package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js +5 -5
  19. package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
  20. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +2 -2
  21. package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +1 -1
  22. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +2 -3
  23. package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -1
  24. package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -8
  25. package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +3 -1
  26. package/dist/pkg-builders/server/SdServerBuildRunner.js +6 -7
  27. package/dist/pkg-builders/server/SdServerBundler.d.ts +6 -1
  28. package/dist/pkg-builders/server/SdServerBundler.js +21 -23
  29. package/dist/ts-compiler/ScopePathSet.d.ts +1 -1
  30. package/dist/ts-compiler/ScopePathSet.js +3 -4
  31. package/dist/ts-compiler/SdDepCache.d.ts +45 -1
  32. package/dist/ts-compiler/SdDepCache.js +71 -69
  33. package/dist/ts-compiler/SdStyleBundler.d.ts +5 -1
  34. package/dist/ts-compiler/SdStyleBundler.js +25 -26
  35. package/dist/ts-compiler/SdTsCompiler.d.ts +20 -1
  36. package/dist/ts-compiler/SdTsCompiler.js +122 -129
  37. package/dist/utils/SdCliPerformanceTimer.d.ts +2 -1
  38. package/dist/utils/SdCliPerformanceTimer.js +9 -9
  39. package/package.json +8 -8
  40. package/src/entry/SdCliCordova.ts +89 -89
  41. package/src/entry/SdCliElectron.ts +21 -21
  42. package/src/entry/SdCliLocalUpdate.ts +3 -3
  43. package/src/entry/SdCliProject.ts +11 -11
  44. package/src/pkg-builders/SdProjectBuildRunner.ts +27 -27
  45. package/src/pkg-builders/client/SdClientBuildRunner.ts +10 -10
  46. package/src/pkg-builders/client/SdNgBundler.ts +78 -78
  47. package/src/pkg-builders/client/SdNgBundlerContext.ts +10 -10
  48. package/src/pkg-builders/lib/SdCliIndexFileGenerator.ts +5 -5
  49. package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +2 -2
  50. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +3 -3
  51. package/src/pkg-builders/lib/SdTsLibBuilder.ts +8 -8
  52. package/src/pkg-builders/server/SdServerBuildRunner.ts +7 -7
  53. package/src/pkg-builders/server/SdServerBundler.ts +23 -23
  54. package/src/ts-compiler/ScopePathSet.ts +4 -4
  55. package/src/ts-compiler/SdDepCache.ts +47 -47
  56. package/src/ts-compiler/SdStyleBundler.ts +26 -26
  57. package/src/ts-compiler/SdTsCompiler.ts +130 -130
  58. package/src/utils/SdCliPerformanceTimer.ts +9 -9
@@ -14,9 +14,9 @@ import { IServerWorkerType } from "../types/worker/IServerWorkerType";
14
14
  import { INpmConfig } from "../types/common-config/INpmConfig";
15
15
 
16
16
  export class SdProjectBuildRunner {
17
- static #logger = SdLogger.get(["simplysm", "sd-cli", "SdProjectBuildRunner"]);
17
+ private static readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdProjectBuildRunner"]);
18
18
 
19
- static #buildInfoMap = new Map<
19
+ private static readonly _buildInfoMap = new Map<
20
20
  TNormPath,
21
21
  {
22
22
  buildWorker: SdWorker<ISdBuildRunnerWorkerType>;
@@ -24,7 +24,7 @@ export class SdProjectBuildRunner {
24
24
  }
25
25
  >();
26
26
 
27
- static #serverInfoMap = new Map<
27
+ private static readonly _serverInfoMap = new Map<
28
28
  string,
29
29
  {
30
30
  worker?: SdWorker<any>;
@@ -39,7 +39,7 @@ export class SdProjectBuildRunner {
39
39
  }
40
40
  >();
41
41
 
42
- static #resultCache = new Map<TNormPath, ISdBuildMessage[]>();
42
+ private static readonly _resultCache = new Map<TNormPath, ISdBuildMessage[]>();
43
43
 
44
44
  static async watchAsync(opt: {
45
45
  allPkgPaths: TNormPath[];
@@ -50,7 +50,7 @@ export class SdProjectBuildRunner {
50
50
  onChange: () => void;
51
51
  onComplete: (buildMessages: ISdBuildMessage[]) => void;
52
52
  }) {
53
- const scopePathSet = await this.#getScopePathSetAsync(
53
+ const scopePathSet = await this._getScopePathSetAsync(
54
54
  opt.allPkgPaths,
55
55
  Object.keys(opt.projConf.localUpdates ?? {}),
56
56
  );
@@ -64,7 +64,7 @@ export class SdProjectBuildRunner {
64
64
 
65
65
  const changedPkgInfos = opt.pkgPaths
66
66
  .map((pkgPath) => {
67
- let buildInfo = this.#buildInfoMap.get(pkgPath);
67
+ let buildInfo = this._buildInfoMap.get(pkgPath);
68
68
  if (!buildInfo) return { pkgPath };
69
69
 
70
70
  const modifiedFileSet = new Set(
@@ -116,7 +116,7 @@ export class SdProjectBuildRunner {
116
116
 
117
117
  const result = await buildWorker.run("rebuild", []);
118
118
 
119
- this.#buildInfoMap.set(changedPkgInfo.pkgPath, {
119
+ this._buildInfoMap.set(changedPkgInfo.pkgPath, {
120
120
  buildWorker,
121
121
  watchFileSet: result.watchFileSet,
122
122
  });
@@ -156,10 +156,10 @@ export class SdProjectBuildRunner {
156
156
  const pkgConf = opt.projConf.packages[path.basename(buildResult.pkgPath)]!;
157
157
  if (pkgConf.type === "server") {
158
158
  const serverName = path.basename(buildResult.pkgPath);
159
- this.#logger.debug(`서버 '${serverName}' 재시작...`);
159
+ this._logger.debug(`서버 '${serverName}' 재시작...`);
160
160
 
161
- const serverInfo = this.#serverInfoMap.getOrCreate(serverName, {});
162
- const restartServerResult = await this.#restartServerAsync(
161
+ const serverInfo = this._serverInfoMap.getOrCreate(serverName, {});
162
+ const restartServerResult = await this._restartServerAsync(
163
163
  serverInfo.worker,
164
164
  buildResult.pkgPath,
165
165
  pkgConf,
@@ -178,10 +178,10 @@ export class SdProjectBuildRunner {
178
178
  }*/
179
179
  } else if (pkgConf.type === "client" && typeof pkgConf.server === "object") {
180
180
  const serverName = pkgConf.server.port.toString();
181
- this.#logger.debug(`서버 '${serverName}' 재시작...`);
181
+ this._logger.debug(`서버 '${serverName}' 재시작...`);
182
182
 
183
- const serverInfo = this.#serverInfoMap.getOrCreate(serverName, {});
184
- const restartServerResult = await this.#restartServerAsync(
183
+ const serverInfo = this._serverInfoMap.getOrCreate(serverName, {});
184
+ const restartServerResult = await this._restartServerAsync(
185
185
  serverInfo.worker,
186
186
  buildResult.pkgPath,
187
187
  pkgConf.server.port,
@@ -211,7 +211,7 @@ export class SdProjectBuildRunner {
211
211
  : undefined;
212
212
  if (serverKey == null) continue;
213
213
 
214
- const serverInfo = this.#serverInfoMap.get(serverKey);
214
+ const serverInfo = this._serverInfoMap.get(serverKey);
215
215
  if (!serverInfo || !serverInfo.worker) continue;
216
216
 
217
217
  const distPath = path.resolve(buildResult.pkgPath, "dist");
@@ -223,7 +223,7 @@ export class SdProjectBuildRunner {
223
223
 
224
224
  if (buildResult.isFirst) continue;
225
225
 
226
- this.#logger.debug(`클라이언트 '${clientName}' 새로고침...`);
226
+ this._logger.debug(`클라이언트 '${clientName}' 새로고침...`);
227
227
  await serverInfo.worker.run("broadcastReload", [
228
228
  clientName,
229
229
  new Set(
@@ -241,7 +241,7 @@ export class SdProjectBuildRunner {
241
241
  }
242
242
 
243
243
  // 서버 Proxy 설정
244
- for (const serverInfo of this.#serverInfoMap.values()) {
244
+ for (const serverInfo of this._serverInfoMap.values()) {
245
245
  if (!serverInfo.worker) continue;
246
246
 
247
247
  await serverInfo.worker.run("setPathProxy", [
@@ -256,8 +256,8 @@ export class SdProjectBuildRunner {
256
256
  }
257
257
 
258
258
  // 접속주소 logging
259
- for (const serverName of this.#serverInfoMap.keys()) {
260
- const serverInfo = this.#serverInfoMap.get(serverName);
259
+ for (const serverName of this._serverInfoMap.keys()) {
260
+ const serverInfo = this._serverInfoMap.get(serverName);
261
261
  const clientPaths: string[] = [];
262
262
  for (const [clientName, clientInfo] of serverInfo?.clientMap?.entries() ?? []) {
263
263
  for (const buildType of clientInfo.buildTypes) {
@@ -269,22 +269,22 @@ export class SdProjectBuildRunner {
269
269
  }
270
270
  }
271
271
 
272
- this.#logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
272
+ this._logger.info("클라이언트 개발 서버 접속 주소\n" + clientPaths.join("\n"));
273
273
  }
274
274
  }
275
275
 
276
276
  // 빌드 완료 이벤트
277
277
 
278
278
  for (const buildResult of buildResults) {
279
- this.#resultCache.delete(buildResult.pkgPath);
279
+ this._resultCache.delete(buildResult.pkgPath);
280
280
  for (const affectedFilePath of buildResult.affectedFileSet) {
281
- this.#resultCache.delete(affectedFilePath);
281
+ this._resultCache.delete(affectedFilePath);
282
282
  }
283
283
  }
284
284
 
285
285
  for (const buildResult of buildResults) {
286
286
  for (const buildMessage of buildResult.buildMessages) {
287
- const cacheItem = this.#resultCache.getOrCreate(
287
+ const cacheItem = this._resultCache.getOrCreate(
288
288
  buildMessage.filePath ?? buildResult.pkgPath,
289
289
  [],
290
290
  );
@@ -292,7 +292,7 @@ export class SdProjectBuildRunner {
292
292
  }
293
293
  }
294
294
 
295
- opt.onComplete(Array.from(this.#resultCache.values()).mapMany());
295
+ opt.onComplete(Array.from(this._resultCache.values()).mapMany());
296
296
  });
297
297
  }
298
298
 
@@ -301,7 +301,7 @@ export class SdProjectBuildRunner {
301
301
  pkgPaths: TNormPath[];
302
302
  projConf: ISdProjectConfig;
303
303
  }) {
304
- const scopePathSet = await this.#getScopePathSetAsync(
304
+ const scopePathSet = await this._getScopePathSetAsync(
305
305
  opt.allPkgPaths,
306
306
  Object.keys(opt.projConf.localUpdates ?? {}),
307
307
  );
@@ -337,7 +337,7 @@ export class SdProjectBuildRunner {
337
337
  return buildResults.mapMany((item) => item.buildMessages);
338
338
  }
339
339
 
340
- static async #getScopePathSetAsync(pkgPaths: TNormPath[], localUpdateGlobs: string[]) {
340
+ private static async _getScopePathSetAsync(pkgPaths: TNormPath[], localUpdateGlobs: string[]) {
341
341
  const workspacePaths = pkgPaths.mapMany((item) => [
342
342
  path.resolve(item, "src"),
343
343
  path.resolve(item, "public"),
@@ -353,7 +353,7 @@ export class SdProjectBuildRunner {
353
353
  return new Set([...workspacePaths, ...localUpdatePaths].map((item) => PathUtils.norm(item)));
354
354
  }
355
355
 
356
- static async #restartServerAsync(
356
+ private static async _restartServerAsync(
357
357
  prevWorker: SdWorker<IServerWorkerType> | undefined,
358
358
  pkgPath: string,
359
359
  pkgConfOrPort: ISdServerPackageConfig | number,
@@ -386,7 +386,7 @@ export class SdProjectBuildRunner {
386
386
  const port = await worker.run("listen", [
387
387
  typeof pkgConfOrPort === "number" ? pkgConfOrPort : pkgPath,
388
388
  ]);
389
- this.#logger.debug("서버가 시작되었습니다.");
389
+ this._logger.debug("서버가 시작되었습니다.");
390
390
 
391
391
  return { worker, port };
392
392
  }
@@ -12,8 +12,8 @@ import { ISdClientPackageConfig } from "../../types/config/ISdProjectConfig";
12
12
  export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
13
13
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
14
14
 
15
- #ngBundlers?: SdNgBundler[];
16
- #cordova?: SdCliCordova;
15
+ private _ngBundlers?: SdNgBundler[];
16
+ private _cordova?: SdCliCordova;
17
17
 
18
18
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
19
19
  // 최초 한번
@@ -30,11 +30,11 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
30
30
  // cordova
31
31
  if (this._pkgConf.builder?.cordova) {
32
32
  this._debug("Preparing Cordova...");
33
- this.#cordova = new SdCliCordova({
33
+ this._cordova = new SdCliCordova({
34
34
  pkgPath: this._opt.pkgPath,
35
35
  config: this._pkgConf.builder.cordova,
36
36
  });
37
- await this.#cordova.initializeAsync();
37
+ await this._cordova.initializeAsync();
38
38
  }
39
39
 
40
40
  // routes
@@ -65,7 +65,7 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
65
65
  ISdClientPackageConfig["builder"]
66
66
  >)[];
67
67
 
68
- this.#ngBundlers = builderTypes.map(
68
+ this._ngBundlers = builderTypes.map(
69
69
  (builderType) =>
70
70
  new SdNgBundler(this._opt, {
71
71
  builderType: builderType,
@@ -76,7 +76,7 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
76
76
  }
77
77
 
78
78
  if (modifiedFileSet) {
79
- for (const ngBundler of this.#ngBundlers!) {
79
+ for (const ngBundler of this._ngBundlers!) {
80
80
  ngBundler.markForChanges(Array.from(modifiedFileSet));
81
81
  }
82
82
  }
@@ -84,7 +84,7 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
84
84
  if (this._opt.watch?.noEmit) {
85
85
  this._debug(`Building...`);
86
86
  const buildResults = await Promise.all(
87
- this.#ngBundlers!.map((builder) => builder.bundleAsync()),
87
+ this._ngBundlers!.map((builder) => builder.bundleAsync()),
88
88
  );
89
89
  const watchFileSet = new Set(buildResults.mapMany((item) => Array.from(item.watchFileSet)));
90
90
  const affectedFileSet = new Set(
@@ -104,7 +104,7 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
104
104
  } else {
105
105
  this._debug(`Building...`);
106
106
  const buildResults = await Promise.all(
107
- this.#ngBundlers!.map((builder) => builder.bundleAsync()),
107
+ this._ngBundlers!.map((builder) => builder.bundleAsync()),
108
108
  );
109
109
  const watchFileSet = new Set(buildResults.mapMany((item) => Array.from(item.watchFileSet)));
110
110
  const affectedFileSet = new Set(
@@ -113,9 +113,9 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
113
113
  const emitFileSet = new Set(buildResults.mapMany((item) => Array.from(item.emitFileSet)));
114
114
  const buildMessages = buildResults.mapMany((item) => item.buildMessages).distinct();
115
115
 
116
- if (!this._opt.watch?.dev && this.#cordova) {
116
+ if (!this._opt.watch?.dev && this._cordova) {
117
117
  this._debug("Building Cordova...");
118
- await this.#cordova.buildAsync(path.resolve(this._opt.pkgPath, "dist"));
118
+ await this._cordova.buildAsync(path.resolve(this._opt.pkgPath, "dist"));
119
119
  }
120
120
 
121
121
  if (!this._opt.watch?.dev && this._pkgConf.builder?.electron) {
@@ -43,47 +43,47 @@ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
43
43
  import { SdWorkerPathPlugin } from "../commons/SdWorkerPathPlugin";
44
44
 
45
45
  export class SdNgBundler {
46
- #logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundler"]);
46
+ private readonly _logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundler"]);
47
47
 
48
- #modifiedFileSet = new Set<TNormPath>();
49
- #ngResultCache: ISdCliNgPluginResultCache = {
48
+ private readonly _modifiedFileSet = new Set<TNormPath>();
49
+ private readonly _ngResultCache: ISdCliNgPluginResultCache = {
50
50
  affectedFileSet: new Set<TNormPath>(),
51
51
  watchFileSet: new Set<TNormPath>(),
52
52
  };
53
- #styleLoadResultCache = new MemoryLoadResultCache();
53
+ private readonly _styleLoadResultCache = new MemoryLoadResultCache();
54
54
 
55
- #contexts: SdNgBundlerContext[] | undefined;
55
+ private _contexts: SdNgBundlerContext[] | undefined;
56
56
 
57
- #outputHashCache = new Map<TNormPath, string>();
57
+ private readonly _outputHashCache = new Map<TNormPath, string>();
58
58
 
59
- #pkgNpmConf: INpmConfig;
60
- #mainFilePath: string;
61
- #tsConfigFilePath: string;
62
- #swConfFilePath: string;
63
- #browserTarget: string[];
64
- #indexHtmlFilePath: string;
65
- #pkgName: string;
66
- #baseHref: string;
67
- #outputPath: string;
59
+ private readonly _pkgNpmConf: INpmConfig;
60
+ private readonly _mainFilePath: string;
61
+ private readonly _tsConfigFilePath: string;
62
+ private readonly _swConfFilePath: string;
63
+ private readonly _browserTarget: string[];
64
+ private readonly _indexHtmlFilePath: string;
65
+ private readonly _pkgName: string;
66
+ private readonly _baseHref: string;
67
+ private readonly _outputPath: string;
68
68
 
69
69
  constructor(
70
70
  private readonly _opt: ISdTsCompilerOptions,
71
71
  private readonly _conf: IConf<any>,
72
72
  ) {
73
- this.#pkgNpmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json"));
74
- this.#mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
75
- this.#tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
76
- this.#swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
77
- this.#browserTarget = transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"]));
78
- this.#indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
79
- this.#pkgName = path.basename(this._opt.pkgPath);
80
- this.#baseHref =
73
+ this._pkgNpmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json"));
74
+ this._mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
75
+ this._tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
76
+ this._swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
77
+ this._browserTarget = transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"]));
78
+ this._indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
79
+ this._pkgName = path.basename(this._opt.pkgPath);
80
+ this._baseHref =
81
81
  this._conf.builderType === "web"
82
- ? `/${this.#pkgName}/`
82
+ ? `/${this._pkgName}/`
83
83
  : this._opt.watch?.dev
84
- ? `/${this.#pkgName}/${this._conf.builderType}/`
84
+ ? `/${this._pkgName}/${this._conf.builderType}/`
85
85
  : ``;
86
- this.#outputPath =
86
+ this._outputPath =
87
87
  this._conf.builderType === "web"
88
88
  ? PathUtils.norm(this._opt.pkgPath, "dist")
89
89
  : this._conf.builderType === "electron" && !this._opt.watch?.dev
@@ -95,8 +95,8 @@ export class SdNgBundler {
95
95
 
96
96
  markForChanges(filePaths: string[]): void {
97
97
  for (const filePath of filePaths) {
98
- this.#modifiedFileSet.add(PathUtils.norm(filePath));
99
- this.#styleLoadResultCache.invalidate(PathUtils.norm(filePath));
98
+ this._modifiedFileSet.add(PathUtils.norm(filePath));
99
+ this._styleLoadResultCache.invalidate(PathUtils.norm(filePath));
100
100
  /*if (this.#styleLoadResultCache.invalidate(PathUtils.norm(filePath))) {
101
101
  this.#styleLoadResultCache.invalidate(PathUtils.norm(this._opt.pkgPath, "src/styles.scss"));
102
102
  }*/
@@ -107,22 +107,22 @@ export class SdNgBundler {
107
107
  async bundleAsync(): Promise<ISdBuildResult> {
108
108
  const perf = new SdCliPerformanceTimer("ng bundle");
109
109
 
110
- this.#debug(`Preparing build contexts...`);
110
+ this._debug(`Preparing build contexts...`);
111
111
 
112
- if (!this.#contexts) {
113
- this.#contexts = perf.run("Preparing build contexts", () => [
114
- this.#getAppContext(),
112
+ if (!this._contexts) {
113
+ this._contexts = perf.run("Preparing build contexts", () => [
114
+ this._getAppContext(),
115
115
  ...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/styles.scss"))
116
- ? [this.#getStyleContext()]
116
+ ? [this._getStyleContext()]
117
117
  : []),
118
- ...(this._conf.builderType === "electron" ? [this.#getElectronMainContext()] : []),
118
+ ...(this._conf.builderType === "electron" ? [this._getElectronMainContext()] : []),
119
119
  ]);
120
120
  }
121
121
 
122
- this.#debug("Bundling...");
122
+ this._debug("Bundling...");
123
123
 
124
124
  const bundlingResults = await perf.run("Bundling", async () => {
125
- return await this.#contexts!.parallelAsync(async (ctx) => await ctx.bundleAsync());
125
+ return await this._contexts!.parallelAsync(async (ctx) => await ctx.bundleAsync());
126
126
  });
127
127
 
128
128
  //-- results
@@ -130,13 +130,13 @@ export class SdNgBundler {
130
130
 
131
131
  if (this._opt.watch?.noEmit) {
132
132
  return {
133
- watchFileSet: this.#ngResultCache.watchFileSet!,
134
- affectedFileSet: this.#ngResultCache.affectedFileSet!,
133
+ watchFileSet: this._ngResultCache.watchFileSet!,
134
+ affectedFileSet: this._ngResultCache.affectedFileSet!,
135
135
  buildMessages,
136
136
  emitFileSet: new Set<TNormPath>(),
137
137
  };
138
138
  } else {
139
- this.#debug(`Converting build results...`);
139
+ this._debug(`Converting build results...`);
140
140
 
141
141
  const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(
142
142
  (item) =>
@@ -161,9 +161,9 @@ export class SdNgBundler {
161
161
  outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
162
162
  }*/
163
163
 
164
- this.#debug(`Generating index.html...`);
164
+ this._debug(`Generating index.html...`);
165
165
  await perf.run("Generating index.html", async () => {
166
- const genIndexHtmlResult = await this.#genIndexHtmlAsync(outputFiles, initialFiles);
166
+ const genIndexHtmlResult = await this._genIndexHtmlAsync(outputFiles, initialFiles);
167
167
  for (const warning of genIndexHtmlResult.warnings) {
168
168
  buildMessages.push({
169
169
  filePath: undefined,
@@ -191,11 +191,11 @@ export class SdNgBundler {
191
191
  );
192
192
  });
193
193
 
194
- this.#debug(`Processing assets...`);
194
+ this._debug(`Processing assets...`);
195
195
  const assetFiles: { source: string; destination: string }[] = [];
196
196
  await perf.run("Processing assets", async () => {
197
197
  //-- copy assets
198
- assetFiles.push(...(await this.#copyAssetsAsync()));
198
+ assetFiles.push(...(await this._copyAssetsAsync()));
199
199
 
200
200
  //-- extract 3rdpartylicenses
201
201
  if (!this._opt.watch?.dev) {
@@ -210,12 +210,12 @@ export class SdNgBundler {
210
210
  });
211
211
 
212
212
  //-- service worker
213
- if (FsUtils.exists(this.#swConfFilePath) && !this._opt.watch?.dev) {
214
- this.#debug(`Preparing service worker...`);
213
+ if (FsUtils.exists(this._swConfFilePath) && !this._opt.watch?.dev) {
214
+ this._debug(`Preparing service worker...`);
215
215
 
216
216
  await perf.run("Preparing service worker", async () => {
217
217
  try {
218
- const serviceWorkerResult = await this.#genServiceWorkerAsync(outputFiles, assetFiles);
218
+ const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
219
219
  outputFiles.push(
220
220
  createOutputFile("ngsw.json", serviceWorkerResult.manifest, BuildOutputFileType.Root),
221
221
  );
@@ -235,13 +235,13 @@ export class SdNgBundler {
235
235
  }
236
236
 
237
237
  //-- write
238
- this.#debug(`Writing output files...(${outputFiles.length})`);
238
+ this._debug(`Writing output files...(${outputFiles.length})`);
239
239
 
240
240
  const emitFileSet = new Set<TNormPath>();
241
241
  await perf.run("Writing output file", async () => {
242
242
  const allOutputFiles = outputFiles
243
243
  .map((item) => ({
244
- path: PathUtils.norm(this.#outputPath, item.path),
244
+ path: PathUtils.norm(this._outputPath, item.path),
245
245
  contents: item.contents,
246
246
  hash: item.hash,
247
247
  }))
@@ -249,7 +249,7 @@ export class SdNgBundler {
249
249
  await assetFiles.parallelAsync(async (item) => {
250
250
  const contents = await FsUtils.readFileBufferAsync(item.source);
251
251
  return {
252
- path: PathUtils.norm(this.#outputPath, item.destination),
252
+ path: PathUtils.norm(this._outputPath, item.destination),
253
253
  contents,
254
254
  hash: HashUtils.get(contents),
255
255
  };
@@ -257,10 +257,10 @@ export class SdNgBundler {
257
257
  );
258
258
 
259
259
  for (const outputFile of allOutputFiles) {
260
- const prevHash = this.#outputHashCache.get(outputFile.path);
260
+ const prevHash = this._outputHashCache.get(outputFile.path);
261
261
  if (prevHash !== outputFile.hash) {
262
262
  await FsUtils.writeFileAsync(outputFile.path, outputFile.contents);
263
- this.#outputHashCache.set(outputFile.path, outputFile.hash);
263
+ this._outputHashCache.set(outputFile.path, outputFile.hash);
264
264
  emitFileSet.add(outputFile.path);
265
265
  }
266
266
  }
@@ -291,23 +291,23 @@ export class SdNgBundler {
291
291
  ]);*/
292
292
  });
293
293
 
294
- this.#debug(`Build performance summary:\n${perf.toString()}`);
294
+ this._debug(`Build performance summary:\n${perf.toString()}`);
295
295
 
296
296
  return {
297
297
  watchFileSet: new Set([
298
- ...this.#ngResultCache.watchFileSet!,
299
- ...this.#styleLoadResultCache.watchFiles.map((item) => PathUtils.norm(item)),
298
+ ...this._ngResultCache.watchFileSet!,
299
+ ...this._styleLoadResultCache.watchFiles.map((item) => PathUtils.norm(item)),
300
300
  ...assetFiles.map((item) => PathUtils.norm(item.source)),
301
- PathUtils.norm(this.#indexHtmlFilePath),
301
+ PathUtils.norm(this._indexHtmlFilePath),
302
302
  ]),
303
- affectedFileSet: this.#ngResultCache.affectedFileSet!,
303
+ affectedFileSet: this._ngResultCache.affectedFileSet!,
304
304
  buildMessages,
305
305
  emitFileSet: emitFileSet,
306
306
  };
307
307
  }
308
308
  }
309
309
 
310
- async #genIndexHtmlAsync(
310
+ private async _genIndexHtmlAsync(
311
311
  outputFiles: esbuild.OutputFile[],
312
312
  initialFiles: Map<string, InitialFileRecord>,
313
313
  ): Promise<IndexHtmlProcessResult> {
@@ -322,7 +322,7 @@ export class SdNgBundler {
322
322
  };
323
323
 
324
324
  const indexHtmlGenerator = new IndexHtmlGenerator({
325
- indexPath: this.#indexHtmlFilePath,
325
+ indexPath: this._indexHtmlFilePath,
326
326
  entrypoints: [
327
327
  ["polyfills", true],
328
328
  ["styles", false],
@@ -365,7 +365,7 @@ export class SdNgBundler {
365
365
  }
366
366
 
367
367
  return await indexHtmlGenerator.process({
368
- baseHref: this.#baseHref,
368
+ baseHref: this._baseHref,
369
369
  lang: undefined,
370
370
  outputPath: "/",
371
371
  files: [...initialFiles].map(([file, record]) => ({
@@ -377,7 +377,7 @@ export class SdNgBundler {
377
377
  });
378
378
  }
379
379
 
380
- async #copyAssetsAsync(): Promise<
380
+ private async _copyAssetsAsync(): Promise<
381
381
  {
382
382
  source: string;
383
383
  destination: string;
@@ -418,7 +418,7 @@ export class SdNgBundler {
418
418
  );
419
419
  }
420
420
 
421
- async #genServiceWorkerAsync(
421
+ private async _genServiceWorkerAsync(
422
422
  outputFiles: BuildOutputFile[],
423
423
  assetFiles: {
424
424
  source: string;
@@ -433,15 +433,15 @@ export class SdNgBundler {
433
433
  }> {
434
434
  return await augmentAppWithServiceWorkerEsbuild(
435
435
  this._opt.pkgPath,
436
- this.#swConfFilePath,
437
- this.#baseHref,
436
+ this._swConfFilePath,
437
+ this._baseHref,
438
438
  "index.html",
439
439
  outputFiles,
440
440
  assetFiles,
441
441
  );
442
442
  }
443
443
 
444
- #getAppContext() {
444
+ private _getAppContext() {
445
445
  /*const workerEntries = (
446
446
  await FsUtils.globAsync(path.resolve(this._opt.pkgPath, "src/workers/!*.ts"))
447
447
  ).toObject((p) => "workers/" + path.basename(p, path.extname(p)));*/
@@ -464,7 +464,7 @@ export class SdNgBundler {
464
464
  outExtension: undefined,
465
465
  sourcemap: !!this._opt.watch?.dev,
466
466
  chunkNames: "[name]-[hash]",
467
- tsconfig: this.#tsConfigFilePath,
467
+ tsconfig: this._tsConfigFilePath,
468
468
  write: false,
469
469
  preserveSymlinks: false,
470
470
  define: {
@@ -473,7 +473,7 @@ export class SdNgBundler {
473
473
  "global": "global",
474
474
  "process": "process",
475
475
  "Buffer": "Buffer",
476
- "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
476
+ "process.env.SD_VERSION": JSON.stringify(this._pkgNpmConf.version),
477
477
  "process.env.NODE_ENV": JSON.stringify(this._opt.watch?.dev ? "development" : "production"),
478
478
  ...(this._conf.env
479
479
  ? Object.keys(this._conf.env).toObject(
@@ -485,7 +485,7 @@ export class SdNgBundler {
485
485
  mainFields: ["es2020", "es2015", "browser", "module", "main"],
486
486
  entryNames: "[dir]/[name]",
487
487
  entryPoints: {
488
- main: this.#mainFilePath,
488
+ main: this._mainFilePath,
489
489
  ...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/polyfills.ts"))
490
490
  ? {
491
491
  polyfills: path.resolve(this._opt.pkgPath, "src/polyfills.ts"),
@@ -543,7 +543,7 @@ export class SdNgBundler {
543
543
  }
544
544
  : {
545
545
  platform: "browser",
546
- target: this.#browserTarget,
546
+ target: this._browserTarget,
547
547
  format: "esm",
548
548
  splitting: true,
549
549
  inject: [
@@ -554,7 +554,7 @@ export class SdNgBundler {
554
554
  }),
555
555
  plugins: [
556
556
  createSourcemapIgnorelistPlugin(),
557
- createSdNgPlugin(this._opt, this.#modifiedFileSet, this.#ngResultCache),
557
+ createSdNgPlugin(this._opt, this._modifiedFileSet, this._ngResultCache),
558
558
  ...(this._conf.builderType === "electron"
559
559
  ? []
560
560
  : [nodeStdLibBrowserPlugin(nodeStdLibBrowser)]),
@@ -574,13 +574,13 @@ export class SdNgBundler {
574
574
  });
575
575
  }
576
576
 
577
- #getStyleContext(): SdNgBundlerContext {
577
+ private _getStyleContext(): SdNgBundlerContext {
578
578
  const pluginFactory = new StylesheetPluginFactory(
579
579
  {
580
580
  sourcemap: !!this._opt.watch?.dev,
581
581
  includePaths: [],
582
582
  },
583
- this.#styleLoadResultCache,
583
+ this._styleLoadResultCache,
584
584
  );
585
585
 
586
586
  return new SdNgBundlerContext(this._opt.pkgPath, !!this._opt.watch, {
@@ -595,7 +595,7 @@ export class SdNgBundler {
595
595
  outdir: this._opt.pkgPath,
596
596
  write: false,
597
597
  platform: "browser",
598
- target: this.#browserTarget,
598
+ target: this._browserTarget,
599
599
  preserveSymlinks: false,
600
600
  external: [],
601
601
  conditions: ["style", "sass"],
@@ -607,12 +607,12 @@ export class SdNgBundler {
607
607
  plugins: [
608
608
  pluginFactory.create(SassStylesheetLanguage),
609
609
  pluginFactory.create(CssStylesheetLanguage),
610
- createCssResourcePlugin(this.#styleLoadResultCache),
610
+ createCssResourcePlugin(this._styleLoadResultCache),
611
611
  ],
612
612
  });
613
613
  }
614
614
 
615
- #getElectronMainContext() {
615
+ private _getElectronMainContext() {
616
616
  return new SdNgBundlerContext(this._opt.pkgPath, !!this._opt.watch, {
617
617
  absWorkingDir: this._opt.pkgPath,
618
618
  bundle: true,
@@ -626,7 +626,7 @@ export class SdNgBundler {
626
626
  minify: !this._opt.watch?.dev,
627
627
  outdir: this._opt.pkgPath,
628
628
  sourcemap: !!this._opt.watch?.dev,
629
- tsconfig: this.#tsConfigFilePath,
629
+ tsconfig: this._tsConfigFilePath,
630
630
  write: false,
631
631
  preserveSymlinks: false,
632
632
  external: [
@@ -636,7 +636,7 @@ export class SdNgBundler {
636
636
  ],
637
637
  define: {
638
638
  ...(!this._opt.watch?.dev ? { ngDevMode: "false" } : {}),
639
- "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
639
+ "process.env.SD_VERSION": JSON.stringify(this._pkgNpmConf.version),
640
640
  "process.env.NODE_ENV": JSON.stringify(this._opt.watch?.dev ? "development" : "production"),
641
641
  ...(this._conf.env
642
642
  ? Object.keys(this._conf.env).toObject(
@@ -652,8 +652,8 @@ export class SdNgBundler {
652
652
  });
653
653
  }
654
654
 
655
- #debug(...msg: any[]): void {
656
- this.#logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
655
+ private _debug(...msg: any[]): void {
656
+ this._logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
657
657
  }
658
658
  }
659
659