@simplysm/sd-cli 7.0.41 → 7.0.43

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 (32) hide show
  1. package/dist/bin/sd-cli.mjs +1 -1
  2. package/dist/build-tool/SdCliCacheCompilerHost.mjs +1 -1
  3. package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +1 -1
  4. package/dist/build-tool/SdCliPackageLinter.mjs +1 -1
  5. package/dist/builder/SdCliClientBuilder.mjs +189 -114
  6. package/dist/builder/SdCliJsLibBuilder.mjs +7 -3
  7. package/dist/builder/SdCliServerBuilder.mjs +58 -34
  8. package/dist/builder/SdCliTsLibBuilder.mjs +10 -6
  9. package/dist/commons.d.ts +1 -0
  10. package/dist/entry-points/SdCliLocalUpdate.mjs +1 -1
  11. package/dist/entry-points/SdCliNpm.mjs +1 -1
  12. package/dist/entry-points/SdCliPrepare.mjs +1 -1
  13. package/dist/entry-points/SdCliWorkspace.mjs +3 -3
  14. package/dist/packages/SdCliPackage.mjs +2 -2
  15. package/dist/utils/SdCliConfigUtil.mjs +2 -2
  16. package/package.json +3 -4
  17. package/src/bin/sd-cli.ts +1 -1
  18. package/src/build-tool/SdCliCacheCompilerHost.ts +1 -1
  19. package/src/build-tool/SdCliNgCacheCompilerHost.ts +1 -1
  20. package/src/build-tool/SdCliPackageLinter.ts +1 -1
  21. package/src/builder/SdCliClientBuilder.ts +191 -112
  22. package/src/builder/SdCliJsLibBuilder.ts +6 -2
  23. package/src/builder/SdCliServerBuilder.ts +59 -33
  24. package/src/builder/SdCliTsLibBuilder.ts +10 -5
  25. package/src/commons.ts +1 -0
  26. package/src/entry-points/SdCliLocalUpdate.ts +1 -1
  27. package/src/entry-points/SdCliNpm.ts +1 -1
  28. package/src/entry-points/SdCliPrepare.ts +1 -1
  29. package/src/entry-points/SdCliWorkspace.ts +3 -2
  30. package/src/packages/SdCliPackage.ts +2 -2
  31. package/src/utils/SdCliConfigUtil.ts +2 -2
  32. package/tsconfig.json +4 -7
@@ -1,6 +1,6 @@
1
1
  import { INpmConfig, ISdCliClientPackageConfig, ISdCliPackageBuildResult } from "../commons";
2
2
  import { EventEmitter } from "events";
3
- import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
3
+ import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core/node";
4
4
  import webpack from "webpack";
5
5
  import path from "path";
6
6
  import ts from "typescript";
@@ -10,6 +10,7 @@ import {
10
10
  AnyComponentStyleBudgetChecker,
11
11
  CommonJsUsageWarnPlugin,
12
12
  DedupeModuleResolvePlugin,
13
+ JavaScriptOptimizerPlugin,
13
14
  SuppressExtractedTextChunksWebpackPlugin
14
15
  } from "@angular-devkit/build-angular/src/webpack/plugins";
15
16
  import CopyWebpackPlugin from "copy-webpack-plugin";
@@ -25,6 +26,13 @@ import { LicenseWebpackPlugin } from "license-webpack-plugin";
25
26
  import { Type } from "@angular-devkit/build-angular";
26
27
  import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
27
28
  import { createHash } from "crypto";
29
+ import ESLintWebpackPlugin from "eslint-webpack-plugin";
30
+ import os from "os";
31
+ import { ESLint } from "eslint";
32
+ import { TransferSizePlugin } from "@angular-devkit/build-angular/src/webpack/plugins/transfer-size-plugin";
33
+ import { CssOptimizerPlugin } from "@angular-devkit/build-angular/src/webpack/plugins/css-optimizer-plugin";
34
+ import browserslist from "browserslist";
35
+ import LintResult = ESLint.LintResult;
28
36
 
