@simplysm/sd-cli 12.5.23 → 12.5.24

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 (64) hide show
  1. package/dist/entry/SdCliElectron.js +2 -2
  2. package/dist/entry/SdCliElectron.js.map +1 -1
  3. package/dist/entry/SdCliLocalUpdate.js +5 -7
  4. package/dist/entry/SdCliLocalUpdate.js.map +1 -1
  5. package/dist/entry/SdCliProject.js +4 -4
  6. package/dist/entry/SdCliProject.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/pkg-builders/SdMultiBuildRunner.d.ts +3 -10
  11. package/dist/pkg-builders/SdMultiBuildRunner.js +132 -116
  12. package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -1
  13. package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +6 -5
  14. package/dist/pkg-builders/client/SdClientBuildRunner.js +16 -8
  15. package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -1
  16. package/dist/pkg-builders/client/SdNgBundler.js +1 -0
  17. package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
  18. package/dist/pkg-builders/client/createSdNgPlugin.js +3 -3
  19. package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
  20. package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +6 -1
  21. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +25 -26
  22. package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -1
  23. package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +2 -3
  24. package/dist/pkg-builders/lib/SdTsLibBuilder.js +7 -11
  25. package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
  26. package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +5 -1
  27. package/dist/pkg-builders/server/SdServerBuildRunner.js +32 -29
  28. package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -1
  29. package/dist/pkg-builders/server/createSdServerPlugin.js +3 -3
  30. package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -1
  31. package/dist/ts-builder/SdTsCompiler.js +172 -160
  32. package/dist/ts-builder/SdTsCompiler.js.map +1 -1
  33. package/dist/types/build-runner.type.d.ts +7 -0
  34. package/dist/types/build-runner.type.js +2 -0
  35. package/dist/types/build-runner.type.js.map +1 -0
  36. package/dist/types/workers.type.d.ts +14 -0
  37. package/dist/workers/build-runner-worker.js +45 -0
  38. package/dist/workers/build-runner-worker.js.map +1 -0
  39. package/package.json +5 -5
  40. package/src/entry/SdCliElectron.ts +2 -2
  41. package/src/entry/SdCliLocalUpdate.ts +7 -7
  42. package/src/entry/SdCliProject.ts +4 -4
  43. package/src/index.ts +1 -1
  44. package/src/pkg-builders/SdMultiBuildRunner.ts +122 -120
  45. package/src/pkg-builders/client/SdClientBuildRunner.ts +26 -22
  46. package/src/pkg-builders/client/SdNgBundler.ts +1 -0
  47. package/src/pkg-builders/client/createSdNgPlugin.ts +3 -3
  48. package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +39 -26
  49. package/src/pkg-builders/lib/SdTsLibBuilder.ts +12 -13
  50. package/src/pkg-builders/server/SdServerBuildRunner.ts +44 -29
  51. package/src/pkg-builders/server/createSdServerPlugin.ts +3 -3
  52. package/src/ts-builder/SdTsCompiler.ts +220 -216
  53. package/src/types/build-runner.type.ts +8 -0
  54. package/src/types/workers.type.ts +13 -0
  55. package/src/workers/build-runner-worker.ts +52 -0
  56. package/tsconfig.json +1 -1
  57. package/dist/ts-builder/SdTsCompileWorker.d.ts +0 -9
  58. package/dist/ts-builder/SdTsCompileWorker.js +0 -16
  59. package/dist/ts-builder/SdTsCompileWorker.js.map +0 -1
  60. package/dist/workers/compile-worker.js +0 -27
  61. package/dist/workers/compile-worker.js.map +0 -1
  62. package/src/ts-builder/SdTsCompileWorker.ts +0 -21
  63. package/src/workers/compile-worker.ts +0 -31
  64. /package/dist/workers/{compile-worker.d.ts → build-runner-worker.d.ts} +0 -0
@@ -2,34 +2,33 @@ import path from "path";
2
2
  import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
3
3
  import { FsUtil, PathUtil, TNormPath } from "@simplysm/sd-core-node";
4
4
  import { ISdBuildMessage } from "../../types/build.type";
5
- import { SdTsCompileWorker } from "../../ts-builder/SdTsCompileWorker";
5
+ import { SdTsCompiler } from "../../ts-builder/SdTsCompiler";
6
6
 
