@simplysm/sd-cli 11.1.45 → 11.1.51

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 (53) hide show
  1. package/dist/build-cluster.js +16 -3
  2. package/dist/build-cluster.js.map +1 -1
  3. package/dist/build-tools/SdLibBundler.d.ts +13 -0
  4. package/dist/build-tools/SdLibBundler.js +51 -0
  5. package/dist/build-tools/SdLibBundler.js.map +1 -0
  6. package/dist/build-tools/SdLinter.js +4 -4
  7. package/dist/build-tools/SdLinter.js.map +1 -1
  8. package/dist/build-tools/SdNgBundler.d.ts +11 -20
  9. package/dist/build-tools/SdNgBundler.js +103 -96
  10. package/dist/build-tools/SdNgBundler.js.map +1 -1
  11. package/dist/build-tools/SdServerBundler.js.map +1 -1
  12. package/dist/build-tools/SdTsCompiler.d.ts +24 -27
  13. package/dist/build-tools/SdTsCompiler.js +237 -184
  14. package/dist/build-tools/SdTsCompiler.js.map +1 -1
  15. package/dist/builders/SdCliTsLibBuilder.d.ts +2 -6
  16. package/dist/builders/SdCliTsLibBuilder.js +30 -30
  17. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  18. package/dist/bundle-plugins/sdNgPlugin.d.ts +3 -3
  19. package/dist/bundle-plugins/sdNgPlugin.js +22 -212
  20. package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
  21. package/dist/bundle-plugins/sdServerPlugin.d.ts +2 -2
  22. package/dist/bundle-plugins/sdServerPlugin.js +17 -110
  23. package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
  24. package/dist/commons.d.ts +1 -0
  25. package/dist/entry/SdCliProject.d.ts +1 -0
  26. package/dist/entry/SdCliProject.js +14 -30
  27. package/dist/entry/SdCliProject.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/sd-cli.d.ts +1 -1
  32. package/dist/sd-cli.js +8 -2
  33. package/dist/sd-cli.js.map +1 -1
  34. package/dist/server-worker.js.map +1 -1
  35. package/dist/utils/SdCliBuildResultUtil.d.ts +10 -0
  36. package/dist/utils/SdCliBuildResultUtil.js +17 -1
  37. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  38. package/package.json +15 -15
  39. package/src/build-cluster.ts +18 -4
  40. package/src/build-tools/SdLibBundler.ts +70 -0
  41. package/src/build-tools/SdLinter.ts +4 -4
  42. package/src/build-tools/SdNgBundler.ts +120 -112
  43. package/src/build-tools/SdServerBundler.ts +2 -2
  44. package/src/build-tools/SdTsCompiler.ts +352 -241
  45. package/src/builders/SdCliTsLibBuilder.ts +33 -31
  46. package/src/bundle-plugins/sdNgPlugin.ts +26 -320
  47. package/src/bundle-plugins/sdServerPlugin.ts +20 -168
  48. package/src/commons.ts +1 -0
  49. package/src/entry/SdCliProject.ts +15 -31
  50. package/src/index.ts +1 -0
  51. package/src/sd-cli.ts +8 -2
  52. package/src/server-worker.ts +3 -3
  53. package/src/utils/SdCliBuildResultUtil.ts +22 -3
@@ -39,9 +39,10 @@ if (cluster.isPrimary) {
39
39
  sendMessage(message);
40
40
  });
41
41
 
42
- process.on("message", (message) => {
42
+ process.on("message", (message: ISdCliBuildClusterReqMessage) => {
43
43
  cluster.fork({
44
- "SD_CLUSTER_MESSAGE": JSON.stringify(message)
44
+ "SD_CLUSTER_MESSAGE": JSON.stringify(message),
45
+ "NODE_OPTIONS": message.execArgs?.join(" ")
45
46
  });
46
47
  });
47
48
  process.send!("ready");
@@ -67,6 +68,7 @@ else {
67
68
  result,
68
69
  req: message
69
70
  });
71
+ logMemory(message);
70
72
  })
71
73
  .watchAsync();
72
74
 
@@ -90,6 +92,7 @@ else {
90
92
  result,
91
93
  req: message
92
94
  });
95
+ logMemory(message);
93
96
  })
94
97
  .watchAsync();
95
98
  sendMessage({
@@ -112,6 +115,7 @@ else {
112
115
  result,
113
116
  req: message
114
117
  });
118
+ logMemory(message);
115
119
  })
116
120
  .watchAsync();
117
121
  sendMessage({
@@ -134,6 +138,7 @@ else {
134
138
  result,
135
139
  req: message
136
140
  });
141
+ logMemory(message);
137
142
  })
138
143
  .watchAsync();
139
144
  sendMessage({
@@ -154,6 +159,7 @@ else {
154
159
  result,
155
160
  req: message
156
161
  });
162
+ logMemory(message);
157
163
  }
158
164
  // [library] typescript
159
165
  else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
@@ -163,6 +169,7 @@ else {
163
169
  result,
164
170
  req: message
165
171
  });
172
+ logMemory(message);
166
173
  }
167
174
  // [server]
