@simplysm/sd-cli 12.5.19 → 12.5.20
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/build-tools/SdNgBundler.d.ts +1 -0
- package/dist/build-tools/SdNgBundler.js +70 -57
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdServerBundler.d.ts +1 -0
- package/dist/build-tools/SdServerBundler.js +8 -7
- package/dist/build-tools/SdServerBundler.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +1 -0
- package/dist/build-tools/SdTsCompiler.js +355 -327
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +1 -1
- package/dist/build-tools/SdTsLibBundler.js +2 -1
- package/dist/build-tools/SdTsLibBundler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +2 -1
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.js +2 -1
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +4 -2
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +1 -0
- package/dist/bundle-plugins/sdNgPlugin.js +38 -23
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +1 -0
- package/dist/bundle-plugins/sdServerPlugin.js +1 -0
- package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
- package/dist/entry/SdCliProject.js +7 -4
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/SdCliPerformanceTime.d.ts +9 -0
- package/dist/utils/SdCliPerformanceTime.js +40 -0
- package/dist/utils/SdCliPerformanceTime.js.map +1 -0
- package/package.json +10 -10
- package/src/build-tools/SdNgBundler.ts +82 -68
- package/src/build-tools/SdServerBundler.ts +22 -20
- package/src/build-tools/SdTsCompiler.ts +341 -357
- package/src/build-tools/SdTsLibBundler.ts +2 -1
- package/src/builders/SdCliClientBuilder.ts +5 -3
- package/src/builders/SdCliServerBuilder.ts +5 -4
- package/src/builders/SdCliTsLibBuilder.ts +7 -4
- package/src/bundle-plugins/sdNgPlugin.ts +44 -23
- package/src/bundle-plugins/sdServerPlugin.ts +2 -0
- package/src/entry/SdCliProject.ts +6 -4
- package/src/index.ts +1 -0
- package/src/utils/SdCliPerformanceTime.ts +42 -0
- package/tsconfig.json +1 -1
|
@@ -10,7 +10,7 @@ export class SdTsLibBundler {
|
|
|
10
10
|
|
|
11
11
|
readonly #pkgPath: string;
|
|
12
12
|
|
|
13
|
-
public constructor(pkgPath: string, dev: boolean) {
|
|
13
|
+
public constructor(pkgPath: string, dev: boolean, watchScopePaths: string[]) {
|
|
14
14
|
this.#pkgPath = pkgPath;
|
|
15
15
|
this.#compiler = new SdTsCompiler({
|
|
16
16
|
pkgPath,
|
|
@@ -18,6 +18,7 @@ export class SdTsLibBundler {
|
|
|
18
18
|
isDevMode: dev,
|
|
19
19
|
globalStyleFilePath: path.resolve(pkgPath, "src/styles.scss"),
|
|
20
20
|
isForBundle: false,
|
|
21
|
+
watchScopePaths: watchScopePaths,
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -116,6 +116,10 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
116
116
|
affectedFileSet: Set<string>;
|
|
117
117
|
buildResults: ISdCliPackageBuildResult[];
|
|
118
118
|
}> {
|
|
119
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
120
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
121
|
+
);
|
|
122
|
+
|
|
119
123
|
const builderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as ("web" | "electron" | "cordova")[];
|
|
120
124
|
if (this._pkgConf.builder?.cordova && !this._cordova) {
|
|
121
125
|
this._debug("CORDOVA 준비...");
|
|
@@ -148,6 +152,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
148
152
|
...this._pkgConf.builder?.[builderType]?.env,
|
|
149
153
|
},
|
|
150
154
|
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
155
|
+
watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths],
|
|
151
156
|
}),
|
|
152
157
|
);
|
|
153
158
|
}
|
|
@@ -184,9 +189,6 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
this._debug(`빌드 완료`);
|
|
187
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
188
|
-
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
189
|
-
);
|
|
190
192
|
const currWatchFileSet = new Set(
|
|
191
193
|
Array.from(watchFileSet).filter(
|
|
192
194
|
(item) =>
|
|
@@ -219,6 +219,10 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
219
219
|
affectedFileSet: Set<string>;
|
|
220
220
|
buildResults: ISdCliPackageBuildResult[];
|
|
221
221
|
}> {
|
|
222
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
223
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
224
|
+
);
|
|
225
|
+
|
|
222
226
|
this._debug(`BUILD 준비...`);
|
|
223
227
|
const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
224
228
|
this.#extModules = this.#extModules ?? (await this._getExternalModulesAsync());
|
|
@@ -231,16 +235,13 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
231
235
|
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
232
236
|
: [path.resolve(this._pkgPath, "src/main.ts")],
|
|
233
237
|
external: this.#extModules.map((item) => item.name),
|
|
238
|
+
watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths],
|
|
234
239
|
});
|
|
235
240
|
|
|
236
241
|
this._debug(`BUILD & CHECK...`);
|
|
237
242
|
const buildResult = await this.#builder.bundleAsync();
|
|
238
243
|
|
|
239
244
|
//-- filePaths
|
|
240
|
-
|
|
241
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
242
|
-
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
243
|
-
);
|
|
244
245
|
const watchFileSet = new Set(
|
|
245
246
|
Array.from(buildResult.watchFileSet).filter(
|
|
246
247
|
(item) =>
|
|
@@ -88,8 +88,14 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
88
88
|
affectedFileSet: Set<string>;
|
|
89
89
|
buildResults: ISdCliPackageBuildResult[];
|
|
90
90
|
}> {
|
|
91
|
+
const localUpdatePaths = Object.keys(this.#projConf.localUpdates ?? {}).mapMany((key) =>
|
|
92
|
+
FsUtil.glob(path.resolve(this.#pkgPath, "../../node_modules", key)),
|
|
93
|
+
);
|
|
94
|
+
|
|
91
95
|
this._debug(`BUILD...`);
|
|
92
|
-
this.#bundler =
|
|
96
|
+
this.#bundler =
|
|
97
|
+
this.#bundler ??
|
|
98
|
+
new SdTsLibBundler(this.#pkgPath, dev, [path.resolve(this.#pkgPath, "../"), ...localUpdatePaths]);
|
|
93
99
|
const buildResult = await this.#bundler.buildAsync();
|
|
94
100
|
|
|
95
101
|
this._debug("LINT...");
|
|
@@ -99,9 +105,6 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
99
105
|
const lintResults = await SdLinter.lintAsync(this.#pkgPath, buildResult.affectedFileSet, buildResult.program);
|
|
100
106
|
|
|
101
107
|
this._debug(`빌드 완료`);
|
|
102
|
-
const localUpdatePaths = Object.keys(this.#projConf.localUpdates ?? {}).mapMany((key) =>
|
|
103
|
-
FsUtil.glob(path.resolve(this.#pkgPath, "../../node_modules", key)),
|
|
104
|
-
);
|
|
105
108
|
const watchFileSet = new Set(
|
|
106
109
|
Array.from(buildResult.watchFileSet).filter(
|
|
107
110
|
(item) =>
|
|
@@ -5,13 +5,23 @@ import os from "os";
|
|
|
5
5
|
import { ISdTsCompilerResult, SdTsCompiler } from "../build-tools/SdTsCompiler";
|
|
6
6
|
import { JavaScriptTransformer } from "@angular/build/src/tools/esbuild/javascript-transformer";
|
|
7
7
|
import { convertTypeScriptDiagnostic } from "@angular/build/src/tools/esbuild/angular/diagnostics";
|
|
8
|
+
import { SdCliPerformanceTimer } from "../utils/SdCliPerformanceTime";
|
|
9
|
+
import { Logger } from "@simplysm/sd-core-node";
|
|
8
10
|
|
|
9
11
|
export function sdNgPlugin(conf: {
|
|
10
12
|
pkgPath: string;
|
|
11
13
|
dev: boolean;
|
|
12
14
|
modifiedFileSet: Set<string>;
|
|
13
15
|
result: INgPluginResultCache;
|
|
16
|
+
watchScopePaths: string[];
|
|
14
17
|
}): esbuild.Plugin {
|
|
18
|
+
let perf: SdCliPerformanceTimer;
|
|
19
|
+
const logger = Logger.get(["simplysm", "sd-cli", "sdNgPlugin"]);
|
|
20
|
+
|
|
21
|
+
function debug(...msg: any[]): void {
|
|
22
|
+
logger.debug(`[${path.basename(conf.pkgPath)}]`, ...msg);
|
|
23
|
+
}
|
|
24
|
+
|
|
15
25
|
return {
|
|
16
26
|
name: "sd-ng-compiler",
|
|
17
27
|
setup: (build: esbuild.PluginBuild) => {
|
|
@@ -20,6 +30,7 @@ export function sdNgPlugin(conf: {
|
|
|
20
30
|
additionalOptions: { declaration: false },
|
|
21
31
|
isDevMode: conf.dev,
|
|
22
32
|
isForBundle: true,
|
|
33
|
+
watchScopePaths: conf.watchScopePaths,
|
|
23
34
|
});
|
|
24
35
|
|
|
25
36
|
let buildResult: ISdTsCompilerResult;
|
|
@@ -39,32 +50,39 @@ export function sdNgPlugin(conf: {
|
|
|
39
50
|
//---------------------------
|
|
40
51
|
|
|
41
52
|
build.onStart(async () => {
|
|
42
|
-
|
|
43
|
-
for (const modifiedFile of conf.modifiedFileSet) {
|
|
44
|
-
outputContentsCacheMap.delete(modifiedFile);
|
|
45
|
-
}
|
|
53
|
+
perf = new SdCliPerformanceTimer("esbuild");
|
|
46
54
|
|
|
47
|
-
|
|
55
|
+
const res = await perf.run("typescript build", async () => {
|
|
56
|
+
compiler.invalidate(conf.modifiedFileSet);
|
|
57
|
+
for (const modifiedFile of conf.modifiedFileSet) {
|
|
58
|
+
outputContentsCacheMap.delete(modifiedFile);
|
|
59
|
+
}
|
|
48
60
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
buildResult = await compiler.buildAsync();
|
|
62
|
+
|
|
63
|
+
conf.result.watchFileSet = buildResult.watchFileSet;
|
|
64
|
+
conf.result.affectedFileSet = buildResult.affectedFileSet;
|
|
65
|
+
conf.result.program = buildResult.program;
|
|
66
|
+
|
|
67
|
+
//-- return err/warn
|
|
68
|
+
return {
|
|
69
|
+
errors: [
|
|
70
|
+
...buildResult.typescriptDiagnostics
|
|
71
|
+
.filter((item) => item.category === ts.DiagnosticCategory.Error)
|
|
72
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
73
|
+
...Array.from(buildResult.stylesheetBundlingResultMap.values()).flatMap((item) => item.errors),
|
|
74
|
+
].filterExists(),
|
|
75
|
+
warnings: [
|
|
76
|
+
...buildResult.typescriptDiagnostics
|
|
77
|
+
.filter((item) => item.category !== ts.DiagnosticCategory.Error)
|
|
78
|
+
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
79
|
+
// ...Array.from(buildResult.stylesheetResultMap.values()).flatMap(item => item.warnings)
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
});
|
|
52
83
|
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
errors: [
|
|
56
|
-
...buildResult.typescriptDiagnostics
|
|
57
|
-
.filter((item) => item.category === ts.DiagnosticCategory.Error)
|
|
58
|
-
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
59
|
-
...Array.from(buildResult.stylesheetBundlingResultMap.values()).flatMap((item) => item.errors),
|
|
60
|
-
].filterExists(),
|
|
61
|
-
warnings: [
|
|
62
|
-
...buildResult.typescriptDiagnostics
|
|
63
|
-
.filter((item) => item.category !== ts.DiagnosticCategory.Error)
|
|
64
|
-
.map((item) => convertTypeScriptDiagnostic(ts, item)),
|
|
65
|
-
// ...Array.from(buildResult.stylesheetResultMap.values()).flatMap(item => item.warnings)
|
|
66
|
-
],
|
|
67
|
-
};
|
|
84
|
+
perf.start("transform & bundling");
|
|
85
|
+
return res;
|
|
68
86
|
});
|
|
69
87
|
|
|
70
88
|
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
@@ -132,6 +150,9 @@ export function sdNgPlugin(conf: {
|
|
|
132
150
|
);
|
|
133
151
|
|
|
134
152
|
build.onEnd((result) => {
|
|
153
|
+
perf.end("transform & bundling");
|
|
154
|
+
debug(perf.toString());
|
|
155
|
+
|
|
135
156
|
for (const { outputFiles, metafile } of buildResult.stylesheetBundlingResultMap.values()) {
|
|
136
157
|
result.outputFiles = result.outputFiles ?? [];
|
|
137
158
|
result.outputFiles.push(...outputFiles);
|
|
@@ -9,6 +9,7 @@ export function sdServerPlugin(conf: {
|
|
|
9
9
|
dev: boolean;
|
|
10
10
|
modifiedFileSet: Set<string>;
|
|
11
11
|
result: IServerPluginResultCache;
|
|
12
|
+
watchScopePaths: string[];
|
|
12
13
|
}): esbuild.Plugin {
|
|
13
14
|
return {
|
|
14
15
|
name: "sd-server-compiler",
|
|
@@ -18,6 +19,7 @@ export function sdServerPlugin(conf: {
|
|
|
18
19
|
additionalOptions: { declaration: false },
|
|
19
20
|
isDevMode: conf.dev,
|
|
20
21
|
isForBundle: true,
|
|
22
|
+
watchScopePaths: conf.watchScopePaths
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
let buildResult: ISdTsCompilerResult;
|
|
@@ -102,10 +102,10 @@ export class SdCliProject {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
for (const buildResult of message.result!.buildResults) {
|
|
105
|
-
if (buildResult.filePath == null || PathUtil.isChildPath(buildResult.filePath, message.req.pkgPath)) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
105
|
+
// if (buildResult.filePath == null || PathUtil.isChildPath(buildResult.filePath, message.req.pkgPath)) {
|
|
106
|
+
const cacheItem = resultCache.getOrCreate(buildResult.filePath ?? "none", []);
|
|
107
|
+
cacheItem.push(buildResult);
|
|
108
|
+
// }
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
const pkgConf = message.req.projConf.packages[path.basename(message.req.pkgPath)]!;
|
|
@@ -147,6 +147,7 @@ export class SdCliProject {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
serverInfo.pathProxy[pkgName] = path.resolve(message.req.pkgPath, "dist");
|
|
150
|
+
serverInfo.pathProxy["node_modules"] = path.resolve(process.cwd(), "node_modules");
|
|
150
151
|
// serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
151
152
|
|
|
152
153
|
serverInfo.hasClientChanges = true;
|
|
@@ -205,6 +206,7 @@ export class SdCliProject {
|
|
|
205
206
|
for (const serverInfo of serverInfoMap.values()) {
|
|
206
207
|
if (Object.keys(serverInfo.pathProxy).length > 0) {
|
|
207
208
|
for (const proxyPath of Object.keys(serverInfo.pathProxy)) {
|
|
209
|
+
if (proxyPath === "node_modules") continue;
|
|
208
210
|
clientPaths.push(`http://localhost:${serverInfo.port}/${proxyPath}/`);
|
|
209
211
|
}
|
|
210
212
|
} else {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class SdCliPerformanceTimer {
|
|
2
|
+
#startingMap = new Map<string, number>();
|
|
3
|
+
#resultMap = new Map<string, number>();
|
|
4
|
+
|
|
5
|
+
constructor(private _name: string) {}
|
|
6
|
+
|
|
7
|
+
start(name: string) {
|
|
8
|
+
this.#startingMap.set(name, new Date().getTime());
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
end(name: string) {
|
|
12
|
+
const val = this.#startingMap.get(name);
|
|
13
|
+
if (val == null) throw new Error();
|
|
14
|
+
this.#resultMap.set(name, new Date().getTime() - val);
|
|
15
|
+
this.#startingMap.delete(name);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
run<R>(name: string, fn: () => R): R {
|
|
19
|
+
const startTime = new Date().getTime();
|
|
20
|
+
let res = fn();
|
|
21
|
+
if (res instanceof Promise) {
|
|
22
|
+
return res.then((realRes) => {
|
|
23
|
+
const duration = new Date().getTime() - startTime;
|
|
24
|
+
this.#resultMap.update(name, (v) => (v ?? 0) + duration);
|
|
25
|
+
return realRes;
|
|
26
|
+
}) as R;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const duration = new Date().getTime() - startTime;
|
|
30
|
+
this.#resultMap.update(name, (v) => (v ?? 0) + duration);
|
|
31
|
+
return res;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
toString() {
|
|
35
|
+
return `${this._name} performance report
|
|
36
|
+
------------------------------------
|
|
37
|
+
${Array.from(this.#resultMap.entries())
|
|
38
|
+
.map((en) => `${en[0]}: ${en[1].toLocaleString()}ms`)
|
|
39
|
+
.join("\n")}
|
|
40
|
+
------------------------------------`;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/tsconfig.json
CHANGED