@simplysm/sd-cli 12.13.37 → 12.13.39

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 (121) hide show
  1. package/dist/pkg-builders/SdBuildRunnerBase.d.ts +14 -0
  2. package/dist/pkg-builders/SdBuildRunnerBase.js +23 -0
  3. package/dist/pkg-builders/SdBuildRunnerBase.js.map +1 -0
  4. package/dist/pkg-builders/SdProjectBuildRunner.js +18 -14
  5. package/dist/pkg-builders/SdProjectBuildRunner.js.map +1 -1
  6. package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +1 -1
  7. package/dist/pkg-builders/client/SdClientBuildRunner.js +17 -36
  8. package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -1
  9. package/dist/pkg-builders/client/SdNgBundler.d.ts +10 -16
  10. package/dist/pkg-builders/client/SdNgBundler.js +59 -54
  11. package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
  12. package/dist/pkg-builders/client/createSdNgPlugin.d.ts +2 -11
  13. package/dist/pkg-builders/client/createSdNgPlugin.js +16 -25
  14. package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
  15. package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
  16. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +5 -5
  17. package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -1
  18. package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +1 -1
  19. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +6 -6
  20. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -1
  21. package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +3 -3
  22. package/dist/pkg-builders/lib/SdTsLibBuilder.js +6 -15
  23. package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
  24. package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +1 -1
  25. package/dist/pkg-builders/server/SdServerBuildRunner.js +25 -42
  26. package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -1
  27. package/dist/pkg-builders/server/SdServerBundler.d.ts +4 -10
  28. package/dist/pkg-builders/server/SdServerBundler.js +15 -22
  29. package/dist/pkg-builders/server/SdServerBundler.js.map +1 -1
  30. package/dist/pkg-builders/server/createSdServerPlugin.d.ts +2 -11
  31. package/dist/pkg-builders/server/createSdServerPlugin.js +10 -19
  32. package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -1
  33. package/dist/sd-cli-entry.js +1 -1
  34. package/dist/sd-cli-entry.js.map +1 -1
  35. package/dist/ts-compiler/ScopePathSet.js.map +1 -0
  36. package/dist/ts-compiler/SdDepAnalyzer.d.ts +1 -1
  37. package/dist/ts-compiler/SdStyleBundler.d.ts +8 -5
  38. package/dist/ts-compiler/SdStyleBundler.js +30 -15
  39. package/dist/ts-compiler/SdStyleBundler.js.map +1 -1
  40. package/dist/ts-compiler/SdTsCompiler.d.ts +2 -1
  41. package/dist/ts-compiler/SdTsCompiler.js +68 -53
  42. package/dist/ts-compiler/SdTsCompiler.js.map +1 -1
  43. package/dist/types/build/ISdTsCompilerOptions.d.ts +6 -9
  44. package/dist/types/worker/ISdBuildRunnerWorkerType.d.ts +4 -7
  45. package/dist/workers/build-runner.worker.js +4 -5
  46. package/dist/workers/build-runner.worker.js.map +1 -1
  47. package/package.json +5 -5
  48. package/src/pkg-builders/SdBuildRunnerBase.ts +36 -0
  49. package/src/pkg-builders/SdProjectBuildRunner.ts +24 -16
  50. package/src/pkg-builders/client/SdClientBuildRunner.ts +25 -46
  51. package/src/pkg-builders/client/SdNgBundler.ts +69 -73
  52. package/src/pkg-builders/client/createSdNgPlugin.ts +21 -35
  53. package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +5 -5
  54. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +9 -13
  55. package/src/pkg-builders/lib/SdTsLibBuilder.ts +7 -23
  56. package/src/pkg-builders/server/SdServerBuildRunner.ts +32 -50
  57. package/src/pkg-builders/server/SdServerBundler.ts +16 -32
  58. package/src/pkg-builders/server/createSdServerPlugin.ts +15 -29
  59. package/src/sd-cli-entry.ts +1 -1
  60. package/src/ts-compiler/SdDepAnalyzer.ts +1 -1
  61. package/src/ts-compiler/SdStyleBundler.ts +34 -15
  62. package/src/ts-compiler/SdTsCompiler.ts +75 -63
  63. package/src/types/build/ISdTsCompilerOptions.ts +6 -9
  64. package/src/types/worker/ISdBuildRunnerWorkerType.ts +4 -9
  65. package/src/workers/build-runner.worker.ts +7 -16
  66. package/dist/fix/convert-extends-sd-modal-base-to-interface.d.ts +0 -1
  67. package/dist/fix/convert-extends-sd-modal-base-to-interface.js +0 -289
  68. package/dist/fix/convert-extends-sd-modal-base-to-interface.js.map +0 -1
  69. package/dist/fix/convert-extends-sd-print-template-base-to-interface.d.ts +0 -1
  70. package/dist/fix/convert-extends-sd-print-template-base-to-interface.js +0 -179
  71. package/dist/fix/convert-extends-sd-print-template-base-to-interface.js.map +0 -1
  72. package/dist/fix/convert-flat-pages-to-flat-menus.d.ts +0 -1
  73. package/dist/fix/convert-flat-pages-to-flat-menus.js +0 -68
  74. package/dist/fix/convert-flat-pages-to-flat-menus.js.map +0 -1
  75. package/dist/fix/convert-get-menus-to-usable-menus.d.ts +0 -1
  76. package/dist/fix/convert-get-menus-to-usable-menus.js +0 -48
  77. package/dist/fix/convert-get-menus-to-usable-menus.js.map +0 -1
  78. package/dist/fix/convert-modal-show-params.d.ts +0 -1
  79. package/dist/fix/convert-modal-show-params.js +0 -29
  80. package/dist/fix/convert-modal-show-params.js.map +0 -1
  81. package/dist/fix/convert-print-params.d.ts +0 -1
  82. package/dist/fix/convert-print-params.js +0 -37
  83. package/dist/fix/convert-print-params.js.map +0 -1
  84. package/dist/fix/convert-sd-icon-to-fa-icon.d.ts +0 -1
  85. package/dist/fix/convert-sd-icon-to-fa-icon.js +0 -80
  86. package/dist/fix/convert-sd-icon-to-fa-icon.js.map +0 -1
  87. package/dist/fix/convert-sd-sheet-bindings-safety.d.ts +0 -1
  88. package/dist/fix/convert-sd-sheet-bindings-safety.js +0 -57
  89. package/dist/fix/convert-sd-sheet-bindings-safety.js.map +0 -1
  90. package/dist/fix/convert-select-modal-button-to-select-button.d.ts +0 -1
  91. package/dist/fix/convert-select-modal-button-to-select-button.js +0 -64
  92. package/dist/fix/convert-select-modal-button-to-select-button.js.map +0 -1
  93. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.d.ts +0 -1
  94. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js +0 -38
  95. package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js.map +0 -1
  96. package/dist/fix/convert-to-use-perms-signal.d.ts +0 -1
  97. package/dist/fix/convert-to-use-perms-signal.js +0 -99
  98. package/dist/fix/convert-to-use-perms-signal.js.map +0 -1
  99. package/dist/fix/core/remove-named-import.d.ts +0 -1
  100. package/dist/fix/core/remove-named-import.js +0 -14
  101. package/dist/fix/core/remove-named-import.js.map +0 -1
  102. package/dist/pkg-builders/commons/ScopePathSet.js.map +0 -1
  103. package/dist/pkg-builders/commons/SdBuildRunnerBase.d.ts +0 -20
  104. package/dist/pkg-builders/commons/SdBuildRunnerBase.js +0 -30
  105. package/dist/pkg-builders/commons/SdBuildRunnerBase.js.map +0 -1
  106. package/src/fix/convert-extends-sd-modal-base-to-interface.ts +0 -324
  107. package/src/fix/convert-extends-sd-print-template-base-to-interface.ts +0 -201
  108. package/src/fix/convert-flat-pages-to-flat-menus.ts +0 -83
  109. package/src/fix/convert-get-menus-to-usable-menus.ts +0 -60
  110. package/src/fix/convert-modal-show-params.ts +0 -37
  111. package/src/fix/convert-print-params.ts +0 -51
  112. package/src/fix/convert-sd-icon-to-fa-icon.ts +0 -95
  113. package/src/fix/convert-sd-sheet-bindings-safety.ts +0 -73
  114. package/src/fix/convert-select-modal-button-to-select-button.ts +0 -91
  115. package/src/fix/convert-setup-cumulate-selected-keys-to-object-param.ts +0 -44
  116. package/src/fix/convert-to-use-perms-signal.ts +0 -133
  117. package/src/fix/core/remove-named-import.ts +0 -14
  118. package/src/pkg-builders/commons/SdBuildRunnerBase.ts +0 -47
  119. /package/dist/{pkg-builders/commons → ts-compiler}/ScopePathSet.d.ts +0 -0
  120. /package/dist/{pkg-builders/commons → ts-compiler}/ScopePathSet.js +0 -0
  121. /package/src/{pkg-builders/commons → ts-compiler}/ScopePathSet.ts +0 -0
