@simplysm/sd-cli 12.5.18 → 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 -328
- 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 +19 -42
- 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 -4
- package/dist/index.js +1 -4
- 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 -14
- package/src/build-tools/SdNgBundler.ts +82 -68
- package/src/build-tools/SdServerBundler.ts +22 -20
- package/src/build-tools/SdTsCompiler.ts +341 -358
- package/src/build-tools/SdTsLibBundler.ts +2 -1
- package/src/builders/SdCliClientBuilder.ts +27 -54
- 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 -4
- package/src/utils/SdCliPerformanceTime.ts +42 -0
- package/tsconfig.json +1 -1
- package/dist/build-tools/SdReactBundler.d.ts +0 -24
- package/dist/build-tools/SdReactBundler.js +0 -294
- package/dist/build-tools/SdReactBundler.js.map +0 -1
- package/dist/build-tools/SdReactBundlerContext.d.ts +0 -14
- package/dist/build-tools/SdReactBundlerContext.js +0 -59
- package/dist/build-tools/SdReactBundlerContext.js.map +0 -1
- package/dist/bundle-plugins/KeysTransformer.d.ts +0 -2
- package/dist/bundle-plugins/KeysTransformer.js +0 -61
- package/dist/bundle-plugins/KeysTransformer.js.map +0 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -15
- package/dist/bundle-plugins/sdReactPlugin.js +0 -116
- package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
- package/src/build-tools/SdReactBundler.ts +0 -370
- package/src/build-tools/SdReactBundlerContext.ts +0 -71
- package/src/bundle-plugins/KeysTransformer.ts +0 -70
- package/src/bundle-plugins/sdReactPlugin.ts +0 -160
|
@@ -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
|
|
|
@@ -14,7 +14,6 @@ import { SdCliCordova } from "../build-tools/SdCliCordova";
|
|
|
14
14
|
import { SdCliNgRoutesFileGenerator } from "../build-tools/SdCliNgRoutesFileGenerator";
|
|
15
15
|
import { SdLinter } from "../build-tools/SdLinter";
|
|
16
16
|
import { SdCliElectron } from "../entry/SdCliElectron";
|
|
17
|
-
import { SdReactBundler } from "../build-tools/SdReactBundler";
|
|
18
17
|
|
|
19
18
|
// import ts from "typescript";
|
|
20
19
|
|
|
@@ -22,7 +21,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
22
21
|
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdCliClientBuilder"]);
|
|
23
22
|
private readonly _pkgConf: ISdCliClientPackageConfig;
|
|
24
23
|
private readonly _npmConf: INpmConfig;
|
|
25
|
-
private _builders?:
|
|
24
|
+
private _builders?: SdNgBundler[];
|
|
26
25
|
private _cordova?: SdCliCordova;
|
|
27
26
|
|
|
28
27
|
// #program?: ts.Program;
|
|
@@ -117,6 +116,10 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
117
116
|
affectedFileSet: Set<string>;
|
|
118
117
|
buildResults: ISdCliPackageBuildResult[];
|
|
119
118
|
}> {
|
|
119
|
+
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
120
|
+
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
121
|
+
);
|
|
122
|
+
|
|
120
123
|
const builderTypes = Object.keys(this._pkgConf.builder ?? { web: {} }) as ("web" | "electron" | "cordova")[];
|
|
121
124
|
if (this._pkgConf.builder?.cordova && !this._cordova) {
|
|
122
125
|
this._debug("CORDOVA 준비...");
|
|
@@ -130,55 +133,28 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
130
133
|
if (!this._builders) {
|
|
131
134
|
this._debug(`BUILD 준비...`);
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
157
|
-
}),
|
|
158
|
-
);
|
|
159
|
-
} else {
|
|
160
|
-
this._builders = builderTypes.map(
|
|
161
|
-
(builderType) =>
|
|
162
|
-
new SdNgBundler({
|
|
163
|
-
dev: opt.dev,
|
|
164
|
-
builderType: builderType,
|
|
165
|
-
pkgPath: this._pkgPath,
|
|
166
|
-
outputPath:
|
|
167
|
-
builderType === "web"
|
|
168
|
-
? path.resolve(this._pkgPath, "dist")
|
|
169
|
-
: builderType === "electron" && !opt.dev
|
|
170
|
-
? path.resolve(this._pkgPath, ".electron/src")
|
|
171
|
-
: builderType === "cordova" && !opt.dev
|
|
172
|
-
? path.resolve(this._pkgPath, ".cordova/www")
|
|
173
|
-
: path.resolve(this._pkgPath, "dist", builderType),
|
|
174
|
-
env: {
|
|
175
|
-
...this._pkgConf.env,
|
|
176
|
-
...this._pkgConf.builder?.[builderType]?.env,
|
|
177
|
-
},
|
|
178
|
-
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
179
|
-
}),
|
|
180
|
-
);
|
|
181
|
-
}
|
|
136
|
+
this._builders = builderTypes.map(
|
|
137
|
+
(builderType) =>
|
|
138
|
+
new SdNgBundler({
|
|
139
|
+
dev: opt.dev,
|
|
140
|
+
builderType: builderType,
|
|
141
|
+
pkgPath: this._pkgPath,
|
|
142
|
+
outputPath:
|
|
143
|
+
builderType === "web"
|
|
144
|
+
? path.resolve(this._pkgPath, "dist")
|
|
145
|
+
: builderType === "electron" && !opt.dev
|
|
146
|
+
? path.resolve(this._pkgPath, ".electron/src")
|
|
147
|
+
: builderType === "cordova" && !opt.dev
|
|
148
|
+
? path.resolve(this._pkgPath, ".cordova/www")
|
|
149
|
+
: path.resolve(this._pkgPath, "dist", builderType),
|
|
150
|
+
env: {
|
|
151
|
+
...this._pkgConf.env,
|
|
152
|
+
...this._pkgConf.builder?.[builderType]?.env,
|
|
153
|
+
},
|
|
154
|
+
cordovaConfig: builderType === "cordova" ? this._pkgConf.builder!.cordova : undefined,
|
|
155
|
+
watchScopePaths: [path.resolve(this._pkgPath, "../"), ...localUpdatePaths],
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
182
158
|
}
|
|
183
159
|
|
|
184
160
|
this._debug(`BUILD & CHECK...`);
|
|
@@ -213,9 +189,6 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
213
189
|
}
|
|
214
190
|
|
|
215
191
|
this._debug(`빌드 완료`);
|
|
216
|
-
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {}).mapMany((key) =>
|
|
217
|
-
FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)),
|
|
218
|
-
);
|
|
219
192
|
const currWatchFileSet = new Set(
|
|
220
193
|
Array.from(watchFileSet).filter(
|
|
221
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
|
@@ -4,8 +4,6 @@ export * from "./build-tools/SdCliNgRoutesFileGenerator";
|
|
|
4
4
|
export * from "./build-tools/SdLinter";
|
|
5
5
|
export * from "./build-tools/SdNgBundler";
|
|
6
6
|
export * from "./build-tools/SdNgBundlerContext";
|
|
7
|
-
export * from "./build-tools/SdReactBundler";
|
|
8
|
-
export * from "./build-tools/SdReactBundlerContext";
|
|
9
7
|
export * from "./build-tools/SdServerBundler";
|
|
10
8
|
export * from "./build-tools/SdTsCompiler";
|
|
11
9
|
export * from "./build-tools/SdTsLibBundler";
|
|
@@ -13,12 +11,11 @@ export * from "./builders/SdCliClientBuilder";
|
|
|
13
11
|
export * from "./builders/SdCliJsLibLinter";
|
|
14
12
|
export * from "./builders/SdCliServerBuilder";
|
|
15
13
|
export * from "./builders/SdCliTsLibBuilder";
|
|
16
|
-
export * from "./bundle-plugins/KeysTransformer";
|
|
17
14
|
export * from "./bundle-plugins/sdNgPlugin";
|
|
18
|
-
export * from "./bundle-plugins/sdReactPlugin";
|
|
19
15
|
export * from "./bundle-plugins/sdServerPlugin";
|
|
20
16
|
export * from "./commons";
|
|
21
17
|
export * from "./entry/SdCliElectron";
|
|
22
18
|
export * from "./entry/SdCliLocalUpdate";
|
|
23
19
|
export * from "./entry/SdCliProject";
|
|
24
20
|
export * from "./utils/SdCliBuildResultUtil";
|
|
21
|
+
export * from "./utils/SdCliPerformanceTime";
|
|
@@ -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
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ISdCliClientBuilderCordovaConfig, ISdCliPackageBuildResult } from "../commons";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
export declare class SdReactBundler {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(opt: IOptions);
|
|
6
|
-
markForChanges(filePaths: string[]): void;
|
|
7
|
-
bundleAsync(): Promise<{
|
|
8
|
-
program?: ts.Program;
|
|
9
|
-
watchFileSet: Set<string>;
|
|
10
|
-
affectedFileSet: Set<string>;
|
|
11
|
-
results: ISdCliPackageBuildResult[];
|
|
12
|
-
}>;
|
|
13
|
-
private _getAppContext;
|
|
14
|
-
private _getElectronMainContext;
|
|
15
|
-
}
|
|
16
|
-
interface IOptions {
|
|
17
|
-
dev: boolean;
|
|
18
|
-
outputPath: string;
|
|
19
|
-
pkgPath: string;
|
|
20
|
-
builderType: string;
|
|
21
|
-
env: Record<string, string> | undefined;
|
|
22
|
-
cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
|
|
23
|
-
}
|
|
24
|
-
export {};
|