@simplysm/sd-cli 7.0.41 → 7.0.49
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.
- package/dist/bin/sd-cli.mjs +1 -1
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +1 -1
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +1 -1
- package/dist/build-tool/SdCliPackageLinter.mjs +1 -1
- package/dist/builder/SdCliClientBuilder.mjs +189 -114
- package/dist/builder/SdCliJsLibBuilder.mjs +7 -3
- package/dist/builder/SdCliServerBuilder.mjs +63 -45
- package/dist/builder/SdCliTsLibBuilder.mjs +10 -6
- package/dist/commons.d.ts +1 -0
- package/dist/entry-points/SdCliLocalUpdate.mjs +1 -1
- package/dist/entry-points/SdCliNpm.mjs +1 -1
- package/dist/entry-points/SdCliPrepare.mjs +1 -1
- package/dist/entry-points/SdCliWorkspace.mjs +3 -3
- package/dist/packages/SdCliPackage.mjs +2 -2
- package/dist/utils/SdCliConfigUtil.mjs +2 -2
- package/package.json +3 -4
- package/src/bin/sd-cli.ts +1 -1
- package/src/build-tool/SdCliCacheCompilerHost.ts +1 -1
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +1 -1
- package/src/build-tool/SdCliPackageLinter.ts +1 -1
- package/src/builder/SdCliClientBuilder.ts +191 -112
- package/src/builder/SdCliJsLibBuilder.ts +6 -2
- package/src/builder/SdCliServerBuilder.ts +64 -44
- package/src/builder/SdCliTsLibBuilder.ts +10 -5
- package/src/commons.ts +1 -0
- package/src/entry-points/SdCliLocalUpdate.ts +1 -1
- package/src/entry-points/SdCliNpm.ts +1 -1
- package/src/entry-points/SdCliPrepare.ts +1 -1
- package/src/entry-points/SdCliWorkspace.ts +3 -2
- package/src/packages/SdCliPackage.ts +2 -2
- package/src/utils/SdCliConfigUtil.ts +2 -2
- 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
|
|
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, ".
|
|
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")
|
|
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[\\/]
|
|
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
|
|
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
|
|
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
|
|
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,10 +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
|
|
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
|
+
import { createHash } from "crypto";
|
|
17
|
+
import { SdCliNpmConfigUtil } from "../utils/SdCliNpmConfigUtil";
|
|
16
18
|
import LintResult = ESLint.LintResult;
|
|
17
19
|
|
|
18
20
|
export class SdCliServerBuilder extends EventEmitter {
|
|
@@ -207,6 +209,13 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
207
209
|
? FsUtil.findAllParentChildDirPaths("node_modules/!(@simplysm)", this._rootPath, this._workspaceRootPath)
|
|
208
210
|
: undefined;
|
|
209
211
|
|
|
212
|
+
const npmConfig = this._getNpmConfig(this._rootPath)!;
|
|
213
|
+
const pkgKey = npmConfig.name.split("/").last()!;
|
|
214
|
+
const pkgVersion = npmConfig.version;
|
|
215
|
+
|
|
216
|
+
const cacheBasePath = path.resolve(this._rootPath, ".cache");
|
|
217
|
+
const cachePath = path.resolve(cacheBasePath, pkgVersion);
|
|
218
|
+
|
|
210
219
|
return {
|
|
211
220
|
mode: watch ? "development" : "production",
|
|
212
221
|
devtool: false,
|
|
@@ -216,7 +225,12 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
216
225
|
roots: [this._rootPath],
|
|
217
226
|
extensions: [".ts", ".js", ".mjs", ".cjs"],
|
|
218
227
|
symlinks: true,
|
|
219
|
-
|
|
228
|
+
modules: [this._workspaceRootPath, "node_modules"],
|
|
229
|
+
mainFields: ["es2020", "default", "module", "main"],
|
|
230
|
+
conditionNames: ["es2020", "..."]
|
|
231
|
+
},
|
|
232
|
+
resolveLoader: {
|
|
233
|
+
symlinks: true
|
|
220
234
|
},
|
|
221
235
|
context: this._workspaceRootPath,
|
|
222
236
|
entry: {
|
|
@@ -225,6 +239,8 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
225
239
|
]
|
|
226
240
|
},
|
|
227
241
|
output: {
|
|
242
|
+
uniqueName: pkgKey,
|
|
243
|
+
hashFunction: "xxhash64",
|
|
228
244
|
clean: true,
|
|
229
245
|
path: this._parsedTsconfig.options.outDir,
|
|
230
246
|
filename: "[name].mjs",
|
|
@@ -232,46 +248,57 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
232
248
|
assetModuleFilename: "res/[name][ext][query]",
|
|
233
249
|
libraryTarget: "module"
|
|
234
250
|
},
|
|
251
|
+
watch: false,
|
|
252
|
+
watchOptions: { poll: undefined, ignored: undefined },
|
|
253
|
+
performance: { hints: false },
|
|
235
254
|
experiments: {
|
|
236
255
|
outputModule: true
|
|
237
256
|
},
|
|
238
|
-
|
|
239
|
-
node: {
|
|
240
|
-
__dirname: true
|
|
241
|
-
},
|
|
257
|
+
infrastructureLogging: { level: "error" },
|
|
242
258
|
stats: "errors-warnings",
|
|
243
|
-
externals: extModuleNames,
|
|
259
|
+
externals: extModuleNames.toObject((item) => item, (item) => "commonjs2 " + item),
|
|
260
|
+
cache: {
|
|
261
|
+
type: "filesystem",
|
|
262
|
+
profile: watch ? undefined : false,
|
|
263
|
+
cacheDirectory: path.resolve(cachePath, "server-webpack"),
|
|
264
|
+
maxMemoryGenerations: 1,
|
|
265
|
+
name: createHash("sha1")
|
|
266
|
+
.update(pkgVersion)
|
|
267
|
+
.update(JSON.stringify(this._parsedTsconfig.options))
|
|
268
|
+
.update(this._workspaceRootPath)
|
|
269
|
+
.update(this._rootPath)
|
|
270
|
+
.update(JSON.stringify(this._config))
|
|
271
|
+
.update(watch.toString())
|
|
272
|
+
.digest("hex")
|
|
273
|
+
},
|
|
244
274
|
...watch ? {
|
|
245
|
-
cache: { type: "memory", maxGenerations: 1 },
|
|
246
275
|
snapshot: {
|
|
247
276
|
immutablePaths: internalModuleCachePaths,
|
|
248
277
|
managedPaths: internalModuleCachePaths
|
|
249
278
|
}
|
|
250
|
-
} : {
|
|
251
|
-
|
|
279
|
+
} : {},
|
|
280
|
+
node: {
|
|
281
|
+
__dirname: true
|
|
252
282
|
},
|
|
253
283
|
optimization: {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
format: {
|
|
269
|
-
comments: false
|
|
270
|
-
}
|
|
284
|
+
minimizer: watch ? [
|
|
285
|
+
new TerserPlugin({
|
|
286
|
+
extractComments: false,
|
|
287
|
+
terserOptions: {
|
|
288
|
+
compress: true,
|
|
289
|
+
ecma: 2020,
|
|
290
|
+
sourceMap: false,
|
|
291
|
+
keep_classnames: true,
|
|
292
|
+
keep_fnames: true,
|
|
293
|
+
ie8: false,
|
|
294
|
+
safari10: false,
|
|
295
|
+
module: true,
|
|
296
|
+
format: {
|
|
297
|
+
comments: false
|
|
271
298
|
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
299
|
+
}
|
|
300
|
+
})
|
|
301
|
+
] : [],
|
|
275
302
|
moduleIds: "deterministic",
|
|
276
303
|
chunkIds: watch ? "named" : "deterministic",
|
|
277
304
|
emitOnErrors: watch
|
|
@@ -280,7 +307,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
280
307
|
strictExportPresence: true,
|
|
281
308
|
rules: [
|
|
282
309
|
{
|
|
283
|
-
test: /\.
|
|
310
|
+
test: /\.[cm]?[tj]sx?$/,
|
|
284
311
|
resolve: {
|
|
285
312
|
fullySpecified: false
|
|
286
313
|
}
|
|
@@ -292,13 +319,13 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
292
319
|
loader: "source-map-loader",
|
|
293
320
|
options: {
|
|
294
321
|
filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
|
|
295
|
-
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]
|
|
322
|
+
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
|
|
296
323
|
}
|
|
297
324
|
}
|
|
298
325
|
}
|
|
299
326
|
] : [],
|
|
300
327
|
{
|
|
301
|
-
test: /\.
|
|
328
|
+
test: /\.[cm]?tsx?$/,
|
|
302
329
|
exclude: /node_modules/,
|
|
303
330
|
loader: "ts-loader",
|
|
304
331
|
options: {
|
|
@@ -399,16 +426,9 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
399
426
|
const npmConfig = this._getNpmConfig(currPath);
|
|
400
427
|
if (!npmConfig) return;
|
|
401
428
|
|
|
402
|
-
const
|
|
403
|
-
...Object.keys(npmConfig.dependencies ?? {}),
|
|
404
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => !npmConfig.peerDependenciesMeta?.[item].optional)
|
|
405
|
-
];
|
|
406
|
-
const optModuleNames = [
|
|
407
|
-
...Object.keys(npmConfig.optionalDependencies ?? {}),
|
|
408
|
-
...Object.keys(npmConfig.peerDependencies ?? {}).filter((item) => npmConfig.peerDependenciesMeta?.[item].optional)
|
|
409
|
-
].distinct();
|
|
429
|
+
const deps = SdCliNpmConfigUtil.getDependencies(npmConfig);
|
|
410
430
|
|
|
411
|
-
for (const moduleName of
|
|
431
|
+
for (const moduleName of deps.defaults) {
|
|
412
432
|
if (loadedModuleNames.includes(moduleName)) continue;
|
|
413
433
|
loadedModuleNames.push(moduleName);
|
|
414
434
|
|
|
@@ -424,7 +444,7 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
424
444
|
fn(modulePath);
|
|
425
445
|
}
|
|
426
446
|
|
|
427
|
-
for (const optModuleName of
|
|
447
|
+
for (const optModuleName of deps.optionals) {
|
|
428
448
|
if (loadedModuleNames.includes(optModuleName)) continue;
|
|
429
449
|
loadedModuleNames.push(optModuleName);
|
|
430
450
|
|
|
@@ -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
|
|
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
|
|
86
|
-
watchBuildResults.push(...await this._linter.lintAsync([
|
|
88
|
+
const lintFilePaths = [
|
|
87
89
|
...watchBuildPack.affectedSourceFiles.map((item) => item.fileName),
|
|
88
|
-
...
|
|
89
|
-
]
|
|
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SdCliConfigUtil } from "../utils/SdCliConfigUtil";
|
|
2
|
-
import { FsUtil, Logger, PathUtil, SdFsWatcher } from "@simplysm/sd-core
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import { FsUtil, Logger, SdProcess } from "@simplysm/sd-core
|
|
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
|
|
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
|
|
3
|
+
import { FsUtil, SdProcess } from "@simplysm/sd-core/node";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
5
|
-
import { ObjectUtil } from "@simplysm/sd-core
|
|
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";
|