7
7
  export class SdTsLibBuilder {
8
- static async new(pkgPath: TNormPath, dev: boolean, watchScopePaths: TNormPath[]) {
9
- const tsCompiler = await SdTsCompileWorker.new({
10
- pkgPath,
8
+ private _tsCompiler: SdTsCompiler;
9
+
10
+ constructor(
11
+ private _pkgPath: TNormPath,
12
+ dev: boolean,
13
+ watchScopePaths: TNormPath[],
14
+ ) {
15
+ this._tsCompiler = new SdTsCompiler({
16
+ pkgPath: this._pkgPath,
11
17
  additionalOptions: { declaration: true },
12
18
  isDevMode: dev,
13
- globalStyleFilePath: PathUtil.norm(pkgPath, "src/styles.scss"),
19
+ globalStyleFilePath: PathUtil.norm(this._pkgPath, "src/styles.scss"),
14
20
  isForBundle: false,
15
21
  watchScopePaths: watchScopePaths,
16
22
  });
17
-
18
- return new SdTsLibBuilder(tsCompiler, pkgPath);
19
23
  }
20
24
 
21
- private constructor(
22
- private _compiler: SdTsCompileWorker,
23
- private _pkgPath: string,
24
- ) {}
25
-
26
25
  public async buildAsync(modifiedFileSet: Set<TNormPath>): Promise<{
27
26
  watchFileSet: Set<TNormPath>;
28
27
  affectedFileSet: Set<TNormPath>;
29
28
  results: ISdBuildMessage[];
30
29
  emitFileSet: Set<TNormPath>;
31
30
  }> {
32
- const tsCompileResult = await this._compiler.compileAsync(modifiedFileSet);
31
+ const tsCompileResult = await this._tsCompiler.compileAsync(modifiedFileSet);
33
32
 
34
33
  const emitFileSet = new Set<TNormPath>();
35
34
  for (const emitFile of tsCompileResult.emitFileSet) {
@@ -8,17 +8,25 @@ import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.type";
8
8
  import { INpmConfig, ITsConfig } from "../../types/common-configs.type";
9
9
 
10
10
  export class SdServerBuildRunner extends EventEmitter {
11
- #logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuildRunner"]);
12
- #pkgConf: ISdServerPackageConfig;
13
- #serverBundler?: SdServerBundler;
14
- #extModules?: { name: string; exists: boolean }[];
11
+ private _logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuildRunner"]);
12
+ private _pkgConf: ISdServerPackageConfig;
13
+ private _serverBundler?: SdServerBundler;
14
+ private _extModules?: { name: string; exists: boolean }[];
15
+ private _watchScopePathSet: Set<TNormPath>;
15
16
 
16
17
  public constructor(
17
18
  private readonly _projConf: ISdProjectConfig,
18
19
  private readonly _pkgPath: TNormPath,
19
20
  ) {
20
21
  super();
21
- this.#pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdServerPackageConfig;
22
+ this._pkgConf = this._projConf.packages[path.basename(_pkgPath)] as ISdServerPackageConfig;
23
+
24
+ const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
25
+ FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
26
+ );
27
+ this._watchScopePathSet = new Set(
28
+ [path.resolve(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtil.norm(item)),
29
+ );
22
30
  }
23
31
 
24
32
  public override on(event: "change", listener: () => void): this;
@@ -36,7 +44,7 @@ export class SdServerBuildRunner extends EventEmitter {
36
44
 
37
45
  this._debug("GEN .config...");
38
46
  const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
39
- FsUtil.writeFile(confDistPath, JSON.stringify(this.#pkgConf.configs ?? {}, undefined, 2));
47
+ FsUtil.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
40
48
 
41
49
  const result = await this._runAsync(true);
42
50
  const res: ISdBuildRunnerResult = {
@@ -47,10 +55,17 @@ export class SdServerBuildRunner extends EventEmitter {
47
55
  this.emit("complete", res);
48
56
 
49
57
  this._debug("WATCH...");
50
- const watcher = SdFsWatcher.watch(Array.from(result.watchFileSet)).onChange({ delay: 100 }, async (changeInfos) => {
58
+ let lastWatchFileSet = result.watchFileSet;
59
+ SdFsWatcher.watch(Array.from(this._watchScopePathSet)).onChange({ delay: 100 }, async (changeInfos) => {
60
+ const currentChangeInfos = changeInfos.filter((item) => lastWatchFileSet.has(item.path));
61
+ if (currentChangeInfos.length < 1) return;
62
+
51
63
  this.emit("change");
52
64
 
53
- const watchResult = await this._runAsync(true, new Set(changeInfos.map((item) => PathUtil.norm(item.path))));
65
+ const watchResult = await this._runAsync(
66
+ true,
67
+ new Set(currentChangeInfos.map((item) => PathUtil.norm(item.path))),
68
+ );
54
69
  const watchRes: ISdBuildRunnerResult = {
55
70
  affectedFilePathSet: watchResult.affectedFileSet,
56
71
  buildMessages: watchResult.buildMessages,
@@ -59,7 +74,7 @@ export class SdServerBuildRunner extends EventEmitter {
59
74
 
60
75
  this.emit("complete", watchRes);
61
76
 
62
- watcher.replaceWatchPaths(watchResult.watchFileSet);
77
+ lastWatchFileSet = watchResult.watchFileSet;
63
78
  });
64
79
  }
65
80
 
@@ -72,7 +87,7 @@ export class SdServerBuildRunner extends EventEmitter {
72
87
 
73
88
  this._debug("GEN .config.json...");
74
89
  const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
75
- FsUtil.writeJson(confDistPath, this.#pkgConf.configs ?? {}, { space: 2 });
90
+ FsUtil.writeJson(confDistPath, this._pkgConf.configs ?? {}, { space: 2 });
76
91
 
77
92
  this._debug("GEN package.json...");
78
93
  {
@@ -87,7 +102,7 @@ export class SdServerBuildRunner extends EventEmitter {
87
102
  delete distNpmConfig.devDependencies;
88
103
  delete distNpmConfig.peerDependencies;
89
104
 
90
- if (this.#pkgConf.pm2 && !this.#pkgConf.pm2.noStartScript) {
105
+ if (this._pkgConf.pm2 && !this._pkgConf.pm2.noStartScript) {
91
106
  distNpmConfig.scripts = { start: "pm2 start pm2.json" };
92
107
  }
93
108
 
@@ -123,18 +138,18 @@ Options = UnsafeLegacyRenegotiation`.trim(),
123
138
  );
124
139
  }
125
140
 
126
- if (this.#pkgConf.pm2) {
141
+ if (this._pkgConf.pm2) {
127
142
  this._debug("GEN pm2.json...");
128
143
 
129
144
  FsUtil.writeJson(
130
145
  path.resolve(this._pkgPath, "dist/pm2.json"),
131
146
  {
132
- name: this.#pkgConf.pm2.name ?? npmConfig.name.replace(/@/g, "").replace(/\//g, "-"),
147
+ name: this._pkgConf.pm2.name ?? npmConfig.name.replace(/@/g, "").replace(/\//g, "-"),
133
148
  script: "main.js",
134
149
  watch: true,
135
150
  watch_delay: 2000,
136
- ignore_watch: ["node_modules", "www", ...(this.#pkgConf.pm2.ignoreWatchPaths ?? [])],
137
- ...(this.#pkgConf.pm2.noInterpreter
151
+ ignore_watch: ["node_modules", "www", ...(this._pkgConf.pm2.ignoreWatchPaths ?? [])],
152
+ ...(this._pkgConf.pm2.noInterpreter
138
153
  ? {}
139
154
  : {
140
155
  interpreter: "node@" + process.versions.node,
@@ -144,7 +159,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
144
159
  NODE_ENV: "production",
145
160
  TZ: "Asia/Seoul",
146
161
  SD_VERSION: npmConfig.version,
147
- ...this.#pkgConf.env,
162
+ ...this._pkgConf.env,
148
163
  },
149
164
  arrayProcess: "concat",
150
165
  useDelTargetNull: true,
@@ -155,11 +170,11 @@ Options = UnsafeLegacyRenegotiation`.trim(),
155
170
  );
156
171
  }
157
172
 
158
- if (this.#pkgConf.iis) {
173
+ if (this._pkgConf.iis) {
159
174
  this._debug("GEN web.config...");
160
175
 
161
176
  const iisDistPath = path.resolve(this._pkgPath, "dist/web.config");
162
- const serverExeFilePath = this.#pkgConf.iis.nodeExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe";
177
+ const serverExeFilePath = this._pkgConf.iis.nodeExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe";
163
178
  FsUtil.writeFile(
164
179
  iisDistPath,
165
180
  `
@@ -168,8 +183,8 @@ Options = UnsafeLegacyRenegotiation`.trim(),
168
183
  <add key="NODE_ENV" value="production" />
169
184
  <add key="TZ" value="Asia/Seoul" />
170
185
  <add key="SD_VERSION" value="${npmConfig.version}" />
171
- ${Object.keys(this.#pkgConf.env ?? {})
172
- .map((key) => `<add key="${key}" value="${this.#pkgConf.env![key]}"/>`)
186
+ ${Object.keys(this._pkgConf.env ?? {})
187
+ .map((key) => `<add key="${key}" value="${this._pkgConf.env![key]}"/>`)
173
188
  .join("\n ")}
174
189
  </appSettings>
175
190
  <system.webServer>
@@ -218,21 +233,21 @@ Options = UnsafeLegacyRenegotiation`.trim(),
218
233
 
219
234
  this._debug(`BUILD 준비...`);
220
235
  const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
221
- this.#extModules = this.#extModules ?? (await this._getExternalModulesAsync());
222
- this.#serverBundler =
223
- this.#serverBundler ??
236
+ this._extModules = this._extModules ?? (await this._getExternalModulesAsync());
237
+ this._serverBundler =
238
+ this._serverBundler ??
224
239
  new SdServerBundler({
225
240
  dev,
226
241
  pkgPath: this._pkgPath,
227
242
  entryPoints: tsConfig.files
228
243
  ? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
229
244
  : [path.resolve(this._pkgPath, "src/main.ts")],
230
- external: this.#extModules.map((item) => item.name),
245
+ external: this._extModules.map((item) => item.name),
231
246
  watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths].map((item) => PathUtil.norm(item)),
232
247
  });
233
248
 
234
249
  this._debug(`BUILD...`);
235
- const bundleResult = await this.#serverBundler.bundleAsync(modifiedFileSet);
250
+ const bundleResult = await this._serverBundler.bundleAsync(modifiedFileSet);
236
251
 
237
252
  //-- filePaths
238
253
  const watchFileSet = new Set(
@@ -304,7 +319,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
304
319
  });
305
320
  }
306
321
 
307
- if (this.#pkgConf.externals?.includes(moduleName)) {
322
+ if (this._pkgConf.externals?.includes(moduleName)) {
308
323
  results.push({
309
324
  name: moduleName,
310
325
  exists: true,
@@ -338,7 +353,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
338
353
  });
339
354
  }
340
355
 
341
- if (this.#pkgConf.externals?.includes(optModuleName)) {
356
+ if (this._pkgConf.externals?.includes(optModuleName)) {
342
357
  results.push({
343
358
  name: optModuleName,
344
359
  exists: true,
@@ -351,7 +366,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
351
366
 
352
367
  await fn(this._pkgPath);
353
368
 
354
- for (const external of this.#pkgConf.externals ?? []) {
369
+ for (const external of this._pkgConf.externals ?? []) {
355
370
  if (!results.some((item) => item.name === external)) {
356
371
  results.push({
357
372
  name: external,
@@ -364,6 +379,6 @@ Options = UnsafeLegacyRenegotiation`.trim(),
364
379
  }
365
380
 
366
381
  private _debug(msg: string): void {
367
- this.#logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
382
+ this._logger.debug(`[${path.basename(this._pkgPath)}] ${msg}`);
368
383
  }
369
384
  }
@@ -2,8 +2,8 @@ import esbuild from "esbuild";
2
2
  import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
3
3
  import { ISdCliServerPluginResultCache } from "../../types/build-plugin.type";
4
4
  import { PathUtil, TNormPath } from "@simplysm/sd-core-node";
5
- import { SdTsCompileWorker } from "../../ts-builder/SdTsCompileWorker";
6
5
  import { ISdTsCompilerResult } from "../../types/ts-compiler.type";
6
+ import { SdTsCompiler } from "../../ts-builder/SdTsCompiler";
7
7
 
8
8
  export function createSdServerPlugin(conf: {
9
9
  pkgPath: TNormPath;
@@ -14,8 +14,8 @@ export function createSdServerPlugin(conf: {
14
14
  }): esbuild.Plugin {
15
15
  return {
16
16
  name: "sd-server-compile",
17
- setup: async (build: esbuild.PluginBuild) => {
18
- const tsCompiler = await SdTsCompileWorker.new({
17
+ setup: (build: esbuild.PluginBuild) => {
18
+ const tsCompiler = new SdTsCompiler({
19
19
  pkgPath: conf.pkgPath,
20
20
  additionalOptions: { declaration: false },
21
21
  isDevMode: conf.dev,