@@ -2,31 +2,15 @@ import path from "path";
2
2
  import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
3
3
  import { FsUtils, HashUtils, PathUtils, TNormPath } from "@simplysm/sd-core-node";
4
4
  import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
5
- import { ScopePathSet } from "../commons/ScopePathSet";
6
5
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
6
+ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
7
7
 
8
8
  export class SdTsLibBuilder {
9
9
  #tsCompiler: SdTsCompiler;
10
10
  #outputHashCache = new Map<TNormPath, string>();
11
11
 
12
- constructor(
13
- private readonly _pkgPath: TNormPath,
14
- watch: boolean,
15
- dev: boolean,
16
- emitOnly: boolean,
17
- noEmit: boolean,
18
- scopePathSet: ScopePathSet,
19
- ) {
20
- this.#tsCompiler = new SdTsCompiler({
21
- pkgPath: this._pkgPath,
22
- additionalOptions: { declaration: true },
23
- isWatchMode: watch,
24
- isDevMode: dev,
25
- isEmitOnly: emitOnly,
26
- isNoEmit: noEmit,
27
- isForBundle: false,
28
- scopePathSet,
29
- });
12
+ constructor(private readonly _opt: ISdTsCompilerOptions) {
13
+ this.#tsCompiler = new SdTsCompiler(_opt, false);
30
14
  }