29
37
  export class SdCliClientBuilder extends EventEmitter {
30
38
  private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
@@ -120,13 +128,18 @@ export class SdCliClientBuilder extends EventEmitter {
120
128
  }
121
129
 
122
130
  private _getWebpackConfig(watch: boolean): webpack.Configuration {
131
+ const internalModuleCachePaths = watch
132
+ ? FsUtil.findAllParentChildDirPaths("node_modules/!(@simplysm)", this._rootPath, this._workspaceRootPath)
133
+ : undefined;
134
+
123
135
  const npmConfig = this._getNpmConfig(this._rootPath)!;
124
136
  const pkgVersion = npmConfig.version;
137
+ const ngVersion = this._getNpmConfig(FsUtil.findAllParentChildDirPaths("node_modules/@angular/core", this._rootPath, this._workspaceRootPath)[0])!.version;
125
138
 
126
139
  const pkgKey = npmConfig.name.split("/").last()!;
127
140
  const publicPath = `/${pkgKey}/`;
128
141
 
129
- const cacheBasePath = path.resolve(this._rootPath, ".angular");
142
+ const cacheBasePath = path.resolve(this._rootPath, ".cache");
130
143
  const cachePath = path.resolve(cacheBasePath, pkgVersion);
131
144
 
132
145
  const distPath = this._parsedTsconfig.options.outDir;
@@ -193,11 +206,46 @@ export class SdCliClientBuilder extends EventEmitter {
193
206
  profile: watch ? undefined : false,
194
207
  cacheDirectory: path.resolve(cachePath, "angular-webpack"),
195
208
  maxMemoryGenerations: 1,
196
- name: createHash("sha1").update(pkgVersion).digest("hex")
209
+ name: createHash("sha1")
210
+ .update(pkgVersion)
211
+ .update(ngVersion)
212
+ .update(JSON.stringify(this._parsedTsconfig.options))
213
+ .update(this._workspaceRootPath)
214
+ .update(this._rootPath)
215
+ .update(JSON.stringify(this._config))
216
+ .update(watch.toString())
217
+ .digest("hex")
197
218
  },
219
+ ...watch ? {
220
+ snapshot: {
221
+ immutablePaths: internalModuleCachePaths,
222
+ managedPaths: internalModuleCachePaths
223
+ }
224
+ } : {},
198
225
  node: false,
199
226
  optimization: {
200
- minimizer: [],
227
+ minimizer: watch ? [] : [
228
+ new JavaScriptOptimizerPlugin({
229
+ define: {
230
+ ngDevMode: false,
231
+ ngI18nClosureMode: false,
232
+ ngJitMode: false
233
+ },
234
+ sourcemap: false,
235
+ target: ts.ScriptTarget.ES2017,
236
+ keepIdentifierNames: true,
237
+ keepNames: true,
238
+ removeLicenses: true,
239
+ advanced: true
240
+ }),
241
+ new TransferSizePlugin(),
242
+ new CssOptimizerPlugin({
243
+ supportedBrowsers: browserslist([
244
+ "last 1 Chrome versions",
245
+ "last 2 Edge major versions"
246
+ ], { path: this._workspaceRootPath })
247
+ })
248
+ ] as any[],
201
249
  moduleIds: "deterministic",
202
250
  chunkIds: watch ? "named" : "deterministic",
203
251
  emitOnErrors: watch,
@@ -227,112 +275,6 @@ export class SdCliClientBuilder extends EventEmitter {
227
275
  }
228
276
  }
229
277
  },
230
- plugins: [
231
- new NodePolyfillPlugin(),
232
- new NamedChunksPlugin(),
233
- new DedupeModuleResolvePlugin(),
234
- /*new webpack.ProgressPlugin({
235
- handler: (per: number, msg: string, ...args: string[]) => {
236
- const phaseText = msg ? ` - phase: ${msg}` : "";
237
- const argsText = args.length > 0 ? ` - args: [${args.join(", ")}]` : "";
238
- this._logger.debug(`Webpack 빌드 수행중...(${Math.round(per * 100)}%)${phaseText}${argsText}`);
239
- }
240
- }),*/
241
- new CommonJsUsageWarnPlugin(),
242
- ...watch ? [] : [
243
- new LicenseWebpackPlugin({
244
- stats: { warnings: false, errors: false },
245
- perChunkOutput: false,
246
- outputFilename: "3rdpartylicenses.txt",
247
- skipChildCompilers: true
248
- })
249
- ],
250
- new CopyWebpackPlugin({
251
- patterns: [
252
- ...["favicon.ico", "assets/", "manifest.webmanifest"].map((item) => ({
253
- context: this._rootPath,
254
- to: item,
255
- from: `src/${item}`,
256
- noErrorOnMissing: true,
257
- force: true,
258
- globOptions: {
259
- dot: true,
260
- followSymbolicLinks: false,
261
- ignore: [
262
- ".gitkeep",
263
- "**/.DS_Store",
264
- "**/Thumbs.db"
265
- ].map((i) => PathUtil.posix(this._rootPath, i))
266
- },
267
- priority: 0
268
- }))
269
- ]
270
- }),
271
- ...watch ? [
272
- new webpack.SourceMapDevToolPlugin({
273
- filename: "[file].map",
274
- include: [/js$/, /css$/],
275
- sourceRoot: "webpack:///",
276
- moduleFilenameTemplate: "[resource-path]",
277
- append: undefined
278
- })
279
- ] : [],
280
- new AngularWebpackPlugin({
281
- tsconfig: this._tsconfigFilePath,
282
- compilerOptions: {
283
- sourceMap: watch,
284
- declaration: false,
285
- declarationMap: false,
286
- preserveSymlinks: false
287
- },
288
- jitMode: false,
289
- emitNgModuleScope: watch,
290
- inlineStyleFileExtension: "scss"
291
- }),
292
- new AnyComponentStyleBudgetChecker(watch ? [] : [
293
- { type: Type.AnyComponentStyle, maximumWarning: "2kb", maximumError: "4kb" }
294
- ]),
295
- {
296
- apply: (compiler: webpack.Compiler) => {
297
- compiler.hooks.shutdown.tap("sass-worker", () => {
298
- sassImplementation.close();
299
- });
300
- }
301
- },
302
- new MiniCssExtractPlugin({ filename: "[name].css" }),
303
- new SuppressExtractedTextChunksWebpackPlugin(),
304
- // NgBuildAnalyticsPlugin,
305
- new IndexHtmlWebpackPlugin({
306
- indexPath: path.resolve(this._rootPath, "src/index.html"),
307
- outputPath: "index.html",
308
- baseHref: publicPath,
309
- entrypoints: [
310
- ["runtime", true],
311
- ["polyfills", true],
312
- ["styles", false],
313
- ["vendor", true],
314
- ["main", true]
315
- ],
316
- deployUrl: undefined,
317
- sri: false,
318
- cache: {
319
- enabled: true,
320
- basePath: cacheBasePath,
321
- path: cachePath
322
- },
323
- postTransform: undefined,
324
- optimization: {
325
- scripts: !watch,
326
- styles: { minify: !watch, inlineCritical: !watch },
327
- fonts: { inline: !watch }
328
- },
329
- crossOrigin: "none",
330
- lang: undefined
331
- }),
332
- ...watch ? [
333
- new webpack.HotModuleReplacementPlugin()
334
- ] : []
335
- ] as any[],
336
278
  module: {
337
279
  strictExportPresence: true,
338
280
  parser: { javascript: { url: false, worker: false } },
@@ -370,7 +312,7 @@ export class SdCliClientBuilder extends EventEmitter {
370
312
  loader: "source-map-loader",
371
313
  options: {
372
314
  filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
373
- return !resourcePath.includes("node_modules") || (/@simplysm[\\/]sd/).test(resourcePath);
315
+ return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
374
316
  }
375
317
  }
376
318
  }
@@ -440,7 +382,144 @@ export class SdCliClientBuilder extends EventEmitter {
440
382
  }
441
383
  ] : []
