@simplysm/sd-cli 6.0.27 → 6.0.36

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 (78) hide show
  1. package/dist-node/bin/sd-cli.js +19 -4
  2. package/dist-node/bin/sd-cli.js.map +1 -1
  3. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js +98 -57
  4. package/dist-node/build-tools/SdCliNgModuleFilesGenerator.js.map +1 -1
  5. package/dist-node/build-tools/metadata/SdAotMetadataReader.js +16 -12
  6. package/dist-node/build-tools/metadata/SdAotMetadataReader.js.map +1 -1
  7. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js +23 -6
  8. package/dist-node/build-tools/metadata/SdIvyMetadataReader.js.map +1 -1
  9. package/dist-node/build-tools/metadata/SdMetadataError.js +13 -0
  10. package/dist-node/build-tools/metadata/SdMetadataError.js.map +1 -0
  11. package/dist-node/build-tools/metadata/SdMyMetadataReader.js +22 -5
  12. package/dist-node/build-tools/metadata/SdMyMetadataReader.js.map +1 -1
  13. package/dist-node/builders/SdCliNgClientBuilder.js +74 -74
  14. package/dist-node/builders/SdCliNgClientBuilder.js.map +1 -1
  15. package/dist-node/builders/SdCliNgLibraryBuilder.js +38 -34
  16. package/dist-node/builders/SdCliNgLibraryBuilder.js.map +1 -1
  17. package/dist-node/builders/SdCliServerBuilder.js +46 -45
  18. package/dist-node/builders/SdCliServerBuilder.js.map +1 -1
  19. package/dist-node/builders/SdCliTypescriptBuilder.js +65 -60
  20. package/dist-node/builders/SdCliTypescriptBuilder.js.map +1 -1
  21. package/dist-node/entry-points/SdCliLocalUpdater.js +30 -29
  22. package/dist-node/entry-points/SdCliLocalUpdater.js.map +1 -1
  23. package/dist-node/entry-points/SdCliProject.js +10 -16
  24. package/dist-node/entry-points/SdCliProject.js.map +1 -1
  25. package/dist-node/packages/SdCliClientPackage.js +6 -4
  26. package/dist-node/packages/SdCliClientPackage.js.map +1 -1
  27. package/dist-node/packages/SdCliLibraryPackage.js +5 -3
  28. package/dist-node/packages/SdCliLibraryPackage.js.map +1 -1
  29. package/dist-node/packages/SdCliServerPackage.js +4 -3
  30. package/dist-node/packages/SdCliServerPackage.js.map +1 -1
  31. package/dist-node/utils/SdProjectConfigUtil.js +1 -1
  32. package/dist-node/utils/SdProjectConfigUtil.js.map +1 -1
  33. package/dist-node/utils/SdWebpackUtil.js +33 -13
  34. package/dist-node/utils/SdWebpackUtil.js.map +1 -1
  35. package/dist-node/workers/client-ng-gen-worker.js +54 -0
  36. package/dist-node/workers/client-ng-gen-worker.js.map +1 -0
  37. package/dist-node/workers/lib-build-worker.js +7 -6
  38. package/dist-node/workers/lib-build-worker.js.map +1 -1
  39. package/dist-types/build-tools/metadata/SdIvyMetadataReader.d.ts +1 -0
  40. package/dist-types/build-tools/metadata/SdMetadataError.d.ts +6 -0
  41. package/dist-types/build-tools/metadata/SdMyMetadataReader.d.ts +1 -0
  42. package/dist-types/builders/SdCliNgClientBuilder.d.ts +6 -2
  43. package/dist-types/builders/SdCliNgLibraryBuilder.d.ts +1 -1
  44. package/dist-types/builders/SdCliServerBuilder.d.ts +2 -1
  45. package/dist-types/builders/SdCliTypescriptBuilder.d.ts +5 -5
  46. package/dist-types/commons.d.ts +4 -1
  47. package/dist-types/entry-points/SdCliLocalUpdater.d.ts +1 -1
  48. package/dist-types/entry-points/SdCliProject.d.ts +2 -0
  49. package/dist-types/packages/SdCliClientPackage.d.ts +2 -1
  50. package/dist-types/packages/SdCliLibraryPackage.d.ts +2 -1
  51. package/dist-types/packages/SdCliServerPackage.d.ts +2 -1
  52. package/dist-types/utils/SdWebpackUtil.d.ts +1 -1
  53. package/dist-types/workers/client-ng-gen-worker.d.ts +1 -0
  54. package/package.json +7 -7
  55. package/schema/schema.json +185 -122
  56. package/sd-tsconfig.node.json +2 -1
  57. package/src/bin/sd-cli.ts +19 -4
  58. package/src/build-tools/SdCliNgModuleFilesGenerator.ts +114 -70
  59. package/src/build-tools/metadata/SdAotMetadataReader.ts +8 -2
  60. package/src/build-tools/metadata/SdIvyMetadataReader.ts +27 -4
  61. package/src/build-tools/metadata/SdMetadataError.ts +7 -0
  62. package/src/build-tools/metadata/SdMyMetadataReader.ts +25 -3
  63. package/src/builders/SdCliNgClientBuilder.ts +123 -66
  64. package/src/builders/SdCliNgLibraryBuilder.ts +79 -39
  65. package/src/builders/SdCliServerBuilder.ts +61 -44
  66. package/src/builders/SdCliTypescriptBuilder.ts +92 -73
  67. package/src/commons.ts +3 -2
  68. package/src/entry-points/SdCliLocalUpdater.ts +40 -33
  69. package/src/entry-points/SdCliProject.ts +14 -13
  70. package/src/packages/SdCliClientPackage.ts +5 -3
  71. package/src/packages/SdCliLibraryPackage.ts +4 -2
  72. package/src/packages/SdCliServerPackage.ts +4 -3
  73. package/src/utils/SdCliFileCrypto.ts +1 -1
  74. package/src/utils/SdProjectConfigUtil.ts +1 -1
  75. package/src/utils/SdWebpackUtil.ts +42 -22
  76. package/src/workers/client-ng-gen-worker.ts +60 -0
  77. package/src/workers/lib-build-worker.ts +7 -6
  78. package/tsconfig.json +2 -1