31
15
 
32
16
  async buildAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
@@ -55,11 +39,11 @@ export class SdTsLibBuilder {
55
39
  if (globalStylesheetBundlingResult && "outputFiles" in globalStylesheetBundlingResult) {
56
40
  for (const outputFile of globalStylesheetBundlingResult.outputFiles) {
57
41
  const distPath = PathUtils.norm(
58
- this._pkgPath,
42
+ this._opt.pkgPath,
59
43
  "dist",
60
- path.relative(this._pkgPath, outputFile.path),
44
+ path.relative(this._opt.pkgPath, outputFile.path),
61
45
  );
62
- if (PathUtils.isChildPath(distPath, path.resolve(this._pkgPath, "dist"))) {
46
+ if (PathUtils.isChildPath(distPath, path.resolve(this._opt.pkgPath, "dist"))) {
63
47
  const prevHash = this.#outputHashCache.get(distPath);
64
48
  const currHash = HashUtils.get(Buffer.from(outputFile.text));
65
49
  if (prevHash !== currHash) {
@@ -73,7 +57,7 @@ export class SdTsLibBuilder {
73
57
  }
74
58
 
75
59
  const styleResults = Array.from(tsCompileResult.stylesheetBundlingResultMap.values()).mapMany(
76
- (item) => SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(item, this._pkgPath),
60
+ (item) => SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(item, this._opt.pkgPath),
77
61
  );
78
62
 
79
63
  return {
@@ -1,49 +1,36 @@
1
1
  import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
3
  import { javascript, StringUtils } from "@simplysm/sd-core-common";
4
- import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
4
+ import { SdBuildRunnerBase } from "../SdBuildRunnerBase";
5
5
  import { SdServerBundler } from "./SdServerBundler";
6
6
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
7
- import { ITsConfig } from "../../types/common-config/ITsConfig";
8
7
  import { INpmConfig } from "../../types/common-config/INpmConfig";
9
8
 
10
9
  export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
11
10
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBuild2Runner"]);
12
11
 
13
12
  #serverBundler?: SdServerBundler;
14
- #extModules?: { name: string; exists: boolean }[];
15
13
 
16
14
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
17
- // prod일때 각종 파일들 생성
18
- if (!this._dev) {
19
- await this.#generateProductionFilesAsync();
20
- }
21
-
22
15
  // 최초
23
16
  if (!modifiedFileSet) {
24
- if (!this._noEmit) {
17
+ const externalModules = this.#getExternalModules();
18
+
19
+ if (!this._opt.watch?.dev) {
20
+ this.#generateProductionFiles(
21
+ externalModules.filter((item) => item.exists).map((item) => item.name),
22
+ );
23
+ }
24
+
25
+ if (!this._opt.watch?.noEmit) {
25
26
  this._debug("GEN .config...");
26
- const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
27
+ const confDistPath = path.resolve(this._opt.pkgPath, "dist/.config.json");
27
28
  FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
28
29
  }
29
30
 
30
31
  this._debug(`BUILD 준비...`);
31
- const tsConfig = FsUtils.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
32
- this.#extModules = this.#extModules ?? (await this.#getExternalModulesAsync());
33
- this.#serverBundler = new SdServerBundler({
34
- watch: this._watch,
35
- dev: this._dev,
36
- emitOnly: this._emitOnly ?? false,
37
- noEmit: this._noEmit ?? false,
38
- pkgPath: this._pkgPath,
39
- entryPoints: tsConfig.files
40
- ? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
41
- : [
42
- path.resolve(this._pkgPath, "src/main.ts"),
43
- ...FsUtils.glob(path.resolve(this._pkgPath, "src/workers/*.ts")),
44
- ],
45
- external: this.#extModules.map((item) => item.name),
46
- scopePathSet: this._scopePathSet,
32
+ this.#serverBundler = new SdServerBundler(this._opt, {
33
+ external: externalModules.map((item) => item.name),
47
34
  });
48
35
  }
49
36
 
@@ -54,17 +41,14 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
54
41
  return bundleResult;
55
42
  }
56
43
 
57
- async #generateProductionFilesAsync() {
58
- const npmConf = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
44
+ #generateProductionFiles(externals: string[]) {
45
+ const npmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json")) as INpmConfig;
59
46
 
60
47
  this._debug("GEN package.json...");
61
48
  {
62
49
  const projNpmConf = FsUtils.readJson(
63
50
  path.resolve(process.cwd(), "package.json"),
64
51
  ) as INpmConfig;
65
- const extModules = await this.#getExternalModulesAsync();
66
-
67
- const deps = extModules.filter((item) => item.exists).map((item) => item.name);
68
52
 
69
53
  const distNpmConfig: INpmConfig = {
70
54
  name: npmConf.name,
@@ -72,13 +56,13 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
72
56
  type: npmConf.type,
73
57
  };
74
58
  distNpmConfig.dependencies = {};
75
- for (const dep of deps) {
76
- distNpmConfig.dependencies[dep] = "*";
59
+ for (const external of externals) {
60
+ distNpmConfig.dependencies[external] = "*";
77
61
  }
78
62
 
79
63
  distNpmConfig.volta = projNpmConf.volta;
80
64
 
81
- FsUtils.writeJson(path.resolve(this._pkgPath, "dist/package.json"), distNpmConfig, {
65
+ FsUtils.writeJson(path.resolve(this._opt.pkgPath, "dist/package.json"), distNpmConfig, {
82
66
  space: 2,
83
67
  });
84
68
  }
@@ -86,7 +70,7 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
86
70
  this._debug("GEN .yarnrc.yml...");
87
71
  {
88
72
  FsUtils.writeFile(
89
- path.resolve(this._pkgPath, "dist/.yarnrc.yml"),
73
+ path.resolve(this._opt.pkgPath, "dist/.yarnrc.yml"),
90
74
  "nodeLinker: node-modules",
91
75
  );
92
76
  }
@@ -94,7 +78,7 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
94
78
  this._debug("GEN openssl.cnf...");
95
79
  {
96
80
  FsUtils.writeFile(
97
- path.resolve(this._pkgPath, "dist/openssl.cnf"),
81
+ path.resolve(this._opt.pkgPath, "dist/openssl.cnf"),
98
82
  `
99
83
  nodejs_conf = openssl_init
100
84
 
@@ -157,13 +141,13 @@ Options = UnsafeLegacyRenegotiation`.trim(),
157
141
  .replaceAll("\n ", "\n")
158
142
  .trim();
159
143
 
160
- FsUtils.writeFile(path.resolve(this._pkgPath, "dist/pm2.config.cjs"), str);
144
+ FsUtils.writeFile(path.resolve(this._opt.pkgPath, "dist/pm2.config.cjs"), str);
161
145
  }
162
146
 
163
147
  if (this._pkgConf.iis) {
164
148
  this._debug("GEN web.config...");
165
149
 
166
- const iisDistPath = path.resolve(this._pkgPath, "dist/web.config");
150
+ const iisDistPath = path.resolve(this._opt.pkgPath, "dist/web.config");
167
151
  const nodeVersion = process.versions.node.substring(1);
168
152
  const serverExeFilePath =
169
153
  this._pkgConf.iis.nodeExeFilePath ??
@@ -203,12 +187,10 @@ Options = UnsafeLegacyRenegotiation`.trim(),
203
187
  }
204
188
  }
205
189
 
206
- async #getExternalModulesAsync(): Promise<
207
- {
208
- name: string;
209
- exists: boolean;
210
- }[]
211
- > {
190
+ #getExternalModules(): {
191
+ name: string;
192
+ exists: boolean;
193
+ }[] {
212
194
  const loadedModuleNames: string[] = [];
213
195
  const results: {
214
196
  name: string;
@@ -217,7 +199,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
217
199
 
218
200
  const npmConfigMap = new Map<string, INpmConfig>();
219
201
 
220
- const fn = async (currPath: string): Promise<void> => {
202
+ const fn = (currPath: string) => {
221
203
  const npmConfig = npmConfigMap.getOrCreate(
222
204
  currPath,
223
205
  FsUtils.readJson(path.resolve(currPath, "package.json")),
@@ -245,7 +227,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
245
227
  const modulePath = FsUtils.findAllParentChildPaths(
246
228
  "node_modules/" + moduleName,
247
229
  currPath,
248
- path.resolve(this._pkgPath, "../../"),
230
+ path.resolve(this._opt.pkgPath, "../../"),
249
231
  ).first();
250
232
  if (StringUtils.isNullOrEmpty(modulePath)) {
251
233
  continue;
@@ -265,7 +247,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
265
247
  });
266
248
  }
267
249
 
268
- await fn(modulePath);
250
+ fn(modulePath);
269
251
  }
270
252
 
271
253
  for (const optModuleName of deps.optionals) {
@@ -275,7 +257,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
275
257
  const optModulePath = FsUtils.findAllParentChildPaths(
276
258
  "node_modules/" + optModuleName,
277
259
  currPath,
278
- path.resolve(this._pkgPath, "../../"),
260
+ path.resolve(this._opt.pkgPath, "../../"),
279
261
  ).first();
280
262
  if (StringUtils.isNullOrEmpty(optModulePath)) {
281
263
  results.push({
@@ -299,11 +281,11 @@ Options = UnsafeLegacyRenegotiation`.trim(),
299
281
  });
300
282
  }
301
283
 
302
- await fn(optModulePath);
284
+ fn(optModulePath);
303
285
  }
304
286
  };
305
287
 
306
- await fn(this._pkgPath);
288
+ fn(this._opt.pkgPath);
307
289
 
308
290
  for (const external of this._pkgConf.externals ?? []) {
309
291
  if (!results.some((item) => item.name === external)) {
@@ -9,9 +9,9 @@ import {
9
9
  } from "@angular/build/src/tools/esbuild/bundler-context";
10
10
  import { convertOutputFile } from "@angular/build/src/tools/esbuild/utils";
11
11
  import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
12
- import { ScopePathSet } from "../commons/ScopePathSet";
13
12
  import { ISdCliServerPluginResultCache } from "../../types/plugin/ISdCliServerPluginResultCache";
14
13
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
14
+ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
15
15
 
16
16
  export class SdServerBundler {
17
17
  #logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
@@ -24,16 +24,8 @@ export class SdServerBundler {
24
24
  #outputHashCache = new Map<TNormPath, string>();
25
25
 
26
26
  constructor(
27
- private readonly _opt: {
28
- watch: boolean;
29
- dev: boolean;
30
- emitOnly: boolean;
31
- noEmit: boolean;
32
- pkgPath: TNormPath;
33
- entryPoints: string[];
34
- external?: string[];
35
- scopePathSet: ScopePathSet;
36
- },
27
+ private readonly _opt: ISdTsCompilerOptions,
28
+ private readonly _conf: { external: string[] },
37
29
  ) {}
38
30
 
39
31
  async bundleAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
@@ -44,20 +36,23 @@ export class SdServerBundler {
44
36
 
45
37
  if (!this.#context) {
46
38
  this.#context = await esbuild.context({
47
- entryPoints: this._opt.entryPoints,
39
+ entryPoints: [
40
+ path.resolve(this._opt.pkgPath, "src/main.ts"),
41
+ ...FsUtils.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")),
42
+ ],
48
43
  keepNames: true,
49
44
  bundle: true,
50
- sourcemap: this._opt.dev,
45
+ sourcemap: !!this._opt.watch?.dev,
51
46
  target: "node18",
52
47
  mainFields: ["es2020", "es2015", "module", "main"],
53
48
  conditions: ["es2020", "es2015", "module"],
54
49
  tsconfig: path.resolve(this._opt.pkgPath, "tsconfig.json"),
55
50
  write: false,
56
51
  metafile: true,
57
- legalComments: this._opt.dev ? "eof" : "none",
58
- minifyIdentifiers: !this._opt.dev,
59
- minifySyntax: !this._opt.dev,
60
- minifyWhitespace: !this._opt.dev,
52
+ legalComments: this._opt.watch?.dev ? "eof" : "none",
53
+ minifyIdentifiers: !this._opt.watch?.dev,
54
+ minifySyntax: !this._opt.watch?.dev,
55
+ minifyWhitespace: !this._opt.watch?.dev,
61
56
  outdir: path.resolve(this._opt.pkgPath, "dist"),
62
57
  format: "esm",
63
58
  resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
@@ -91,7 +86,7 @@ export class SdServerBundler {
91
86
  },
92
87
  platform: "node",
93
88
  logLevel: "silent",
94
- external: this._opt.external,
89
+ external: this._conf.external,
95
90
  banner: {
96
91
  js: `
97
92
  import __path__ from 'path';
@@ -102,25 +97,14 @@ const require = __createRequire__(import.meta.url);
102
97
  const __filename = __fileURLToPath__(import.meta.url);
103
98
  const __dirname = __path__.dirname(__filename);`.trim(),
104
99
  },
105
- plugins: [
106
- createSdServerPlugin({
107
- modifiedFileSet: this.#modifiedFileSet,
108
- watch: this._opt.watch,
109
- dev: this._opt.dev,
110
- emitOnly: this._opt.emitOnly,
111
- noEmit: this._opt.noEmit,
112
- pkgPath: this._opt.pkgPath,
113
- result: this.#resultCache,
114
- scopePathSet: this._opt.scopePathSet,
115
- }),
116
- ],
100
+ plugins: [createSdServerPlugin(this._opt, this.#modifiedFileSet, this.#resultCache)],
117
101
  });
118
102
  }
119
103
 
120
104
  let esbuildResult: esbuild.BuildResult | esbuild.BuildFailure;
121
105
  esbuildResult = await this.#context.rebuild();
122
106
 
123
- if (this._opt.noEmit) {
107
+ if (this._opt.watch?.noEmit) {
124
108
  return {
125
109
  buildMessages: SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
126
110
  esbuildResult,
@@ -155,7 +139,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
155
139
  const assetFiles = await resolveAssets(
156
140
  [
157
141
  { input: "public", glob: "**/*", output: "." },
158
- ...(this._opt.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
142
+ ...(this._opt.watch?.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
159
143
  ],
160
144
  this._opt.pkgPath,
161
145
  );
@@ -2,41 +2,27 @@ import esbuild from "esbuild";
2
2
  import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
3
3
  import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
4
4
  import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
5
- import { ScopePathSet } from "../commons/ScopePathSet";
6
5
  import { ISdCliServerPluginResultCache } from "../../types/plugin/ISdCliServerPluginResultCache";
7
6
  import { ISdTsCompilerResult } from "../../types/build/ISdTsCompilerResult";
7
+ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
8
8
 
9
- export function createSdServerPlugin(conf: {
10
- pkgPath: TNormPath;
11
- watch: boolean;
12
- dev: boolean;
13
- emitOnly: boolean;
14
- noEmit: boolean;
15
- modifiedFileSet: Set<TNormPath>;
16
- result: ISdCliServerPluginResultCache;
17
- scopePathSet: ScopePathSet;
18
- }): esbuild.Plugin {
9
+ export function createSdServerPlugin(
10
+ conf: ISdTsCompilerOptions,
11
+ modifiedFileSet: Set<TNormPath>,
12
+ resultCache: ISdCliServerPluginResultCache,
13
+ ): esbuild.Plugin {
19
14
  return {
20
15
  name: "sd-server-compile",
21
16
  setup: (build: esbuild.PluginBuild) => {
22
- const tsCompiler = new SdTsCompiler({
23
- pkgPath: conf.pkgPath,
24
- additionalOptions: { declaration: false },
25
- isWatchMode: conf.watch,
26
- isDevMode: conf.dev,
27
- isNoEmit: conf.noEmit,
28
- isEmitOnly: conf.emitOnly,
29
- isForBundle: true,
30
- scopePathSet: conf.scopePathSet,
31
- });
17
+ const tsCompiler = new SdTsCompiler(conf, true);
32
18
 
33
19
  let tsCompileResult: ISdTsCompilerResult;
34
20
 
35
21
  build.onStart(async () => {
36
- tsCompileResult = await tsCompiler.compileAsync(conf.modifiedFileSet);
22
+ tsCompileResult = await tsCompiler.compileAsync(modifiedFileSet);
37
23
 
38
- conf.result.watchFileSet = tsCompileResult.watchFileSet;
39
- conf.result.affectedFileSet = tsCompileResult.affectedFileSet;
24
+ resultCache.watchFileSet = tsCompileResult.watchFileSet;
25
+ resultCache.affectedFileSet = tsCompileResult.affectedFileSet;
40
26
 
41
27
  //-- return err/warn
42
28
  return SdCliConvertMessageUtils.convertToEsbuildFromBuildMessages(
@@ -63,7 +49,7 @@ export function createSdServerPlugin(conf: {
63
49
  });
64
50
 
65
51
  build.onLoad({ filter: /\.[cm]?js$/ }, (args) => {
66
- conf.result.watchFileSet!.add(PathUtils.norm(args.path));
52
+ resultCache.watchFileSet!.add(PathUtils.norm(args.path));
67
53
  return null;
68
54
  });
69
55
 
@@ -78,16 +64,16 @@ export function createSdServerPlugin(conf: {
78
64
  ),
79
65
  },
80
66
  (args) => {
81
- conf.result.watchFileSet!.add(PathUtils.norm(args.path));
67
+ resultCache.watchFileSet!.add(PathUtils.norm(args.path));
82
68
  return null;
83
69
  },
84
70
  );
85
71
 
86
72
  build.onEnd((result) => {
87
- conf.result.outputFiles = result.outputFiles;
88
- conf.result.metafile = result.metafile;
73
+ resultCache.outputFiles = result.outputFiles;
74
+ resultCache.metafile = result.metafile;
89
75
 
90
- conf.modifiedFileSet.clear();
76
+ modifiedFileSet.clear();
91
77
  });
92
78
  },
93
79
  };
@@ -16,8 +16,8 @@ import convertPrivateToHash from "./fix/convert-private-to-hash";
16
16
  import removeSdAngularSymbolNames from "./fix/remove-sd-angular-symbol-names";
17
17
  import convertSdAngularSymbolNames from "./fix/convert-sd-angular-symbol-names";
18
18
  import { removeUnusedInjects } from "./fix/remove-unused-injects";
19
- import { removeUnusedImports } from "./fix/remove-unused-imports";
20
19
  import removeUnusedProtectedReadonly from "./fix/remove-unused-protected-readonly";
20
+ import { removeUnusedImports } from "./fix/remove-unused-imports";
21
21
 
22
22
  Error.stackTraceLimit = Infinity;
23
23
  EventEmitter.defaultMaxListeners = 0;
@@ -3,7 +3,7 @@ import { SdDepCache } from "./SdDepCache";
3
3
  import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
4
4
  import path from "path";
5
5
  import { NgtscProgram } from "@angular/compiler-cli";
6
- import { ScopePathSet } from "../pkg-builders/commons/ScopePathSet";
6
+ import { ScopePathSet } from "./ScopePathSet";
7
7
 
8
8
  export class SdDepAnalyzer {
9
9
  static analyze(
@@ -2,8 +2,9 @@ import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
2
2
  import { ComponentStylesheetBundler } from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
3
3
  import { transformSupportedBrowsersToTargets } from "@angular/build/src/tools/esbuild/utils";
4
4
  import browserslist from "browserslist";
5
- import { ScopePathSet } from "../pkg-builders/commons/ScopePathSet";
6
5
  import { TStylesheetBundlingResult } from "../types/build/TStylesheetBundlingResult";
6
+ import { ScopePathSet } from "./ScopePathSet";
7
+ import path from "path";
7
8
 
8
9
  export class SdStyleBundler {
9
10
  #ngStyleBundler: ComponentStylesheetBundler;
@@ -12,30 +13,40 @@ export class SdStyleBundler {
12
13
  #revRefCache = new Map<TNormPath, Set<TNormPath>>();
13
14
 
14
15
  constructor(
15
- private readonly _pkgPath: TNormPath,
16
- private readonly _isDevMode: boolean,
17
- private readonly _scopePathSet: ScopePathSet,
16
+ private readonly _opt: {
17
+ pkgPath: TNormPath;
18
+ scopePathSet: ScopePathSet;
19
+ dev: boolean;
20
+ },
18
21
  ) {
19
22
  this.#ngStyleBundler = new ComponentStylesheetBundler(
20
23
  {
21
- workspaceRoot: this._pkgPath,
22
- optimization: !this._isDevMode,
23
- inlineFonts: true,
24
- preserveSymlinks: false,
25
- sourcemap: this._isDevMode ? "inline" : false,
26
- outputNames: { bundles: "[name]", media: "media/[name]" },
24
+ workspaceRoot: this._opt.pkgPath,
25
+ inlineFonts: !this._opt.dev,
26
+ optimization: !this._opt.dev,
27
+ sourcemap: this._opt.dev ? "linked" : false,
28
+ sourcesContent: this._opt.dev,
29
+ outputNames: { bundles: "[name]-[hash]", media: "media/[name]-[hash]" },
27
30
  includePaths: [],
31
+ sass: {
32
+ fatalDeprecations: undefined,
33
+ silenceDeprecations: undefined,
34
+ futureDeprecations: undefined,
35
+ },
28
36
  externalDependencies: [],
29
37
  target: transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"])),
38
+ preserveSymlinks: false,
30
39
  tailwindConfiguration: undefined,
40
+ postcssConfiguration: undefined,
31
41
  cacheOptions: {
32
42
  enabled: true,
33
- path: ".cache/angular",
34
- basePath: ".cache",
43
+ basePath: path.resolve(this._opt.pkgPath, ".cache"),
44
+ path: path.resolve(this._opt.pkgPath, ".cache/angular"),
35
45
  },
46
+ publicPath: undefined,
36
47
  },
37
48
  "scss",
38
- this._isDevMode,
49
+ this._opt.dev,
39
50
  );
40
51
  }
41
52
 
@@ -68,8 +79,8 @@ export class SdStyleBundler {
68
79
 
69
80
  for (const referencedFile of result.referencedFiles ?? []) {
70
81
  if (
71
- !this._scopePathSet.inScope(fileNPath) ||
72
- !this._scopePathSet.inScope(PathUtils.norm(referencedFile))
82
+ !this._opt.scopePathSet.inScope(fileNPath) ||
83
+ !this._opt.scopePathSet.inScope(PathUtils.norm(referencedFile))
73
84
  )
74
85
  continue;
75
86
 
@@ -127,10 +138,18 @@ export class SdStyleBundler {
127
138
  }
128
139
 
129
140
  #addReference(fileNPath: TNormPath, referencedFile: TNormPath) {
141
+ if (fileNPath === referencedFile) return;
130
142
  this.#refCache.getOrCreate(fileNPath, new Set()).add(referencedFile);
131
143
  this.#revRefCache.getOrCreate(referencedFile, new Set()).add(fileNPath);
132
144
  }
133
145
 
146
+ getAllStyleFileSet() {
147
+ return new Set([
148
+ ...this.#revRefCache.keys(),
149
+ ...Array.from(this.#revRefCache.values()).mapMany((item) => Array.from(item)),
150
+ ]);
151
+ }
152
+
134
153
  getAffectedFileSet(modifiedNPathSet: Set<TNormPath>) {
135
154
  const affectedFileSet = new Set<TNormPath>();
136
155
  // 수정파일중 Result에 있는것