442
384
  ]
443
- }
385
+ },
386
+ plugins: [
387
+ new NodePolyfillPlugin(),
388
+ new NamedChunksPlugin(),
389
+ new DedupeModuleResolvePlugin(),
390
+ /*new webpack.ProgressPlugin({
391
+ handler: (per: number, msg: string, ...args: string[]) => {
392
+ const phaseText = msg ? ` - phase: ${msg}` : "";
393
+ const argsText = args.length > 0 ? ` - args: [${args.join(", ")}]` : "";
394
+ this._logger.debug(`Webpack 빌드 수행중...(${Math.round(per * 100)}%)${phaseText}${argsText}`);
395
+ }
396
+ }),*/
397
+ new CommonJsUsageWarnPlugin(),
398
+ ...watch ? [] : [
399
+ new LicenseWebpackPlugin({
400
+ stats: { warnings: false, errors: false },
401
+ perChunkOutput: false,
402
+ outputFilename: "3rdpartylicenses.txt",
403
+ skipChildCompilers: true
404
+ })
405
+ ],
406
+ new CopyWebpackPlugin({
407
+ patterns: [
408
+ ...["favicon.ico", "assets/", "manifest.webmanifest"].map((item) => ({
409
+ context: this._rootPath,
410
+ to: item,
411
+ from: `src/${item}`,
412
+ noErrorOnMissing: true,
413
+ force: true,
414
+ globOptions: {
415
+ dot: true,
416
+ followSymbolicLinks: false,
417
+ ignore: [
418
+ ".gitkeep",
419
+ "**/.DS_Store",
420
+ "**/Thumbs.db"
421
+ ].map((i) => PathUtil.posix(this._rootPath, i))
422
+ },
423
+ priority: 0
424
+ }))
425
+ ]
426
+ }),
427
+ ...watch ? [
428
+ new webpack.SourceMapDevToolPlugin({
429
+ filename: "[file].map",
430
+ include: [/js$/, /css$/],
431
+ sourceRoot: "webpack:///",
432
+ moduleFilenameTemplate: "[resource-path]",
433
+ append: undefined
434
+ })
435
+ ] : [],
436
+ new AngularWebpackPlugin({
437
+ tsconfig: this._tsconfigFilePath,
438
+ compilerOptions: {
439
+ sourceMap: watch,
440
+ declaration: false,
441
+ declarationMap: false,
442
+ preserveSymlinks: false
443
+ },
444
+ jitMode: false,
445
+ emitNgModuleScope: watch,
446
+ inlineStyleFileExtension: "scss"
447
+ }),
448
+ new AnyComponentStyleBudgetChecker(watch ? [] : [
449
+ { type: Type.AnyComponentStyle, maximumWarning: "2kb", maximumError: "4kb" }
450
+ ]),
451
+ {
452
+ apply: (compiler: webpack.Compiler) => {
453
+ compiler.hooks.shutdown.tap("sass-worker", () => {
454
+ sassImplementation.close();
455
+ });
456
+ }
457
+ },
458
+ new MiniCssExtractPlugin({ filename: "[name].css" }),
459
+ new SuppressExtractedTextChunksWebpackPlugin(),
460
+ // NgBuildAnalyticsPlugin,
461
+ new IndexHtmlWebpackPlugin({
462
+ indexPath: path.resolve(this._rootPath, "src/index.html"),
463
+ outputPath: "index.html",
464
+ baseHref: publicPath,
465
+ entrypoints: [
466
+ ["runtime", true],
467
+ ["polyfills", true],
468
+ ["styles", false],
469
+ ["vendor", true],
470
+ ["main", true]
471
+ ],
472
+ deployUrl: undefined,
473
+ sri: false,
474
+ cache: {
475
+ enabled: true,
476
+ basePath: cacheBasePath,
477
+ path: cachePath
478
+ },
479
+ postTransform: undefined,
480
+ optimization: {
481
+ scripts: !watch,
482
+ styles: { minify: !watch, inlineCritical: !watch },
483
+ fonts: { inline: !watch }
484
+ },
485
+ crossOrigin: "none",
486
+ lang: undefined
487
+ }),
488
+ ...watch ? [
489
+ new webpack.HotModuleReplacementPlugin()
490
+ ] : [],
491
+ new webpack.EnvironmentPlugin({
492
+ SD_VERSION: this._getNpmConfig(this._rootPath)!.version,
493
+ ...this._config.env
494
+ }),
495
+ new ESLintWebpackPlugin({
496
+ context: this._rootPath,
497
+ eslintPath: path.resolve(this._workspaceRootPath, "node_modules", "eslint"),
498
+ exclude: ["node_modules"],
499
+ extensions: ["ts", "js", "mjs", "cjs"],
500
+ fix: false,
501
+ threads: false,
502
+ formatter: (results: LintResult[]) => {
503
+ const resultMessages: string[] = [];
504
+ for (const result of results) {
505
+ for (const msg of result.messages) {
506
+ const severity = msg.severity === 1 ? "warning" : msg.severity === 2 ? "error" : undefined;
507
+ if (severity === undefined) continue;
508
+
509
+ resultMessages.push(SdCliBuildResultUtil.getMessage({
510
+ filePath: result.filePath,
511
+ line: msg.line,
512
+ char: msg.column,
513
+ code: msg.ruleId?.toString(),
514
+ severity,
515
+ message: msg.message
516
+ }));
517
+ }
518
+ }
519
+ return resultMessages.join(os.EOL);
520
+ }
521
+ })
522
+ ] as any[]
444
523
  };
