@simplysm/sd-cli 7.0.38 → 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.
- package/.eslintrc.cjs +2 -2
- package/dist/bin/sd-cli.mjs +3 -2
- package/dist/build-tool/SdCliCacheCompilerHost.mjs +1 -1
- package/dist/build-tool/SdCliNgCacheCompilerHost.mjs +3 -3
- package/dist/build-tool/SdCliPackageLinter.mjs +1 -1
- package/dist/builder/SdCliClientBuilder.mjs +197 -120
- package/dist/builder/SdCliJsLibBuilder.mjs +7 -3
- package/dist/builder/SdCliServerBuilder.mjs +58 -34
- package/dist/builder/SdCliTsLibBuilder.d.ts +1 -1
- package/dist/builder/SdCliTsLibBuilder.mjs +13 -9
- 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 +5 -5
- package/dist/packages/SdCliPackage.mjs +2 -2
- package/dist/utils/SdCliBuildResultUtil.mjs +2 -2
- package/dist/utils/SdCliConfigUtil.mjs +2 -2
- package/package.json +5 -5
- package/src/bin/sd-cli.ts +2 -1
- package/src/build-tool/SdCliCacheCompilerHost.ts +1 -1
- package/src/build-tool/SdCliNgCacheCompilerHost.ts +3 -3
- package/src/build-tool/SdCliPackageLinter.ts +1 -1
- package/src/builder/SdCliClientBuilder.ts +199 -118
- package/src/builder/SdCliJsLibBuilder.ts +7 -3
- package/src/builder/SdCliServerBuilder.ts +59 -33
- package/src/builder/SdCliTsLibBuilder.ts +14 -9
- 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 +5 -4
- package/src/packages/SdCliPackage.ts +2 -2
- package/src/utils/SdCliBuildResultUtil.ts +1 -1
- package/src/utils/SdCliConfigUtil.ts +2 -2
- package/tsconfig.json +4 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
|
-
import { PathUtil } from "@simplysm/sd-core
|
|
2
|
+
import { PathUtil } from "@simplysm/sd-core/node";
|
|
3
3
|
import sass from "sass";
|
|
4
4
|
import { pathToFileURL, URL } from "url";
|
|
5
5
|
|
|
@@ -25,10 +25,10 @@ export class SdCliNgCacheCompilerHost {
|
|
|
25
25
|
if (cache.styleContent === undefined) {
|
|
26
26
|
cache.styleContent = (
|
|
27
27
|
await sass.compileStringAsync(data, {
|
|
28
|
-
url: new URL(context.containingFile + ".sd.scss"),
|
|
28
|
+
url: new URL((context.containingFile as string) + ".sd.scss"),
|
|
29
29
|
importer: {
|
|
30
30
|
findFileUrl: (url) => {
|
|
31
|
-
if (!url.startsWith("~")) return
|
|
31
|
+
if (!url.startsWith("~")) return pathToFileURL(url);
|
|
32
32
|
return new URL(url.substring(1), pathToFileURL("node_modules"));
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -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,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, ".
|
|
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;
|
|
@@ -156,7 +170,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
156
170
|
entry: {
|
|
157
171
|
main: [
|
|
158
172
|
...watch ? [
|
|
159
|
-
`webpack-hot-middleware/client?path=${publicPath}__webpack_hmr&timeout=20000&reload=true&overlay=true
|
|
173
|
+
`webpack-hot-middleware/client?path=${publicPath}__webpack_hmr&timeout=20000&reload=true&overlay=true`
|
|
160
174
|
] : [],
|
|
161
175
|
mainFilePath
|
|
162
176
|
],
|
|
@@ -174,7 +188,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
174
188
|
libraryTarget: undefined,
|
|
175
189
|
crossOriginLoading: false,
|
|
176
190
|
trustedTypes: "angular#bundler",
|
|
177
|
-
scriptType: "module"
|
|
191
|
+
scriptType: "module"
|
|
178
192
|
},
|
|
179
193
|
watch: false,
|
|
180
194
|
watchOptions: { poll: undefined, ignored: undefined },
|
|
@@ -182,7 +196,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
182
196
|
ignoreWarnings: [
|
|
183
197
|
/Failed to parse source map from/,
|
|
184
198
|
/Add postcss as project dependency/,
|
|
185
|
-
/"@charset" must be the first rule in the file
|
|
199
|
+
/"@charset" must be the first rule in the file/
|
|
186
200
|
],
|
|
187
201
|
experiments: { backCompat: false, syncWebAssembly: true, asyncWebAssembly: true },
|
|
188
202
|
infrastructureLogging: { level: "error" },
|
|
@@ -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")
|
|
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 } },
|
|
@@ -342,7 +286,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
342
286
|
},
|
|
343
287
|
{
|
|
344
288
|
test: /[/\\]rxjs[/\\]add[/\\].+\.js$/,
|
|
345
|
-
sideEffects: true
|
|
289
|
+
sideEffects: true
|
|
346
290
|
},
|
|
347
291
|
{
|
|
348
292
|
test: /\.[cm]?[tj]sx?$/,
|
|
@@ -359,7 +303,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
359
303
|
instrumentCode: undefined
|
|
360
304
|
}
|
|
361
305
|
}
|
|
362
|
-
]
|
|
306
|
+
]
|
|
363
307
|
},
|
|
364
308
|
...watch ? [
|
|
365
309
|
{
|
|
@@ -367,8 +311,8 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
367
311
|
enforce: "pre" as const,
|
|
368
312
|
loader: "source-map-loader",
|
|
369
313
|
options: {
|
|
370
|
-
filterSourceMappingUrl: (
|
|
371
|
-
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]
|
|
314
|
+
filterSourceMappingUrl: (mapUri: string, resourcePath: string) => {
|
|
315
|
+
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
|
|
372
316
|
}
|
|
373
317
|
}
|
|
374
318
|
}
|
|
@@ -376,7 +320,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
376
320
|
{
|
|
377
321
|
test: /\.[cm]?tsx?$/,
|
|
378
322
|
loader: "@ngtools/webpack",
|
|
379
|
-
exclude: [/[/\\](?:css-loader|mini-css-extract-plugin|webpack-dev-server|webpack)[/\\]/]
|
|
323
|
+
exclude: [/[/\\](?:css-loader|mini-css-extract-plugin|webpack-dev-server|webpack)[/\\]/]
|
|
380
324
|
},
|
|
381
325
|
{
|
|
382
326
|
test: /\.css$/i,
|
|
@@ -439,6 +383,143 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
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
|
|
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
|
|
|
@@ -27,12 +27,16 @@ export class SdCliJsLibBuilder extends EventEmitter {
|
|
|
27
27
|
const watcher = SdFsWatcher.watch(relatedPaths);
|
|
28
28
|
watcher.onChange({}, async (changeInfos) => {
|
|
29
29
|
const changeFilePaths = changeInfos.filter((item) => ["add", "change", "unlink"].includes(item.event)).map((item) => item.path);
|
|
30
|
-
if(changeFilePaths.length === 0) return;
|
|
30
|
+
if (changeFilePaths.length === 0) return;
|
|
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,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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
278
|
+
} : {},
|
|
279
|
+
node: {
|
|
280
|
+
__dirname: true
|
|
252
281
|
},
|
|
253
282
|
optimization: {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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: /\.
|
|
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[\\/]
|
|
321
|
+
return !resourcePath.includes("node_modules") || (/@simplysm[\\/]/).test(resourcePath);
|
|
296
322
|
}
|
|
297
323
|
}
|
|
298
324
|
}
|
|
299
325
|
] : [],
|
|
300
326
|
{
|
|
301
|
-
test: /\.
|
|
327
|
+
test: /\.[cm]?tsx?$/,
|
|
302
328
|
exclude: /node_modules/,
|
|
303
329
|
loader: "ts-loader",
|
|
304
330
|
options: {
|