@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
@@ -1,12 +1,13 @@
1
- import { FsUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
1
+ import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
- import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
3
+ import { SdBuildRunnerBase } from "../SdBuildRunnerBase";
4
4
  import { SdNgBundler } from "./SdNgBundler";
5
5
  import { SdCliCordova } from "../../entry/SdCliCordova";
6
6
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
7
7
  import { INpmConfig } from "../../types/common-config/INpmConfig";
8
8
  import { SdCliNgRoutesFileGenerator } from "./SdCliNgRoutesFileGenerator";
9
9
  import { SdCliElectron } from "../../entry/SdCliElectron";
10
+ import { ISdClientPackageConfig } from "../../types/config/ISdProjectConfig";
10
11
 
11
12
  export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
12
13
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdClientBuildRunner"]);
@@ -17,28 +18,30 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
17
18
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
18
19
  // 최초 한번
19
20
  if (!modifiedFileSet) {
20
- if (!this._noEmit) {
21
+ if (!this._opt.watch?.noEmit) {
21
22
  // config
22
23
  this._debug("GEN .config...");
23
- const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
24
+ const confDistPath = path.resolve(this._opt.pkgPath, "dist/.config.json");
24
25
  FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
25
26
 
26
27
  // cordova
27
28
  if (this._pkgConf.builder?.cordova) {
28
29
  this._debug("CORDOVA 준비...");
29
30
  this.#cordova = new SdCliCordova({
30
- pkgPath: this._pkgPath,
31
+ pkgPath: this._opt.pkgPath,
31
32
  config: this._pkgConf.builder.cordova,
32
33
  });
33
34
  await this.#cordova.initializeAsync();
34
35
  }
35
36
 
36
37
  // routes
37
- const npmConf = FsUtils.readJson(path.resolve(this._pkgPath, "package.json")) as INpmConfig;
38
+ const npmConf = FsUtils.readJson(
39
+ path.resolve(this._opt.pkgPath, "package.json"),
40
+ ) as INpmConfig;
38
41
  if ("@angular/router" in (npmConf.dependencies ?? {})) {
39
42
  this._debug(`GEN routes.ts...`);
40
43
  await new SdCliNgRoutesFileGenerator().watchAsync(
41
- this._pkgPath,
44
+ this._opt.pkgPath,
42
45
  this._pkgConf.noLazyRoute,
43
46
  );
44
47
  }
@@ -47,40 +50,16 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
47
50
  // ng
48
51
  this._debug(`BUILD 준비...`);
49
52
 
50
- const ngBundlerBuilderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as (
51
- | "web"
52
- | "electron"
53
- | "cordova"
54
- )[];
55
-
56
- this.#ngBundlers = ngBundlerBuilderTypes.map(
57
- (ngBundlerBuilderType) =>
58
- new SdNgBundler({
59
- watch: this._watch,
60
- dev: this._dev,
61
- emitOnly: this._emitOnly ?? false,
62
- noEmit: this._noEmit ?? false,
63
- builderType: ngBundlerBuilderType,
64
- pkgPath: this._pkgPath,
65
- outputPath:
66
- ngBundlerBuilderType === "web"
67
- ? PathUtils.norm(this._pkgPath, "dist")
68
- : ngBundlerBuilderType === "electron" && !this._dev
69
- ? PathUtils.norm(this._pkgPath, ".electron/src")
70
- : ngBundlerBuilderType === "cordova" && !this._dev
71
- ? PathUtils.norm(this._pkgPath, ".cordova/www")
72
- : PathUtils.norm(this._pkgPath, "dist", ngBundlerBuilderType),
73
- env: {
74
- ...this._pkgConf.env,
75
- ...this._pkgConf.builder?.[ngBundlerBuilderType]?.env,
76
- },
77
- external:
78
- ngBundlerBuilderType === "electron"
79
- ? (this._pkgConf.builder?.electron?.reinstallDependencies ?? [])
80
- : [],
81
- cordovaConfig:
82
- ngBundlerBuilderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
83
- scopePathSet: this._scopePathSet,
53
+ const builderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as (keyof NonNullable<
54
+ ISdClientPackageConfig["builder"]
55
+ >)[];
56
+
57
+ this.#ngBundlers = builderTypes.map(
58
+ (builderType) =>
59
+ new SdNgBundler(this._opt, {
60
+ builderType: builderType,
61
+ builderConfig: this._pkgConf.builder?.[builderType],
62
+ env: this._pkgConf.env,
84
63
  }),
85
64
  );
86
65
  }
@@ -91,7 +70,7 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
91
70
  }
92
71
  }
