@simplysm/sd-cli 7.0.39 → 7.0.46

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 +191 -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 +5 -5
  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 +193 -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,13 +10,13 @@ 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";
16
17
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
17
18
  import { AngularWebpackPlugin } from "@ngtools/webpack";
18
19
  import { IndexHtmlWebpackPlugin } from "@angular-devkit/build-angular/src/webpack/plugins/index-html-webpack-plugin";
19
- import { createHash } from "crypto";
20
20
  import { SassWorkerImplementation } from "@angular-devkit/build-angular/src/sass/sass-service";
21
21
  import { HmrLoader } from "@angular-devkit/build-angular/src/webpack/plugins/hmr/hmr-loader";
22
22
  import wdm from "webpack-dev-middleware";
@@ -24,6 +24,15 @@ import whm from "webpack-hot-middleware";
24
24
  import { NextHandleFunction } from "connect";
25
25
  import { LicenseWebpackPlugin } from "license-webpack-plugin";
26
26
  import { Type } from "@angular-devkit/build-angular";
27
+ import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
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;
27
36
 
28
37
  export class SdCliClientBuilder extends EventEmitter {
29
38
  private readonly _logger = Logger.get(["simplysm", "sd-cli", this.constructor.name]);
@@ -119,13 +128,18 @@ export class SdCliClientBuilder extends EventEmitter {
119
128
  }
120
129
 
121
130
  private _getWebpackConfig(watch: boolean): webpack.Configuration {
131
+ const internalModuleCachePaths = watch
132
+ ? FsUtil.findAllParentChildDirPaths("node_modules/!(@simplysm)", this._rootPath, this._workspaceRootPath)
133
+ : undefined;
134
+
122
135
  const npmConfig = this._getNpmConfig(this._rootPath)!;
123
136
  const pkgVersion = npmConfig.version;
137
+ const ngVersion = this._getNpmConfig(FsUtil.findAllParentChildDirPaths("node_modules/@angular/core", this._rootPath, this._workspaceRootPath)[0])!.version;
124
138
 
125
139
  const pkgKey = npmConfig.name.split("/").last()!;
126
140
  const publicPath = `/${pkgKey}/`;
127
141
 
128
- const cacheBasePath = path.resolve(this._rootPath, ".angular");
142
+ const cacheBasePath = path.resolve(this._rootPath, ".cache");
129
143
  const cachePath = path.resolve(cacheBasePath, pkgVersion);
130
144
 
131
145
  const distPath = this._parsedTsconfig.options.outDir;
@@ -192,11 +206,46 @@ export class SdCliClientBuilder extends EventEmitter {
192
206
  profile: watch ? undefined : false,
193
207
  cacheDirectory: path.resolve(cachePath, "angular-webpack"),
194
208
  maxMemoryGenerations: 1,
195
- 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")
196
218
  },
219
+ ...watch ? {
220
+ snapshot: {
221
+ immutablePaths: internalModuleCachePaths,
222
+ managedPaths: internalModuleCachePaths
223
+ }
224
+ } : {},
197
225
  node: false,
198
226
  optimization: {
199
- 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[],
200
249
  moduleIds: "deterministic",
201
250
  chunkIds: watch ? "named" : "deterministic",
202
251
  emitOnErrors: watch,
@@ -226,111 +275,6 @@ export class SdCliClientBuilder extends EventEmitter {
226
275
  }
227
276
  }
228
277
  },
229
- plugins: [
230
- new NamedChunksPlugin(),
231
- new DedupeModuleResolvePlugin(),
232
- /*new webpack.ProgressPlugin({
233
- handler: (per: number, msg: string, ...args: string[]) => {
234
- const phaseText = msg ? ` - phase: ${msg}` : "";
235
- const argsText = args.length > 0 ? ` - args: [${args.join(", ")}]` : "";
236
- this._logger.debug(`Webpack 빌드 수행중...(${Math.round(per * 100)}%)${phaseText}${argsText}`);
237
- }
238
- }),*/
239
- new CommonJsUsageWarnPlugin(),
240
- ...watch ? [] : [
241
- new LicenseWebpackPlugin({
242
- stats: { warnings: false, errors: false },
243
- perChunkOutput: false,
244
- outputFilename: "3rdpartylicenses.txt",
245
- skipChildCompilers: true
246
- })
247
- ],
248
- new CopyWebpackPlugin({
249
- patterns: [
250
- ...["favicon.ico", "assets/", "manifest.webmanifest"].map((item) => ({
251
- context: this._rootPath,
252
- to: item,
253
- from: `src/${item}`,
254
- noErrorOnMissing: true,
255
- force: true,
256
- globOptions: {
257
- dot: true,
258
- followSymbolicLinks: false,
259
- ignore: [
260
- ".gitkeep",
261
- "**/.DS_Store",
262
- "**/Thumbs.db"
263
- ].map((i) => PathUtil.posix(this._rootPath, i))
264
- },
265
- priority: 0
266
- }))
267
- ]
268
- }),
269
- ...watch ? [
270
- new webpack.SourceMapDevToolPlugin({
271
- filename: "[file].map",
272
- include: [/js$/, /css$/],
273
- sourceRoot: "webpack:///",
274
- moduleFilenameTemplate: "[resource-path]",
275
- append: undefined
276
- })
277
- ] : [],
278
- new AngularWebpackPlugin({
279
- tsconfig: this._tsconfigFilePath,
280
- compilerOptions: {
281
- sourceMap: watch,
282
- declaration: false,
283
- declarationMap: false,
284
- preserveSymlinks: false
285
- },
286
- jitMode: false,
287
- emitNgModuleScope: watch,
288
- inlineStyleFileExtension: "scss"
289
- }),
290
- new AnyComponentStyleBudgetChecker(watch ? [] : [
291
- { type: Type.AnyComponentStyle, maximumWarning: "2kb", maximumError: "4kb" }
292
- ]),
293
- {
294
- apply: (compiler: webpack.Compiler) => {
295
- compiler.hooks.shutdown.tap("sass-worker", () => {
296
- sassImplementation.close();
297
- });
298
- }
299
- },
300
- new MiniCssExtractPlugin({ filename: "[name].css" }),
301
- new SuppressExtractedTextChunksWebpackPlugin(),
302
- // NgBuildAnalyticsPlugin,
303
- new IndexHtmlWebpackPlugin({
304
- indexPath: path.resolve(this._rootPath, "src/index.html"),
305
- outputPath: "index.html",
306
- baseHref: publicPath,
307
- entrypoints: [
308
- ["runtime", true],
309
- ["polyfills", true],
310
- ["styles", false],
311
- ["vendor", true],
312
- ["main", true]
313
- ],
314
- deployUrl: undefined,
315
- sri: false,
316
- cache: {
317
- enabled: true,
318
- basePath: cacheBasePath,
319
- path: cachePath
320
- },
321
- postTransform: undefined,
322
- optimization: {
323
- scripts: !watch,
324
- styles: { minify: !watch, inlineCritical: !watch },
325
- fonts: { inline: !watch }
326
- },
327
- crossOrigin: "none",
328
- lang: undefined
329
- }),
330
- ...watch ? [
331
- new webpack.HotModuleReplacementPlugin()
332
- ] : []
333
- ] as any[],
334
278
  module: {
335
279
  strictExportPresence: true,
336
280
  parser: { javascript: { url: false, worker: false } },
@@ -368,7 +312,7 @@ export class SdCliClientBuilder extends EventEmitter {
368
312
  loader: "source-map-loader",
369
313
  options: {
370
314
  filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
371
- return !resourcePath.includes("node_modules") || (/@simplysm[\\/]sd/).test(resourcePath);
315
+ return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
372
316
  }
373
317
  }
374
318
  }
@@ -438,7 +382,144 @@ export class SdCliClientBuilder extends EventEmitter {
438
382
  }
439
383
  ] : []
440
384
  ]
441
- }
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[]
442
523
  };
443
524
  }
444
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 {