@@ -1,5 +1,5 @@
1
1
  import * as ts from "typescript";
2
- import { ISdAutoIndexConfig, ISdPackageBuildResult, ITsconfig } from "../commons";
2
+ import { ISdAutoIndexConfig, ISdPackageBuildResult } from "../commons";
3
3
  import * as path from "path";
4
4
  import { SdTsDiagnosticUtil } from "../utils/SdTsDiagnosticUtil";
5
5
  import { NgccProcessingCache } from "ng-packagr/lib/ng-package/ngcc-cache";
@@ -10,7 +10,7 @@ import { MetadataCollector, NgtscProgram } from "@angular/compiler-cli";
10
10
  import { ITsBuildFileCache, ITsGenResult, SdCliTypescriptBuilder } from "./SdCliTypescriptBuilder";
11
11
  import { NgCompiler } from "@angular/compiler-cli/src/ngtsc/core";
12
12
  import { NeverEntryError, StringUtil } from "@simplysm/sd-core-common";
13
- import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
13
+ import { PathUtil } from "@simplysm/sd-core-node";
14
14
  import * as os from "os";
15
15
  import * as nodeSass from "node-sass";
16
16
  import { createHash } from "crypto";
@@ -29,20 +29,10 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
29
29
 
30
30
  public constructor(public rootPath: string,
31
31
  public tsconfigFilePath: string,
32
- ignoreProcesses: ("emit" | "check" | "lint" | "genIndex" | "genNgModule")[],
32
+ skipProcesses: ("emit" | "check" | "lint" | "genIndex" | "genNgModule")[],
33
33
  public autoIndexConfig: ISdAutoIndexConfig | undefined) {
34
- super(rootPath, tsconfigFilePath, ignoreProcesses as ("emit" | "check" | "lint" | "genIndex")[], autoIndexConfig);
35
- this.ignoreProcesses = ignoreProcesses;
36
-
37
- const tsconfig: ITsconfig = FsUtil.readJson(this.tsconfigFilePath);
38
- this._parsedTsconfig = {
39
- ...this._parsedTsconfig,
40
- options: {
41
- baseUrl: path.dirname(this.tsconfigFilePath),
42
- ...this._parsedTsconfig.options,
43
- ...tsconfig.angularCompilerOptions
44
- }
45
- };
34
+ super(rootPath, tsconfigFilePath, skipProcesses as ("emit" | "check" | "lint" | "genIndex")[], autoIndexConfig);
35
+ this.skipProcesses = skipProcesses;
46
36
  }