93
72
 
94
- if (this._noEmit) {
73
+ if (this._opt.watch?.noEmit) {
95
74
  this._debug(`BUILD...`);
96
75
  const buildResults = await Promise.all(
97
76
  this.#ngBundlers!.map((builder) => builder.bundleAsync()),
@@ -124,15 +103,15 @@ export class SdClientBuildRunner extends SdBuildRunnerBase<"client"> {
124
103
  const emitFileSet = new Set(buildResults.mapMany((item) => Array.from(item.emitFileSet)));
125
104
  const buildMessages = buildResults.mapMany((item) => item.buildMessages).distinct();
126
105
 
127
- if (!this._dev && this.#cordova) {
106
+ if (!this._opt.watch?.dev && this.#cordova) {
128
107
  this._debug("CORDOVA BUILD...");
129
- await this.#cordova.buildAsync(path.resolve(this._pkgPath, "dist"));
108
+ await this.#cordova.buildAsync(path.resolve(this._opt.pkgPath, "dist"));
130
109
  }
131
110
 
132
- if (!this._dev && this._pkgConf.builder?.electron) {
111
+ if (!this._opt.watch?.dev && this._pkgConf.builder?.electron) {
133
112
  this._debug("ELECTRON BUILD...");
134
113
  await SdCliElectron.buildAsync({
135
- pkgPath: this._pkgPath,
114
+ pkgPath: this._opt.pkgPath,
136
115
  electronConfig: this._pkgConf.builder.electron,
137
116
  });
138
117
  }
@@ -34,12 +34,12 @@ import { createCssResourcePlugin } from "@angular/build/src/tools/esbuild/styles
34
34
  import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
35
35
  import { createSdNgPlugin } from "./createSdNgPlugin";
36
36
  import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTimer";
37
- import { ISdClientBuilderCordovaConfig } from "../../types/config/ISdProjectConfig";
37
+ import { ISdClientPackageConfig } from "../../types/config/ISdProjectConfig";
38
38
  import nodeModule from "module";
39
- import { ScopePathSet } from "../commons/ScopePathSet";
40
39
  import { ISdCliNgPluginResultCache } from "../../types/plugin/ISdCliNgPluginResultCache";
41
40
  import { INpmConfig } from "../../types/common-config/INpmConfig";
42
41
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
42
+ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
43
43
 
44
44
  export class SdNgBundler {
45
45
  #logger = SdLogger.get(["simplysm", "sd-cli", "SdNgBundler"]);
@@ -63,21 +63,11 @@ export class SdNgBundler {
63
63
  #indexHtmlFilePath: string;
64
64
  #pkgName: string;
65
65
  #baseHref: string;
66
+ #outputPath: string;
66
67
 
67
68
  constructor(
68
- private readonly _opt: {
69
- watch: boolean;
70
- dev: boolean;
71
- emitOnly: boolean;
72
- noEmit: boolean;
73
- outputPath: TNormPath;
74
- pkgPath: TNormPath;
75
- builderType: string;
76
- env: Record<string, string> | undefined;
77
- external: string[];
78
- cordovaConfig: ISdClientBuilderCordovaConfig | undefined;
79
- scopePathSet: ScopePathSet;
80
- },
69
+ private readonly _opt: ISdTsCompilerOptions,
70
+ private readonly _conf: IConf<any>,
81
71
  ) {
82
72
  this.#pkgNpmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json"));
83
73
  this.#mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
@@ -87,11 +77,19 @@ export class SdNgBundler {
87
77
  this.#indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
88
78
  this.#pkgName = path.basename(this._opt.pkgPath);
89
79
  this.#baseHref =
90
- this._opt.builderType === "web"
80
+ this._conf.builderType === "web"
91
81
  ? `/${this.#pkgName}/`
92
- : this._opt.dev
93
- ? `/${this.#pkgName}/${this._opt.builderType}/`
82
+ : this._opt.watch?.dev
83
+ ? `/${this.#pkgName}/${this._conf.builderType}/`
94
84
  : ``;
85
+ this.#outputPath =
86
+ this._conf.builderType === "web"
87
+ ? PathUtils.norm(this._opt.pkgPath, "dist")
88
+ : this._conf.builderType === "electron" && !this._opt.watch?.dev
89
+ ? PathUtils.norm(this._opt.pkgPath, ".electron/src")
90
+ : this._conf.builderType === "cordova" && !this._opt.watch?.dev
91
+ ? PathUtils.norm(this._opt.pkgPath, ".cordova/www")
92
+ : PathUtils.norm(this._opt.pkgPath, "dist", this._conf.builderType);
95
93
  }
96
94
 
97
95
  markForChanges(filePaths: string[]): void {
@@ -113,7 +111,7 @@ export class SdNgBundler {
113
111
  ...(FsUtils.exists(path.resolve(this._opt.pkgPath, "src/styles.scss"))
114
112
  ? [this.#getStyleContext()]
115
113
  : []),
116
- ...(this._opt.builderType === "electron" ? [this.#getElectronMainContext()] : []),
114
+ ...(this._conf.builderType === "electron" ? [this.#getElectronMainContext()] : []),
117
115
  ]);
118
116
  }
119
117
 
@@ -126,7 +124,7 @@ export class SdNgBundler {
126
124
  //-- results
127
125
  const buildMessages = bundlingResults.mapMany((bundlingResult) => bundlingResult.results);
128
126
 
129
- if (this._opt.noEmit) {
127
+ if (this._opt.watch?.noEmit) {
130
128
  return {
131
129
  watchFileSet: this.#ngResultCache.watchFileSet!,
132
130
  affectedFileSet: this.#ngResultCache.affectedFileSet!,
@@ -195,7 +193,7 @@ export class SdNgBundler {
195
193
  assetFiles.push(...(await this.#copyAssetsAsync()));
196
194
 
197
195
  //-- extract 3rdpartylicenses
198
- if (!this._opt.dev) {
196
+ if (!this._opt.watch?.dev) {
199
197
  outputFiles.push(
200
198
  createOutputFile(
201
199
  "3rdpartylicenses.txt",
@@ -237,7 +235,7 @@ export class SdNgBundler {
237
235
  const emitFileSet = new Set<TNormPath>();
238
236
  perf.run("write output file", () => {
239
237
  for (const outputFile of outputFiles) {
240
- const distFilePath = PathUtils.norm(this._opt.outputPath, outputFile.path);
238
+ const distFilePath = PathUtils.norm(this.#outputPath, outputFile.path);
241
239
  const prevHash = this.#outputHashCache.get(distFilePath);
242
240
  const currHash = HashUtils.get(Buffer.from(outputFile.contents));
243
241
  if (prevHash !== currHash) {
@@ -250,12 +248,9 @@ export class SdNgBundler {
250
248
  const prevHash = this.#outputHashCache.get(PathUtils.norm(assetFile.source));
251
249
  const currHash = HashUtils.get(FsUtils.readFileBuffer(assetFile.source));
252
250
  if (prevHash !== currHash) {
253
- FsUtils.copy(
254
- assetFile.source,
255
- path.resolve(this._opt.outputPath, assetFile.destination),
256
- );
251
+ FsUtils.copy(assetFile.source, path.resolve(this.#outputPath, assetFile.destination));
257
252
  this.#outputHashCache.set(PathUtils.norm(assetFile.source), currHash);
258
- emitFileSet.add(PathUtils.norm(this._opt.outputPath, assetFile.destination));
253
+ emitFileSet.add(PathUtils.norm(this.#outputPath, assetFile.destination));
259
254
  }
260
255
  }
261
256
  });
@@ -296,17 +291,17 @@ export class SdNgBundler {
296
291
  ["polyfills", true],
297
292
  ["styles", false],
298
293
  ["main", true],
299
- ...(this._opt.builderType === "cordova" ? [["cordova-entry", true] as Entrypoint] : []),
294
+ ...(this._conf.builderType === "cordova" ? [["cordova-entry", true] as Entrypoint] : []),
300
295
  ],
301
296
  sri: false,
302
297
  optimization: {
303
- scripts: !this._opt.dev,
298
+ scripts: !this._opt.watch?.dev,
304
299
  styles: {
305
- minify: !this._opt.dev,
306
- inlineCritical: !this._opt.dev,
307
- removeSpecialComments: !this._opt.dev,
300
+ minify: !this._opt.watch?.dev,
301
+ inlineCritical: !this._opt.watch?.dev,
302
+ removeSpecialComments: !this._opt.watch?.dev,
308
303
  },
309
- fonts: { inline: !this._opt.dev },
304
+ fonts: { inline: !this._opt.watch?.dev },
310
305
  },
311
306
  crossOrigin: CrossOrigin.None,
312
307
  generateDedicatedSSRContent: false,
@@ -315,7 +310,7 @@ export class SdNgBundler {
315
310
 
316
311
  const modulePreloads: { url: string; mode: HintMode; depth: number }[] = [];
317
312
  const hints: { url: string; mode: HintMode; as?: string }[] = [];
318
- if (!this._opt.dev) {
313
+ if (!this._opt.watch?.dev) {
319
314
  for (const [key, value] of initialFiles) {
320
315
  if (value.entrypoint || value.serverFile) {
321
316
  continue;
@@ -355,9 +350,9 @@ export class SdNgBundler {
355
350
  return await resolveAssets(
356
351
  [
357
352
  { input: "public", glob: "**/*", output: "." },
358
- ...(this._opt.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
359
- ...(this._opt.dev && this._opt.builderType === "cordova"
360
- ? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} }).mapMany(
353
+ ...(this._opt.watch?.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
354
+ ...(this._opt.watch?.dev && this._conf.builderType === "cordova"
355
+ ? Object.keys(this._conf.builderConfig?.platform ?? { browser: {} }).mapMany(
361
356
  (platform) => [
362
357
  {
363
358
  input: `.cordova/platforms/${platform}/platform_www/plugins`,
@@ -423,31 +418,31 @@ export class SdNgBundler {
423
418
  conditions: ["es2020", "es2015", "module"],
424
419
  resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
425
420
  metafile: true,
426
- legalComments: this._opt.dev ? "eof" : "none",
421
+ legalComments: this._opt.watch?.dev ? "eof" : "none",
427
422
  logLevel: "silent",
428
- minifyIdentifiers: !this._opt.dev,
429
- minifySyntax: !this._opt.dev,
430
- minifyWhitespace: !this._opt.dev,
423
+ minifyIdentifiers: !this._opt.watch?.dev,
424
+ minifySyntax: !this._opt.watch?.dev,
425
+ minifyWhitespace: !this._opt.watch?.dev,
431
426
  pure: ["forwardRef"],
432
427
  outdir: this._opt.pkgPath,
433
428
  outExtension: undefined,
434
- sourcemap: this._opt.dev,
429
+ sourcemap: !!this._opt.watch?.dev,
435
430
  chunkNames: "[name]-[hash]",
436
431
  tsconfig: this.#tsConfigFilePath,
437
432
  write: false,
438
433
  preserveSymlinks: false,
439
434
  define: {
440
- ...(!this._opt.dev ? { ngDevMode: "false" } : {}),
435
+ ...(!this._opt.watch?.dev ? { ngDevMode: "false" } : {}),
441
436
  "ngJitMode": "false",
442
437
  "global": "global",
443
438
  "process": "process",
444
439
  "Buffer": "Buffer",
445
440
  "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
446
- "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
447
- ...(this._opt.env
448
- ? Object.keys(this._opt.env).toObject(
441
+ "process.env.NODE_ENV": JSON.stringify(this._opt.watch?.dev ? "development" : "production"),
442
+ ...(this._conf.env
443
+ ? Object.keys(this._conf.env).toObject(
449
444
  (key) => `process.env.${key}`,
450
- (key) => JSON.stringify(this._opt.env![key]),
445
+ (key) => JSON.stringify(this._conf.env![key]),
451
446
  )
452
447
  : {}),
453
448
  },
@@ -461,7 +456,7 @@ export class SdNgBundler {
461
456
  }
462
457
  : {}),
463
458
 
464
- ...(this._opt.builderType === "cordova"
459
+ ...(this._conf.builderType === "cordova"
465
460
  ? {
466
461
  "cordova-entry": path.resolve(
467
462
  path.dirname(fileURLToPath(import.meta.url)),
@@ -499,11 +494,15 @@ export class SdNgBundler {
499
494
  ".mp3": "file",
500
495
  ".ogg": "file",
501
496
  },
502
- ...(this._opt.builderType === "electron"
497
+ ...(this._conf.builderType === "electron"
503
498
  ? {
504
499
  platform: "node",
505
500
  target: "node20",
506
- external: ["electron", ...nodeModule.builtinModules, ...this._opt.external],
501
+ external: [
502
+ "electron",
503
+ ...nodeModule.builtinModules,
504
+ ...(this._conf.builderConfig?.reinstallDependencies ?? []),
505
+ ],
507
506
  }
508
507
  : {
509
508
  platform: "browser",
@@ -518,17 +517,8 @@ export class SdNgBundler {
518
517
  }),
519
518
  plugins: [
520
519
  createSourcemapIgnorelistPlugin(),
521
- createSdNgPlugin({
522
- modifiedFileSet: this.#modifiedFileSet,
523
- watch: this._opt.watch,
524
- dev: this._opt.dev,
525
- emitOnly: this._opt.emitOnly,
526
- noEmit: this._opt.noEmit,
527
- pkgPath: this._opt.pkgPath,
528
- result: this.#ngResultCache,
529
- scopePathSet: this._opt.scopePathSet,
530
- }),
531
- ...(this._opt.builderType === "electron"
520
+ createSdNgPlugin(this._opt, this.#modifiedFileSet, this.#ngResultCache),
521
+ ...(this._conf.builderType === "electron"
532
522
  ? []
533
523
  : [nodeStdLibBrowserPlugin(nodeStdLibBrowser)]),
534
524
  // {
@@ -549,7 +539,7 @@ export class SdNgBundler {
549
539
  #getStyleContext(): SdNgBundlerContext {
550
540
  const pluginFactory = new StylesheetPluginFactory(
551
541
  {
552
- sourcemap: this._opt.dev,
542
+ sourcemap: !!this._opt.watch?.dev,
553
543
  includePaths: [],
554
544
  },
555
545
  this.#styleLoadResultCache,
@@ -561,9 +551,9 @@ export class SdNgBundler {
561
551
  entryNames: "[name]",
562
552
  assetNames: "media/[name]",
563
553
  logLevel: "silent",
564
- minify: !this._opt.dev,
554
+ minify: !this._opt.watch?.dev,
565
555
  metafile: true,
566
- sourcemap: this._opt.dev,
556
+ sourcemap: !!this._opt.watch?.dev,
567
557
  outdir: this._opt.pkgPath,
568
558
  write: false,
569
559
  platform: "browser",
@@ -572,7 +562,7 @@ export class SdNgBundler {
572
562
  external: [],
573
563
  conditions: ["style", "sass"],
574
564
  mainFields: ["style", "sass"],
575
- legalComments: !this._opt.dev ? "none" : "eof",
565
+ legalComments: !this._opt.watch?.dev ? "none" : "eof",
576
566
  entryPoints: {
577
567
  styles: path.resolve(this._opt.pkgPath, "src/styles.scss"),
578
568
  },
@@ -593,23 +583,23 @@ export class SdNgBundler {
593
583
  conditions: ["es2020", "es2015", "module"],
594
584
  resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
595
585
  metafile: true,
596
- legalComments: this._opt.dev ? "eof" : "none",
586
+ legalComments: this._opt.watch?.dev ? "eof" : "none",
597
587
  logLevel: "silent",
598
- minify: !this._opt.dev,
588
+ minify: !this._opt.watch?.dev,
599
589
  outdir: this._opt.pkgPath,
600
- sourcemap: this._opt.dev,
590
+ sourcemap: !!this._opt.watch?.dev,
601
591
  tsconfig: this.#tsConfigFilePath,
602
592
  write: false,
603
593
  preserveSymlinks: false,
604
594
  external: ["electron"],
605
595
  define: {
606
- ...(!this._opt.dev ? { ngDevMode: "false" } : {}),
596
+ ...(!this._opt.watch?.dev ? { ngDevMode: "false" } : {}),
607
597
  "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
608
- "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
609
- ...(this._opt.env
610
- ? Object.keys(this._opt.env).toObject(
598
+ "process.env.NODE_ENV": JSON.stringify(this._opt.watch?.dev ? "development" : "production"),
599
+ ...(this._conf.env
600
+ ? Object.keys(this._conf.env).toObject(
611
601
  (key) => `process.env.${key}`,
612
- (key) => JSON.stringify(this._opt.env![key]),
602
+ (key) => JSON.stringify(this._conf.env![key]),
613
603
  )
614
604
  : {}),
615
605
  },
@@ -624,3 +614,9 @@ export class SdNgBundler {
624
614
  this.#logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
625
615
  }
626
616
  }
617
+
618
+ interface IConf<T extends keyof NonNullable<ISdClientPackageConfig["builder"]>> {
619
+ builderType: T;
620
+ builderConfig: NonNullable<ISdClientPackageConfig["builder"]>[T];
621
+ env: Record<string, string> | undefined;
622
+ }
@@ -6,40 +6,26 @@ import { FsUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node"
6
6
  import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTimer";
7
7
  import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
8
8
  import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
9
- import { ScopePathSet } from "../commons/ScopePathSet";
10
9
  import { ISdCliNgPluginResultCache } from "../../types/plugin/ISdCliNgPluginResultCache";
11
10
  import { ISdTsCompilerResult } from "../../types/build/ISdTsCompilerResult";
11
+ import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
12
12
 
13
- export function createSdNgPlugin(conf: {
14
- pkgPath: TNormPath;
15
- watch: boolean;
16
- dev: boolean;
17
- emitOnly: boolean;
18
- noEmit: boolean;
19
- modifiedFileSet: Set<TNormPath>;
20
- result: ISdCliNgPluginResultCache;
21
- scopePathSet: ScopePathSet;
22
- }): esbuild.Plugin {
13
+ export function createSdNgPlugin(
14
+ opt: ISdTsCompilerOptions,
15
+ modifiedFileSet: Set<TNormPath>,
16
+ resultCache: ISdCliNgPluginResultCache,
17
+ ): esbuild.Plugin {
23
18
  let perf: SdCliPerformanceTimer;
24
19
  const logger = SdLogger.get(["simplysm", "sd-cli", "createSdNgPlugin"]);
25
20
 
26
21
  const debug = (...msg: any[]) => {
27
- logger.debug(`[${path.basename(conf.pkgPath)}]`, ...msg);
22
+ logger.debug(`[${path.basename(opt.pkgPath)}]`, ...msg);
28
23
  };
29
24
 
30
25
  return {
31
26
  name: "sd-ng-compile",
32
27
  setup: (build: esbuild.PluginBuild) => {
33
- const tsCompiler = new SdTsCompiler({
34
- pkgPath: conf.pkgPath,
35
- additionalOptions: { declaration: false },
36
- isWatchMode: conf.watch,
37
- isDevMode: conf.dev,
38
- isForBundle: true,
39
- isEmitOnly: conf.emitOnly,
40
- isNoEmit: conf.noEmit,
41
- scopePathSet: conf.scopePathSet,
42
- });
28
+ const tsCompiler = new SdTsCompiler(opt, true);
43
29
 
44
30
  let tsCompileResult: ISdTsCompilerResult;
45
31
  const outputContentsCacheMap = new Map<TNormPath, Uint8Array>();
@@ -47,10 +33,10 @@ export function createSdNgPlugin(conf: {
47
33
  //-- js babel transformer
48
34
  const javascriptTransformer = new JavaScriptTransformer(
49
35
  {
50
- thirdPartySourcemaps: conf.dev,
51
- sourcemap: conf.dev,
36
+ thirdPartySourcemaps: !!opt.watch?.dev,
37
+ sourcemap: !!opt.watch?.dev,
52
38
  jit: false,
53
- advancedOptimizations: !conf.dev,
39
+ advancedOptimizations: !opt.watch?.dev,
54
40
  },
55
41
  Math.floor((os.cpus().length * 2) / 3),
56
42
  );
@@ -61,18 +47,18 @@ export function createSdNgPlugin(conf: {
61
47
  perf = new SdCliPerformanceTimer("esbuild");
62
48
 
63
49
  const res = await perf.run("typescript build", async () => {
64
- for (const modifiedFile of conf.modifiedFileSet) {
50
+ for (const modifiedFile of modifiedFileSet) {
65
51
  outputContentsCacheMap.delete(modifiedFile);
66
52
  }
67
53
 
68
- tsCompileResult = await tsCompiler.compileAsync(conf.modifiedFileSet);
54
+ tsCompileResult = await tsCompiler.compileAsync(modifiedFileSet);
69
55
 
70
- conf.result.watchFileSet = tsCompileResult.watchFileSet;
71
- conf.result.affectedFileSet = tsCompileResult.affectedFileSet;
56
+ resultCache.watchFileSet = tsCompileResult.watchFileSet;
57
+ resultCache.affectedFileSet = tsCompileResult.affectedFileSet;
72
58
 
73
59
  const tsEsbuildResult = SdCliConvertMessageUtils.convertToEsbuildFromBuildMessages(
74
60
  tsCompileResult.messages,
75
- conf.pkgPath,
61
+ opt.pkgPath,
76
62
  );
77
63
 
78
64
  //-- return err/warn
@@ -121,7 +107,7 @@ export function createSdNgPlugin(conf: {
121
107
  });
122
108
 
123
109
  build.onLoad({ filter: /\.mjs$/ }, async (args) => {
124
- conf.result.watchFileSet!.add(PathUtils.norm(args.path));
110
+ resultCache.watchFileSet!.add(PathUtils.norm(args.path));
125
111
 
126
112
  const output = outputContentsCacheMap.get(PathUtils.norm(args.path));
127
113
  if (output != null) {
@@ -164,7 +150,7 @@ export function createSdNgPlugin(conf: {
164
150
  ")$",
165
151
  );
166
152
  build.onLoad({ filter: otherLoaderFilter }, (args) => {
167
- conf.result.watchFileSet!.add(PathUtils.norm(args.path));
153
+ resultCache.watchFileSet!.add(PathUtils.norm(args.path));
168
154
  return null;
169
155
  });
170
156
 
@@ -190,10 +176,10 @@ export function createSdNgPlugin(conf: {
190
176
  }
191
177
  }
192
178
 
193
- conf.result.outputFiles = result.outputFiles;
194
- conf.result.metafile = result.metafile;
179
+ resultCache.outputFiles = result.outputFiles;
180
+ resultCache.metafile = result.metafile;
195
181
 
196
- conf.modifiedFileSet.clear();
182
+ modifiedFileSet.clear();
197
183
  });
198
184
  },
199
185
  };
@@ -1,7 +1,7 @@
1
1
  import { FsUtils, PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
2
  import path from "path";
3
3
  import { ESLint } from "eslint";
4
- import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
4
+ import { SdBuildRunnerBase } from "../SdBuildRunnerBase";
5
5
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
6
6
  import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
7
7
 
@@ -9,7 +9,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
9
9
  protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdJsLibBuildRunner"]);
10
10
 
11
11
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
12
- if (this._emitOnly) {
12
+ if (this._opt.watch?.emitOnly) {
13
13
  return {
14
14
  buildMessages: [],
15
15
 
@@ -22,7 +22,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
22
22
  const filePathSet =
23
23
  modifiedFileSet ??
24
24
  new Set(
25
- FsUtils.glob(path.resolve(this._pkgPath, "src/**/*.js")).map((item) =>
25
+ FsUtils.glob(path.resolve(this._opt.pkgPath, "src/**/*.js")).map((item) =>
26
26
  PathUtils.norm(item),
27
27
  ),
28
28
  );
@@ -45,7 +45,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
45
45
 
46
46
  async #lintAsync(fileSet: Set<string>) {
47
47
  const lintFilePaths = Array.from(fileSet)
48
- .filter((item) => PathUtils.isChildPath(item, path.resolve(this._pkgPath, "src")))
48
+ .filter((item) => PathUtils.isChildPath(item, path.resolve(this._opt.pkgPath, "src")))
49
49
  .filter((item) => item.endsWith(".js"))
50
50
  .filter((item) => FsUtils.exists(item));
51
51
 
@@ -53,7 +53,7 @@ export class SdJsLibBuildRunner extends SdBuildRunnerBase<"library"> {
53
53
  return [];
54
54
  }
55
55
 
56
- const linter = new ESLint({ cwd: this._pkgPath, cache: false });
56
+ const linter = new ESLint({ cwd: this._opt.pkgPath, cache: false });
57
57
  return await linter.lintFiles(lintFilePaths);
58
58
  }
59
59
  }
@@ -1,5 +1,5 @@
1
- import { PathUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
- import { SdBuildRunnerBase } from "../commons/SdBuildRunnerBase";
1
+ import { SdLogger, TNormPath } from "@simplysm/sd-core-node";
2
+ import { SdBuildRunnerBase } from "../SdBuildRunnerBase";
3
3
  import { SdTsLibBuilder } from "./SdTsLibBuilder";
4
4
  import { SdCliIndexFileGenerator } from "./SdCliIndexFileGenerator";
5
5
  import { ISdBuildResult } from "../../types/build/ISdBuildResult";
@@ -13,32 +13,28 @@ export class SdTsLibBuildRunner extends SdBuildRunnerBase<"library"> {
13
13
  protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
14
14
  // 최초한번
15
15
  if (!modifiedFileSet) {
16
- if (!this._noEmit) {
16
+ if (!this._opt.watch?.noEmit) {
17
17
  // index
18
18
  if (!this._pkgConf.noGenIndex) {
19
19
  this._debug("GEN index.ts...");
20
- await new SdCliIndexFileGenerator().watchAsync(this._pkgPath, this._pkgConf.polyfills);
20
+ await new SdCliIndexFileGenerator().watchAsync(
21
+ this._opt.pkgPath,
22
+ this._pkgConf.polyfills,
23
+ );
21
24
  }
22
25
 
23
26
  // db-context
24
27
  if (this._pkgConf.dbContext != null) {
25
28
  this._debug(`GEN ${this._pkgConf.dbContext}.ts...`);
26
29
  await new SdCliDbContextFileGenerator().watchAsync(
27
- this._pkgPath,
30
+ this._opt.pkgPath,
28
31
  this._pkgConf.dbContext,
29
32
  );
30
33
  }
31
34
  }
32
35
 
33
36
  this._debug(`BUILD 준비...`);
34
- this.#builder = new SdTsLibBuilder(
35
- PathUtils.norm(this._pkgPath),
36
- this._watch,
37
- this._dev,
38
- this._emitOnly ?? false,
39
- this._noEmit ?? false,
40
- this._scopePathSet,
41
- );
37
+ this.#builder = new SdTsLibBuilder(this._opt);
42
38
  }
43
39
 
44
40
  this._debug(`BUILD...`);