445
524
  }
446
525
 
@@ -1,6 +1,6 @@
1
1
  import { ISdCliPackageBuildResult } from "../commons";
2
2
  import { EventEmitter } from "events";
3
- import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core-node";
3
+ import { FsUtil, Logger, SdFsWatcher } from "@simplysm/sd-core/node";
4
4
  import * as path from "path";
5
5
  import { SdCliPackageLinter } from "../build-tool/SdCliPackageLinter";
6
6
 
@@ -31,8 +31,12 @@ export class SdCliJsLibBuilder extends EventEmitter {
31
31
 
32
32
  this._logger.debug("파일 변경 감지", changeInfos);
33
33
  this.emit("change");
34
+ const watchBuildResults: ISdCliPackageBuildResult[] = [];
34
35
 
35
- const watchBuildResults = await this._linter.lintAsync(changeFilePaths);
36
+ const lintFilePaths = changeInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path);
37
+ if (lintFilePaths.length > 0) {
38
+ watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths));
39
+ }
36
40
 
37
41
  const watchRelatedPaths = await this.getRelatedPathsAsync();
38
42
  watcher.add(watchRelatedPaths);
@@ -1,6 +1,6 @@
1
1
  import { INpmConfig, ISdCliPackageBuildResult, ISdCliServerPackageConfig } from "../commons";