168
175
  else if (pkgConf.type === "server") {
@@ -170,8 +177,9 @@ else {
170
177
  sendMessage({
171
178
  type: "complete",
172
179
  result,
173
- req: message
180
+ req: message,
174
181
  });
182
+ logMemory(message);
175
183
  }
176
184
  // [client]
177
185
  else if (pkgConf.type === "client") {
@@ -179,8 +187,9 @@ else {
179
187
  sendMessage({
180
188
  type: "complete",
181
189
  result,
182
- req: message
190
+ req: message,
183
191
  });
192
+ logMemory(message);
184
193
  }
185
194
  else {
186
195
  throw new NeverEntryError();
@@ -196,3 +205,8 @@ else {
196
205
  function sendMessage(message: ISdCliBuildClusterResMessage): void {
197
206
  process.send!(message);
198
207
  }
208
+
209
+ function logMemory(message: ISdCliBuildClusterReqMessage) {
210
+ /*global.gc!();
211
+ logger.log(`[${process.pid}:${path.basename(message.pkgPath)}] 메모리 사용량: ${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`);*/
212
+ }
@@ -0,0 +1,70 @@
1
+ import {SdCliBuildResultUtil} from "../utils/SdCliBuildResultUtil";
2
+ import {ISdCliPackageBuildResult} from "../commons";
3
+ import {SdTsCompiler} from "./SdTsCompiler";
4
+ import ts from "typescript";
5
+ import path from "path";
6
+ import {FsUtil, PathUtil} from "@simplysm/sd-core-node";
7
+
8
+ export class SdLibBundler {
9
+ readonly #compiler: SdTsCompiler;
10
+
11
+ readonly #pkgPath: string;
12
+
13
+ public constructor(pkgPath: string, dev: boolean) {
14
+ this.#pkgPath = pkgPath;
15
+ this.#compiler = new SdTsCompiler(
16
+ pkgPath,
17
+ {declaration: true},
18
+ dev,
19
+ path.resolve(pkgPath, "src/styles.scss")
20
+ );
21
+ }
22
+
23
+ public markChanges(modifiedFileSet: Set<string>): void {
24
+ this.#compiler.invalidate(modifiedFileSet);
25
+ }
26
+
27
+ public async buildAsync(): Promise<{
28
+ program: ts.Program;
29
+ watchFileSet: Set<string>;
30
+ affectedFileSet: Set<string>;
31
+ results: ISdCliPackageBuildResult[];
32
+ }> {
33
+ const buildResult = await this.#compiler.buildAsync();
34
+
35
+ for (const affectedFilePath of buildResult.affectedFileSet) {
36
+ const emittedFiles = buildResult.emittedFilesCacheMap.get(affectedFilePath) ?? [];
37
+ for (const emittedFile of emittedFiles) {
38
+ if (emittedFile.outRelPath != null) {
39
+ const distPath = path.resolve(this.#pkgPath, "dist", emittedFile.outRelPath);
40
+ if (PathUtil.isChildPath(distPath, path.resolve(this.#pkgPath, "dist"))) {
41
+ await FsUtil.writeFileAsync(distPath, emittedFile.text);
42
+ }
43
+ }
44
+ }
45
+
46
+ const globalStylesheetResult = buildResult.stylesheetResultMap.get(affectedFilePath);
47
+ if (globalStylesheetResult) {
48
+ for (const outputFile of globalStylesheetResult.outputFiles) {
49
+ const distPath = path.resolve(this.#pkgPath, "dist", path.relative(this.#pkgPath, outputFile.path));
50
+ if (PathUtil.isChildPath(distPath, path.resolve(this.#pkgPath, "dist"))) {
51
+ await FsUtil.writeFileAsync(distPath, outputFile.text);
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ return {
58
+ program: buildResult.program,
59
+ watchFileSet: buildResult.watchFileSet,
60
+ affectedFileSet: buildResult.affectedFileSet,
61
+ results: [
62
+ ...buildResult.typescriptDiagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, "build")),
63
+ ...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.errors ?? [])
64
+ .map(err => SdCliBuildResultUtil.convertFromEsbuildResult(err, "build", "error")),
65
+ /*...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.warnings!)
66
+ .map(warn => SdCliBuildResultUtil.convertFromEsbuildResult(warn, "build", "warning"))*/
67
+ ]
68
+ };
69
+ }
70
+ }
@@ -4,18 +4,18 @@ import ts from "typescript";
4
4
 
5
5
  export abstract class SdLinter {
6
6
  static async lintAsync(fileSet: Iterable<string>, tsProgram: ts.Program | undefined): Promise<ISdCliPackageBuildResult[]> {
7
- const sourceFilePaths = Array.from(fileSet).filter((item) =>
7
+ const lintFilePaths = Array.from(fileSet).filter((item) =>
8
8
  (!item.endsWith(".d.ts") && item.endsWith(".ts")) ||
9
9
  item.endsWith(".js") ||
10
10
  item.endsWith(".cjs") ||
11
11
  item.endsWith(".mjs")
12
12
  );
13
13
 
14
- if (sourceFilePaths.length === 0) {
14
+ if (lintFilePaths.length === 0) {
15
15
  return [];
16
16
  }
17
17
 
18
- const linter = new ESLint(tsProgram !== null ? {
18
+ const linter = new ESLint(tsProgram != null ? {
19
19
  cache: false,
20
20
  overrideConfig: {
21
21
  overrides: [
@@ -40,7 +40,7 @@ export abstract class SdLinter {
40
40
  } : undefined);
41
41
 
42
42
 
43
- const lintResults = await linter.lintFiles(sourceFilePaths);
43
+ const lintResults = await linter.lintFiles(lintFilePaths);
44
44
 
45
45
  return lintResults.mapMany((lintResult) => lintResult.messages.map((msg) => ({
46
46
  filePath: lintResult.filePath,