47
37
 
48
38
  protected override async _runProgramAsync(dirtyFilePaths: string[]): Promise<ISdPackageBuildResult[]> {
@@ -53,7 +43,7 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
53
43
 
54
44
  const diagnostics: ts.Diagnostic[] = [];
55
45
 
56
- if (!this.ignoreProcesses.includes("check")) {
46
+ if (!this.skipProcesses.includes("check")) {
57
47
  diagnostics.push(
58
48
  ...this._ngCompiler.getOptionDiagnostics(),
59
49
  ...this._builder.getOptionsDiagnostics(),
@@ -62,9 +52,10 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
62
52
 
63
53
  await this._ngCompiler.analyzeAsync();
64
54
 
65
- for (const filePath of dirtyFilePaths) {
66
- const sourceFile = this._builder.getSourceFile(filePath);
67
- if (!sourceFile) continue;
55
+ for (const sourceFile of this._builder.getSourceFiles()) {
56
+ /*for (const filePath of dirtyFilePaths) {
57
+ const sourceFile = this._builder.getSourceFile(filePath);
58
+ if (!sourceFile) continue;*/
68
59
 
69
60
  if (this._ngCompiler.ignoreForDiagnostics.has(sourceFile)) continue;
70
61
  if (sourceFile.isDeclarationFile) continue;
@@ -77,7 +68,7 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
77
68
  }
78
69
  }
79
70
 
80
- if (!this.ignoreProcesses.includes("emit")) {
71
+ if (!this.skipProcesses.includes("emit")) {
81
72
  const transformers = this._ngCompiler.prepareEmit().transformers;
82
73
 
83
74
  for (const filePath of dirtyFilePaths) {
@@ -88,7 +79,8 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
88
79
 
89
80
  this._builder.emit(sourceFile, undefined, undefined, undefined, transformers);
90
81
 
91
- if (this._parsedTsconfig.options.declaration) {
82
+ // TODO: sd-metadata를 ModuleMetadata로 만들게 아니고, 아예 IAotModuleDefMetadata형식으로 만들어지게 해야함
83
+ if (this._program!.getCompilerOptions().declaration) {
92
84
  if (sourceFile.fileName.endsWith(".ts") && !sourceFile.fileName.endsWith(".d.ts")) {
93
85
  const metadata = this._getMetadata(sourceFile);
94
86
  if (metadata) {
@@ -97,6 +89,10 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
97
89
  }
98
90
  }
99
91
  }
92
+
93
+ /*if (this._parsedTsconfig.options.declaration) {
94
+ this._writeMetadataBundles();
95
+ }*/
100
96
  }
101
97
 
102
98
  const result = diagnostics.map((item) => SdTsDiagnosticUtil.convertDiagnosticsToResult(item)).filterExists();
@@ -107,9 +103,12 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
107
103
  }
108
104
 
109
105
  private _writeMetadataFile(sourceFile: ts.SourceFile, metadata: ModuleMetadata): void {
110
- const metadataText = JSON.stringify([metadata]);
106
+ const metadataText = JSON.stringify({
107
+ ...metadata,
108
+ importAs: this.npmConfig.name
109
+ });
111
110
  const outFileName = path.resolve(
112
- this._parsedTsconfig.options.declarationDir!,
111
+ this._program!.getCompilerOptions().declarationDir!,
113
112
  path.relative(path.resolve(this.rootPath, "src"), sourceFile.fileName)
114
113
  ).replace(/\.ts$/, ".sd-metadata.json");
115
114
  this._cacheCompilerHost!.writeFile(outFileName, metadataText, false, undefined, [sourceFile]);
@@ -119,15 +118,38 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
119
118
  return new MetadataCollector().getMetadata(sourceFile, true);
120
119
  }
121
120
 
121
+ /*private _writeMetadataBundles(): void {
122
+ for (const rootFilePath of this._parsedTsconfig.fileNames) {
123
+ const metadata = new MetadataBundler(
124
+ rootFilePath.replace(/\.ts$/, ""),
125
+ rootFilePath.endsWith("/index.ts") ? this.npmConfig.name
126
+ : (this.npmConfig.name + "/" + PathUtil.posix(path.relative(path.resolve(this.rootPath, "src"), rootFilePath)).replace(/\.ts/, "")),
127
+ new CompilerHostAdapter(this._cacheCompilerHost!, null, this._parsedTsconfig.options),
128
+ undefined
129
+ ).getMetadataBundle().metadata;
130
+
131
+ const outFileName = path.resolve(
132
+ this._parsedTsconfig.options.declarationDir!,
133
+ path.relative(path.resolve(this.rootPath, "src"), rootFilePath)
134
+ ).replace(/\.ts$/, ".sd-metadata.json");
135
+
136
+ const fileCache = this._fileCache.get(PathUtil.posix(rootFilePath));
137
+ if (!fileCache?.sourceFile) throw new NeverEntryError();
138
+ this._cacheCompilerHost!.writeFile(outFileName, JSON.stringify(metadata), false, undefined, [fileCache.sourceFile]);
139
+ }
140
+ }*/
141
+
122
142
  public override async reloadProgramAsync(watch: boolean): Promise<string[]> {
123
143
  this._logger.debug("프로그램 리로드");
124
144
 
125
- this._moduleResolutionCache = ts.createModuleResolutionCache(this.rootPath, (s) => s, this._parsedTsconfig.options);
126
- this._cacheCompilerHost = await this._createCacheCompilerHostAsync(this._parsedTsconfig, this._moduleResolutionCache);
145
+ const parsedTsconfig = ts.parseJsonConfigFileContent(this._tsconfig, ts.sys, this.rootPath, this._tsconfig.angularCompilerOptions);
146
+
147
+ this._moduleResolutionCache = ts.createModuleResolutionCache(this.rootPath, (s) => s, parsedTsconfig.options);
148
+ this._cacheCompilerHost = await this._createCacheCompilerHostAsync(parsedTsconfig, this._moduleResolutionCache);
127
149
 
128
150
  this._ngProgram = new NgtscProgram(
129
- this._parsedTsconfig.fileNames,
130
- this._parsedTsconfig.options,
151
+ parsedTsconfig.fileNames,
152
+ parsedTsconfig.options,
131
153
  this._cacheCompilerHost,
132
154
  this._ngProgram
133
155
  );
@@ -149,15 +171,27 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
149
171
  };
150
172
 
151
173
  if (watch) {
152
- const builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(
153
- this._program,
154
- this._cacheCompilerHost,
155
- this._builder as ts.EmitAndSemanticDiagnosticsBuilderProgram
156
- );
157
- this._builder = builder;
174
+ if (this.skipProcesses.includes("emit")) {
175
+ this._builder = ts.createSemanticDiagnosticsBuilderProgram(
176
+ this._program,
177
+ this._cacheCompilerHost,
178
+ this._builder as ts.SemanticDiagnosticsBuilderProgram
179
+ );
180
+ }
181
+ else {
182
+ this._builder = ts.createEmitAndSemanticDiagnosticsBuilderProgram(
183
+ this._program,
184
+ this._cacheCompilerHost,
185
+ this._builder as ts.EmitAndSemanticDiagnosticsBuilderProgram
186
+ );
187
+ }
188
+ const builder = this._builder as ts.SemanticDiagnosticsBuilderProgram;
158
189
 
159
- const affectedFilePaths: string[] = [];
190
+ let seq = 0;
191
+ const affectedFilePathSet = new Set<string>();
160
192
  while (true) {
193
+ const affectedFilePaths: string[] = [];
194
+ this._logger.debug(`프로그램 리로드 > 변경파일 목록구성: [SEQ: ${++seq}]`);
161
195
  const result = builder.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
162
196
  if (this._ngCompiler!.ignoreForDiagnostics.has(sourceFile) && sourceFile.fileName.endsWith(".ngtypecheck.ts")) {
163
197
  const originalFilename = sourceFile.fileName.slice(0, -15) + ".ts";
@@ -170,14 +204,20 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
170
204
  return false;
171
205
  });
172
206
 
173
- if (!result) break;
174
-
175
- if ("fileName" in result.affected) {
207
+ if (result && "fileName" in result.affected) {
176
208
  affectedFilePaths.push(result.affected.fileName);
177
209
  }
210
+
211
+ affectedFilePaths.distinctThis();
212
+
213
+ this._logger.debug(`프로그램 리로드 > 변경파일 목록구성: [SEQ: ${seq}, SIZE:${affectedFilePathSet.size}]\n` + affectedFilePaths.map((item) => "- " + item).join("\n"));
214
+
215
+ affectedFilePathSet.adds(...affectedFilePaths.distinct());
216
+
217
+ if (!result) break;
178
218
  }
179
219
 
180
- const result = affectedFilePaths.distinct();
220
+ const result = Array.from(affectedFilePathSet.values());
181
221
 
182
222
  this._logger.debug("프로그램 리로드", result);
183
223
 
@@ -231,7 +271,7 @@ export class SdCliNgLibraryBuilder extends SdCliTypescriptBuilder {
231
271
  this._logger.debug("Angular Module, RoutingModule 생성", dirtyFilePaths);
232
272
 
233
273
  const result: ITsGenResult = { dirtyFilePaths: [], result: [] };
234
- if (this.ignoreProcesses.includes("genNgModule")) return result;
274
+ if (this.skipProcesses.includes("genNgModule")) return result;
235
275
 
236
276
  const reloadResult = await this._moduleFilesGenerator.reloadSourceFilesAsync(
237
277
  dirtyFilePaths,
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from "events";
2
2
  import { INpmConfig, ISdPackageBuildResult, ISdServerPackageConfig, ITsconfig } from "../commons";
3
3
  import * as ts from "typescript";
4
- import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
4
+ import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
5
5
  import { ObjectUtil, StringUtil, Wait } from "@simplysm/sd-core-common";
6
6
  import * as webpack from "webpack";
7
7
  import * as path from "path";
@@ -27,7 +27,8 @@ export class SdCliServerBuilder extends EventEmitter {
27
27
  public constructor(public rootPath: string,
28
28
  public tsconfigFilePath: string,
29
29
  public projectRootPath: string,
30
- public config: ISdServerPackageConfig) {
30
+ public config: ISdServerPackageConfig,
31
+ public useCache: boolean) {
31
32
  super();
32
33
 
33
34
  const tsconfig: ITsconfig = FsUtil.readJson(this.tsconfigFilePath);
@@ -93,13 +94,19 @@ export class SdCliServerBuilder extends EventEmitter {
93
94
  ...this.config.env ? this.config.env : {}
94
95
  }
95
96
  },
96
- (typeof this.config.pm2 !== "boolean") ? this.config.pm2 : {}
97
+ (typeof this.config.pm2 !== "boolean") ? this.config.pm2 : {},
98
+ {
99
+ arrayProcess: "concat"
100
+ }
97
101
  ), undefined, 2));
98
102
  }
99
103
 
100
104
  // iis 파일 쓰기
101
- if (this.config.iis) {
105
+ if (this.config.iis !== undefined && this.config.iis !== false) {
102
106
  const iisDistPath = path.resolve(this.parsedTsconfig.options.outDir!, "web.config");
107
+ const serverExeFilePath = (this.config.iis !== true && "serverExeFilePath" in this.config.iis)
108
+ ? (this.config.iis.serverExeFilePath ?? "C:\\Program Files\\nodejs\\node.exe")
109
+ : "C:\\Program Files\\nodejs\\node.exe";
103
110
  await FsUtil.writeFileAsync(iisDistPath, `
104
111
  <configuration>
105
112
  <system.webServer>
@@ -107,7 +114,10 @@ export class SdCliServerBuilder extends EventEmitter {
107
114
  <handlers>
108
115
  <add name="iisnode" path="main.js" verb="*" modules="iisnode" />
109
116
  </handlers>
110
- <iisnode nodeProcessCommandLine="C:\\Program Files\\nodejs\\node.exe" watchedFiles="web.config;*.js" loggingEnabled="true" />
117
+ <iisnode nodeProcessCommandLine="${serverExeFilePath}"
118
+ watchedFiles="web.config;*.js"
119
+ loggingEnabled="true"
120
+ devErrorsEnabled="true" />
111
121
  <rewrite>
112
122
  <rules>
113
123
  <rule name="main">
@@ -115,9 +125,10 @@ export class SdCliServerBuilder extends EventEmitter {
115
125
  </rule>
116
126
  </rules>
117
127
  </rewrite>
118
- <httpErrors errorMode="Detailed" />
128
+ <httpErrors errorMode="Detailed" />
119
129
  </system.webServer>
120
130
  </configuration>
131
+
121
132
  `.trim());
122
133
  }
123
134
 
@@ -133,12 +144,6 @@ export class SdCliServerBuilder extends EventEmitter {
133
144
 
134
145
  await FsUtil.writeFileAsync(path.resolve(this.parsedTsconfig.options.outDir!, "package.json"), JSON.stringify(distNpmConfig, undefined, 2));
135
146
 
136
- // CopyWebpackPlugin 대신 직접 카피
137
-
138
- for (const item of ["assets/"]) {
139
- await FsUtil.copyAsync(path.resolve(this.rootPath, "src", item), path.resolve(this.parsedTsconfig.options.outDir!, item));
140
- }
141
-
142
147
  this.emit("complete", buildResults);
143
148
  }
144
149
 
@@ -148,7 +153,6 @@ export class SdCliServerBuilder extends EventEmitter {
148
153
  const externalModuleNames = this._findExternalModuleNames(true);
149
154
 
150
155
  // 빌드
151
-
152
156
  const webpackConfig = this._getWebpackConfig(true, externalModuleNames);
153
157
  const compiler = webpack(webpackConfig);
154
158
  await new Promise<void>((resolve, reject) => {
@@ -209,9 +213,9 @@ export class SdCliServerBuilder extends EventEmitter {
209
213
 
210
214
  const mainFilePath = path.resolve(this.parsedTsconfig.options.outDir!, "main.js");
211
215
 
212
- const prevLoggerConfigs = ObjectUtil.clone(Logger.configs);
216
+ // const prevLoggerConfigs = ObjectUtil.clone(Logger.configs);
213
217
  this._server = require(mainFilePath) as SdServiceServer | undefined;
214
- Logger.configs = prevLoggerConfigs;
218
+ // Logger.configs = prevLoggerConfigs;
215
219
 
216
220
  if (!this._server) {
217
221
  throw new Error(`${mainFilePath}(0, 0): 'SdServiceServer'를 'export'해야 합니다.`);
@@ -234,16 +238,16 @@ export class SdCliServerBuilder extends EventEmitter {
234
238
  resolve: {
235
239
  extensions: [".ts", ".tsx", ".js"],
236
240
  symlinks: true,
237
- modules: [this.projectRootPath, "node_modules"],
241
+ // modules: [this.projectRootPath, "node_modules"],
238
242
  mainFields: ["es2020", "main", "module"]
239
243
  },
240
- resolveLoader: {
244
+ /*resolveLoader: {
241
245
  symlinks: true,
242
246
  modules: [
243
247
  "node_modules",
244
248
  ...this._findAllNodeModules(__dirname, this.projectRootPath)
245
249
  ]
246
- },
250
+ },*/
247
251
  context: this.projectRootPath,
248
252
  entry: {
249
253
  main: [
@@ -258,6 +262,7 @@ export class SdCliServerBuilder extends EventEmitter {
258
262
  // chunkFilename: watch ? "[name].js" : "[name].[chunkhash:20].js",
259
263
  filename: "[name].js",
260
264
  chunkFilename: "[name].js",
265
+ assetModuleFilename: "resources/[name][ext][query]",
261
266
  libraryTarget: watch ? "umd" : "commonjs"
262
267
  },
263
268
  performance: { hints: false },
@@ -286,10 +291,14 @@ export class SdCliServerBuilder extends EventEmitter {
286
291
  return `${msg.file}(${msg.line}, ${msg.character}): ${msg.code}: ${msg.severity} ${msg.content}`;
287
292
  }
288
293
  }
294
+ },
295
+ {
296
+ test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico|otf|xlsx?|pptx?|docx?|zip|pfx|pkl)$/,
297
+ type: "asset/resource"
289
298
  }
290
299
  ]
291
300
  },
292
- cache: watch ? { type: "memory", maxGenerations: 1 } : false,
301
+ cache: (watch && this.useCache) ? { type: "memory", maxGenerations: 1 } : false,
293
302
  optimization: {
294
303
  minimizer: watch ? [] : [
295
304
  new JavaScriptOptimizerPlugin({
@@ -302,7 +311,7 @@ export class SdCliServerBuilder extends EventEmitter {
302
311
  ],
303
312
  moduleIds: "deterministic",
304
313
  chunkIds: watch ? "named" : "deterministic",
305
- emitOnErrors: false
314
+ emitOnErrors: watch
306
315
  },
307
316
  plugins: [
308
317
  new DedupeModuleResolvePlugin({ verbose: false }) as any,
@@ -314,30 +323,29 @@ export class SdCliServerBuilder extends EventEmitter {
314
323
  skipChildCompilers: true
315
324
  })
316
325
  ],
317
- ...watch ? [
318
- new CopyWebpackPlugin({
319
- patterns: ["assets/"].map((item) => ({
320
- context: this.rootPath,
321
- to: item,
322
- from: `src/${item}`,
323
- noErrorOnMissing: true,
324
- force: true,
325
- globOptions: {
326
- dot: true,
327
- followSymbolicLinks: false,
328
- ignore: [
329
- ".gitkeep",
330
- "**/.DS_Store",
331
- "**/Thumbs.db"
332
- ].map((i) => PathUtil.posix(this.rootPath, i))
333
- },
334
- priority: 0
335
- }))
336
- })
337
- ] : [],
338
- ...this.config.env ? [
339
- new webpack.EnvironmentPlugin(this.config.env)
340
- ] : [],
326
+ new CopyWebpackPlugin({
327
+ patterns: ["assets/"].map((item) => ({
328
+ context: this.rootPath,
329
+ to: item,
330
+ from: `src/${item}`,
331
+ noErrorOnMissing: true,
332
+ force: true,
333
+ globOptions: {
334
+ dot: true,
335
+ followSymbolicLinks: false,
336
+ ignore: [
337
+ ".gitkeep",
338
+ "**/.DS_Store",
339
+ "**/Thumbs.db"
340
+ ].map((i) => PathUtil.posix(this.rootPath, i))
341
+ },
342
+ priority: 0
343
+ }))
344
+ }),
345
+ new webpack.EnvironmentPlugin({
346
+ SD_VERSION: this._getNpmConfig(this.rootPath)!.version,
347
+ ...this.config.env
348
+ }),
341
349
  new ESLintWebpackPlugin({
342
350
  context: this.rootPath,
343
351
  eslintPath: path.resolve(this.projectRootPath, "node_modules", "eslint"),
@@ -365,6 +373,15 @@ export class SdCliServerBuilder extends EventEmitter {
365
373
  };
366
374
  }
367
375
 
376
+ /*private _findAllInternalModuleCachePaths(): string[] {
377
+ return this._findAllNodeModules(this.rootPath, this.projectRootPath)
378
+ .mapMany((item) => (
379
+ FsUtil.readdir(item)
380
+ .filter((item1) => !item1.startsWith("@simplysm"))
381
+ .map((item1) => path.resolve(item, item1))
382
+ ));
383
+ }*/
384
+
368
385
  private _findAllNodeModules(from: string, root: string): string[] {
369
386
  const nodeModules: string[] = [];
370
387