2
2
  import { EventEmitter } from "events";
3
- import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
3
+ import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core/node";
4
4
  import webpack from "webpack";
5
5
  import path from "path";
6
6
  import ts from "typescript";
@@ -9,11 +9,12 @@ import { ErrorInfo } from "ts-loader/dist/interfaces";
9
9
  import os from "os";
10
10
  import { ESLint } from "eslint";
11
11
  import TerserPlugin from "terser-webpack-plugin";
12
- import { ObjectUtil, StringUtil } from "@simplysm/sd-core-common";
12
+ import { ObjectUtil, StringUtil } from "@simplysm/sd-core/common";
13
13
  import ESLintWebpackPlugin from "eslint-webpack-plugin";
14
14
  import CopyWebpackPlugin from "copy-webpack-plugin";
15
15
  import { LicenseWebpackPlugin } from "license-webpack-plugin";
16
16
  import LintResult = ESLint.LintResult;
17
+ import { createHash } from "crypto";
17
18
 
18
19
  export class SdCliServerBuilder extends EventEmitter {
19
20
  private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
@@ -207,6 +208,13 @@ export class SdCliServerBuilder extends EventEmitter {
207
208
  ? FsUtil.findAllParentChildDirPaths("node_modules/!(@simplysm)", this._rootPath, this._workspaceRootPath)
208
209
  : undefined;
209
210
 
211
+ const npmConfig = this._getNpmConfig(this._rootPath)!;
212
+ const pkgKey = npmConfig.name.split("/").last()!;
213
+ const pkgVersion = npmConfig.version;
214
+
215
+ const cacheBasePath = path.resolve(this._rootPath, ".cache");
216
+ const cachePath = path.resolve(cacheBasePath, pkgVersion);
217
+
210
218
  return {
211
219
  mode: watch ? "development" : "production",
212
220
  devtool: false,
@@ -216,7 +224,12 @@ export class SdCliServerBuilder extends EventEmitter {
216
224
  roots: [this._rootPath],
217
225
  extensions: [".ts", ".js", ".mjs", ".cjs"],
218
226
  symlinks: true,
219
- mainFields: ["es2020", "default", "module", "main"]
227
+ modules: [this._workspaceRootPath, "node_modules"],
228
+ mainFields: ["es2020", "default", "module", "main"],
229
+ conditionNames: ["es2020", "..."]
230
+ },
231
+ resolveLoader: {
232
+ symlinks: true
220
233
  },
221
234
  context: this._workspaceRootPath,
222
235
  entry: {
@@ -225,6 +238,8 @@ export class SdCliServerBuilder extends EventEmitter {
225
238
  ]
226
239
  },
227
240
  output: {
241
+ uniqueName: pkgKey,
242
+ hashFunction: "xxhash64",
228
243
  clean: true,
229
244
  path: this._parsedTsconfig.options.outDir,
230
245
  filename: "[name].mjs",
@@ -232,46 +247,57 @@ export class SdCliServerBuilder extends EventEmitter {
232
247
  assetModuleFilename: "res/[name][ext][query]",
233
248
  libraryTarget: "module"
234
249
  },
250
+ watch: false,
251
+ watchOptions: { poll: undefined, ignored: undefined },
252
+ performance: { hints: false },
235
253
  experiments: {
236
254
  outputModule: true
237
255
  },
238
- performance: { hints: false },
239
- node: {
240
- __dirname: true
241
- },
256
+ infrastructureLogging: { level: "error" },
242
257
  stats: "errors-warnings",
243
258
  externals: extModuleNames,
259
+ cache: {
260
+ type: "filesystem",
261
+ profile: watch ? undefined : false,
262
+ cacheDirectory: path.resolve(cachePath, "server-webpack"),
263
+ maxMemoryGenerations: 1,
264
+ name: createHash("sha1")
265
+ .update(pkgVersion)
266
+ .update(JSON.stringify(this._parsedTsconfig.options))
267
+ .update(this._workspaceRootPath)
268
+ .update(this._rootPath)
269
+ .update(JSON.stringify(this._config))
270
+ .update(watch.toString())
271
+ .digest("hex")
272
+ },
244
273
  ...watch ? {
245
- cache: { type: "memory", maxGenerations: 1 },
246
274
  snapshot: {
247
275
  immutablePaths: internalModuleCachePaths,
248
276
  managedPaths: internalModuleCachePaths
249
277
  }
250
- } : {
251
- cache: false
278
+ } : {},
279
+ node: {
280
+ __dirname: true
252
281
  },
253
282
  optimization: {
254
- ...watch ? {} : {
255
- minimize: true,
256
- minimizer: [
257
- new TerserPlugin({
258
- extractComments: false,
259
- terserOptions: {
260
- compress: true,
261
- ecma: 2020,
262
- sourceMap: false,
263
- keep_classnames: true,
264
- keep_fnames: true,
265
- ie8: false,
266
- safari10: false,
267
- module: true,
268
- format: {
269
- comments: false
270
- }
283
+ minimizer: watch ? [
284
+ new TerserPlugin({
285
+ extractComments: false,
286
+ terserOptions: {
287
+ compress: true,
288
+ ecma: 2020,
289
+ sourceMap: false,
290
+ keep_classnames: true,
291
+ keep_fnames: true,
292
+ ie8: false,
293
+ safari10: false,
294
+ module: true,
295
+ format: {
296
+ comments: false
271
297
  }
272
- })
273
- ]
274
- },
298
+ }
299
+ })
300
+ ] : [],
275
301
  moduleIds: "deterministic",
276
302
  chunkIds: watch ? "named" : "deterministic",
277
303
  emitOnErrors: watch
@@ -280,7 +306,7 @@ export class SdCliServerBuilder extends EventEmitter {
280
306
  strictExportPresence: true,
281
307
  rules: [
282
308
  {
283
- test: /\.m?js/,
309
+ test: /\.[cm]?[tj]sx?$/,
284
310
  resolve: {
285
311
  fullySpecified: false
286
312
  }
@@ -292,13 +318,13 @@ export class SdCliServerBuilder extends EventEmitter {
292
318
  loader: "source-map-loader",
293
319
  options: {
294
320
  filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
295
- return !resourcePath.includes("node_modules") || (/@simplysm[\\/]sd/).test(resourcePath);
321
+ return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
296
322
  }
297
323
  }
298
324
  }
299
325
  ] : [],
300
326
  {
301
- test: /\.ts$/,
327
+ test: /\.[cm]?tsx?$/,
302
328
  exclude: /node_modules/,
303
329
  loader: "ts-loader",
304
330
  options: {
@@ -1,7 +1,7 @@
1
1
  import { INpmConfig, ISdCliPackageBuildResult } from "../commons";
2
2
  import { EventEmitter } from "events";
3
3
  import ts from "typescript";
4
- import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
4
+ import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core/node";
5
5
  import * as path from "path";
6
6
  import { createHash } from "crypto";
7
7
  import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
@@ -78,15 +78,20 @@ export class SdCliTsLibBuilder extends EventEmitter {
78
78
  this._fileCache.delete(PathUtil.posix(changeFilePath));
79
79
  }
80
80
 
81
+ const watchBuildResults: ISdCliPackageBuildResult[] = [];
82
+
81
83
  // 빌드
82
84
  const watchBuildPack = this._createSdBuildPack(this._parsedTsconfig);
85
+ watchBuildResults.push(...await this._runBuilderAsync(watchBuildPack.builder, watchBuildPack.ngCompiler));
83
86
 
84
87
  // 린트
85
- const watchBuildResults = await this._runBuilderAsync(watchBuildPack.builder, watchBuildPack.ngCompiler);
86
- watchBuildResults.push(...await this._linter.lintAsync([
88
+ const lintFilePaths = [
87
89
  ...watchBuildPack.affectedSourceFiles.map((item) => item.fileName),
88
- ...changeFilePaths
89
- ], watchBuildPack.program));
90
+ ...changeInfos.filter((item) => ["add", "change"].includes(item.event)).map((item) => item.path)
91
+ ];
92
+ if (lintFilePaths.length > 0) {
93
+ watchBuildResults.push(...await this._linter.lintAsync(lintFilePaths, watchBuildPack.program));
94
+ }
90
95
 
91
96
  const watchRelatedPaths = await this.getAllRelatedPathsAsync();
92
97
  watcher.add(watchRelatedPaths);
package/src/commons.ts CHANGED
@@ -58,4 +58,5 @@ export interface ISdCliServerPackageConfig {
58
58
  export interface ISdCliClientPackageConfig {
59
59
  type: "client";
60
60
  server: string;
61
+ env?: Record<string, string>;
61
62
  }
@@ -1,5 +1,5 @@
1
1
  import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
2
- import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
2
+ import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core/node";
3
3
  import * as path from "path";
4
4
 
5
5
  export class SdCliLocalUpdate {
@@ -1,4 +1,4 @@
1
- import { Logger, SdProcess } from "@simplysm/sd-core-node";
1
+ import { Logger, SdProcess } from "@simplysm/sd-core/node";
2
2
  import { SdCliPrepare } from "./SdCliPrepare";
3
3
 
4
4
  export class SdCliNpm {
@@ -1,4 +1,4 @@
1
- import { FsUtil, Logger } from "@simplysm/sd-core-node";
1
+ import { FsUtil, Logger } from "@simplysm/sd-core/node";
2
2
  import { fileURLToPath } from "url";
3
3
 
4
4
  export class SdCliPrepare {
@@ -1,8 +1,8 @@
1
- import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core-node";
1
+ import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core/node";
2
2
  import path from "path";
3
3
  import { INpmConfig, ISdCliConfig, ISdCliPackageBuildResult } from "../commons";
4
4
  import { SdCliPackage } from "../packages/SdCliPackage";
5
- import { Uuid, Wait } from "@simplysm/sd-core-common";
5
+ import { Uuid, Wait } from "@simplysm/sd-core/common";
6
6
  import os from "os";
7
7
  import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
8
8
  import semver from "semver/preload";
@@ -252,6 +252,7 @@ export class SdCliWorkspace {
252
252
  throw new Error("최상위 'package.json'에서 'workspaces'를 찾을 수 없습니다.");
253
253
  }
254
254
 
255
+
255
256
  return pkgRootPaths.map((pkgRootPath) => {
256
257
  const pkgConfig = conf.packages[path.basename(pkgRootPath)];
257
258
  return pkgConfig ? new SdCliPackage(this._rootPath, pkgRootPath, pkgConfig) : undefined;
@@ -1,8 +1,8 @@
1
1
  import { INpmConfig, ISdCliPackageBuildResult, ITsconfig, TSdCliPackageConfig } from "../commons";
2
2
  import path from "path";
3
- import { FsUtil, SdProcess } from "@simplysm/sd-core-node";
3
+ import { FsUtil, SdProcess } from "@simplysm/sd-core/node";
4
4
  import { EventEmitter } from "events";
5
- import { ObjectUtil } from "@simplysm/sd-core-common";
5
+ import { ObjectUtil } from "@simplysm/sd-core/common";
6
6
  import { SdCliTsLibBuilder } from "../builder/SdCliTsLibBuilder";
7
7
  import { SdCliJsLibBuilder } from "../builder/SdCliJsLibBuilder";
8
8
  import { SdCliServerBuilder } from "../builder/SdCliServerBuilder";
@@ -1,6 +1,6 @@
1
1
  import { ISdCliConfig, TSdCliPackageConfig } from "../commons";
2
- import { FsUtil } from "@simplysm/sd-core-node";
3
- import { ObjectUtil } from "@simplysm/sd-core-common";
2
+ import { FsUtil } from "@simplysm/sd-core/node";
3
+ import { ObjectUtil } from "@simplysm/sd-core/common";
4
4
  import path from "path";
5
5
 
6
6
  export class SdCliConfigUtil {
package/tsconfig.json CHANGED
@@ -7,14 +7,11 @@
7
7
  "outDir": "./dist",
8
8
  "baseUrl": ".",
9
9
  "paths": {
10
- "@simplysm/sd-core-node": [
11
- "../sd-core-node/src/index.ts"
10
+ "@simplysm/sd-core/*": [
11
+ "../sd-core/src/*/index.ts"
12
12
  ],
13
- "@simplysm/sd-core-common": [
14
- "../sd-core-common/src/index.ts"
15
- ],
16
- "@simplysm/sd-service/server": [
17
- "../sd-service/src/server/index.ts"
13
+ "@simplysm/sd-service/*": [
14
+ "../sd-service/src/*/index.ts"
18
15
  ]
19
16
  }
20
17
  }