@simplysm/sd-cli 12.13.37 → 12.13.39
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/pkg-builders/SdBuildRunnerBase.d.ts +14 -0
- package/dist/pkg-builders/SdBuildRunnerBase.js +23 -0
- package/dist/pkg-builders/SdBuildRunnerBase.js.map +1 -0
- package/dist/pkg-builders/SdProjectBuildRunner.js +18 -14
- package/dist/pkg-builders/SdProjectBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/client/SdClientBuildRunner.js +17 -36
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -1
- package/dist/pkg-builders/client/SdNgBundler.d.ts +10 -16
- package/dist/pkg-builders/client/SdNgBundler.js +59 -54
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -1
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +2 -11
- package/dist/pkg-builders/client/createSdNgPlugin.js +16 -25
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -1
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +5 -5
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +6 -6
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -1
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +3 -3
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +6 -15
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +1 -1
- package/dist/pkg-builders/server/SdServerBuildRunner.js +25 -42
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -1
- package/dist/pkg-builders/server/SdServerBundler.d.ts +4 -10
- package/dist/pkg-builders/server/SdServerBundler.js +15 -22
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -1
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +2 -11
- package/dist/pkg-builders/server/createSdServerPlugin.js +10 -19
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -1
- package/dist/sd-cli-entry.js +1 -1
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/ts-compiler/ScopePathSet.js.map +1 -0
- package/dist/ts-compiler/SdDepAnalyzer.d.ts +1 -1
- package/dist/ts-compiler/SdStyleBundler.d.ts +8 -5
- package/dist/ts-compiler/SdStyleBundler.js +30 -15
- package/dist/ts-compiler/SdStyleBundler.js.map +1 -1
- package/dist/ts-compiler/SdTsCompiler.d.ts +2 -1
- package/dist/ts-compiler/SdTsCompiler.js +68 -53
- package/dist/ts-compiler/SdTsCompiler.js.map +1 -1
- package/dist/types/build/ISdTsCompilerOptions.d.ts +6 -9
- package/dist/types/worker/ISdBuildRunnerWorkerType.d.ts +4 -7
- package/dist/workers/build-runner.worker.js +4 -5
- package/dist/workers/build-runner.worker.js.map +1 -1
- package/package.json +5 -5
- package/src/pkg-builders/SdBuildRunnerBase.ts +36 -0
- package/src/pkg-builders/SdProjectBuildRunner.ts +24 -16
- package/src/pkg-builders/client/SdClientBuildRunner.ts +25 -46
- package/src/pkg-builders/client/SdNgBundler.ts +69 -73
- package/src/pkg-builders/client/createSdNgPlugin.ts +21 -35
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +5 -5
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +9 -13
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +7 -23
- package/src/pkg-builders/server/SdServerBuildRunner.ts +32 -50
- package/src/pkg-builders/server/SdServerBundler.ts +16 -32
- package/src/pkg-builders/server/createSdServerPlugin.ts +15 -29
- package/src/sd-cli-entry.ts +1 -1
- package/src/ts-compiler/SdDepAnalyzer.ts +1 -1
- package/src/ts-compiler/SdStyleBundler.ts +34 -15
- package/src/ts-compiler/SdTsCompiler.ts +75 -63
- package/src/types/build/ISdTsCompilerOptions.ts +6 -9
- package/src/types/worker/ISdBuildRunnerWorkerType.ts +4 -9
- package/src/workers/build-runner.worker.ts +7 -16
- package/dist/fix/convert-extends-sd-modal-base-to-interface.d.ts +0 -1
- package/dist/fix/convert-extends-sd-modal-base-to-interface.js +0 -289
- package/dist/fix/convert-extends-sd-modal-base-to-interface.js.map +0 -1
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.d.ts +0 -1
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.js +0 -179
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.js.map +0 -1
- package/dist/fix/convert-flat-pages-to-flat-menus.d.ts +0 -1
- package/dist/fix/convert-flat-pages-to-flat-menus.js +0 -68
- package/dist/fix/convert-flat-pages-to-flat-menus.js.map +0 -1
- package/dist/fix/convert-get-menus-to-usable-menus.d.ts +0 -1
- package/dist/fix/convert-get-menus-to-usable-menus.js +0 -48
- package/dist/fix/convert-get-menus-to-usable-menus.js.map +0 -1
- package/dist/fix/convert-modal-show-params.d.ts +0 -1
- package/dist/fix/convert-modal-show-params.js +0 -29
- package/dist/fix/convert-modal-show-params.js.map +0 -1
- package/dist/fix/convert-print-params.d.ts +0 -1
- package/dist/fix/convert-print-params.js +0 -37
- package/dist/fix/convert-print-params.js.map +0 -1
- package/dist/fix/convert-sd-icon-to-fa-icon.d.ts +0 -1
- package/dist/fix/convert-sd-icon-to-fa-icon.js +0 -80
- package/dist/fix/convert-sd-icon-to-fa-icon.js.map +0 -1
- package/dist/fix/convert-sd-sheet-bindings-safety.d.ts +0 -1
- package/dist/fix/convert-sd-sheet-bindings-safety.js +0 -57
- package/dist/fix/convert-sd-sheet-bindings-safety.js.map +0 -1
- package/dist/fix/convert-select-modal-button-to-select-button.d.ts +0 -1
- package/dist/fix/convert-select-modal-button-to-select-button.js +0 -64
- package/dist/fix/convert-select-modal-button-to-select-button.js.map +0 -1
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.d.ts +0 -1
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js +0 -38
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js.map +0 -1
- package/dist/fix/convert-to-use-perms-signal.d.ts +0 -1
- package/dist/fix/convert-to-use-perms-signal.js +0 -99
- package/dist/fix/convert-to-use-perms-signal.js.map +0 -1
- package/dist/fix/core/remove-named-import.d.ts +0 -1
- package/dist/fix/core/remove-named-import.js +0 -14
- package/dist/fix/core/remove-named-import.js.map +0 -1
- package/dist/pkg-builders/commons/ScopePathSet.js.map +0 -1
- package/dist/pkg-builders/commons/SdBuildRunnerBase.d.ts +0 -20
- package/dist/pkg-builders/commons/SdBuildRunnerBase.js +0 -30
- package/dist/pkg-builders/commons/SdBuildRunnerBase.js.map +0 -1
- package/src/fix/convert-extends-sd-modal-base-to-interface.ts +0 -324
- package/src/fix/convert-extends-sd-print-template-base-to-interface.ts +0 -201
- package/src/fix/convert-flat-pages-to-flat-menus.ts +0 -83
- package/src/fix/convert-get-menus-to-usable-menus.ts +0 -60
- package/src/fix/convert-modal-show-params.ts +0 -37
- package/src/fix/convert-print-params.ts +0 -51
- package/src/fix/convert-sd-icon-to-fa-icon.ts +0 -95
- package/src/fix/convert-sd-sheet-bindings-safety.ts +0 -73
- package/src/fix/convert-select-modal-button-to-select-button.ts +0 -91
- package/src/fix/convert-setup-cumulate-selected-keys-to-object-param.ts +0 -44
- package/src/fix/convert-to-use-perms-signal.ts +0 -133
- package/src/fix/core/remove-named-import.ts +0 -14
- package/src/pkg-builders/commons/SdBuildRunnerBase.ts +0 -47
- /package/dist/{pkg-builders/commons → ts-compiler}/ScopePathSet.d.ts +0 -0
- /package/dist/{pkg-builders/commons → ts-compiler}/ScopePathSet.js +0 -0
- /package/src/{pkg-builders/commons → ts-compiler}/ScopePathSet.ts +0 -0
|
@@ -2,31 +2,15 @@ import path from "path";
|
|
|
2
2
|
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
3
3
|
import { FsUtils, HashUtils, PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
|
|
5
|
-
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
6
5
|
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
6
|
+
import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
|
|
7
7
|
|
|
8
8
|
export class SdTsLibBuilder {
|
|
9
9
|
#tsCompiler: SdTsCompiler;
|
|
10
10
|
#outputHashCache = new Map<TNormPath, string>();
|
|
11
11
|
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
watch: boolean,
|
|
15
|
-
dev: boolean,
|
|
16
|
-
emitOnly: boolean,
|
|
17
|
-
noEmit: boolean,
|
|
18
|
-
scopePathSet: ScopePathSet,
|
|
19
|
-
) {
|
|
20
|
-
this.#tsCompiler = new SdTsCompiler({
|
|
21
|
-
pkgPath: this._pkgPath,
|
|
22
|
-
additionalOptions: { declaration: true },
|
|
23
|
-
isWatchMode: watch,
|
|
24
|
-
isDevMode: dev,
|
|
25
|
-
isEmitOnly: emitOnly,
|
|
26
|
-
isNoEmit: noEmit,
|
|
27
|
-
isForBundle: false,
|
|
28
|
-
scopePathSet,
|
|
29
|
-
});
|
|
12
|
+
constructor(private readonly _opt: ISdTsCompilerOptions) {
|
|
13
|
+
this.#tsCompiler = new SdTsCompiler(_opt, false);
|
|
30
14
|
}
|
|
31
15
|
|
|
32
16
|
async buildAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
@@ -55,11 +39,11 @@ export class SdTsLibBuilder {
|
|
|
55
39
|
if (globalStylesheetBundlingResult && "outputFiles" in globalStylesheetBundlingResult) {
|
|
56
40
|
for (const outputFile of globalStylesheetBundlingResult.outputFiles) {
|
|
57
41
|
const distPath = PathUtils.norm(
|
|
58
|
-
this.
|
|
42
|
+
this._opt.pkgPath,
|
|
59
43
|
"dist",
|
|
60
|
-
path.relative(this.
|
|
44
|
+
path.relative(this._opt.pkgPath, outputFile.path),
|
|
61
45
|
);
|
|
62
|
-
if (PathUtils.isChildPath(distPath, path.resolve(this.
|
|
46
|
+
if (PathUtils.isChildPath(distPath, path.resolve(this._opt.pkgPath, "dist"))) {
|
|
63
47
|
const prevHash = this.#outputHashCache.get(distPath);
|
|
64
48
|
const currHash = HashUtils.get(Buffer.from(outputFile.text));
|
|
65
49
|
if (prevHash !== currHash) {
|
|
@@ -73,7 +57,7 @@ export class SdTsLibBuilder {
|
|
|
73
57
|
}
|
|
74
58
|
|
|
75
59
|
const styleResults = Array.from(tsCompileResult.stylesheetBundlingResultMap.values()).mapMany(
|
|
76
|
-
(item) => SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(item, this.
|
|
60
|
+
(item) => SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(item, this._opt.pkgPath),
|
|
77
61
|
);
|
|
78
62
|
|
|
79
63
|
return {
|
|
@@ -1,49 +1,36 @@
|
|
|
1
1
|
import { FsUtils, SdLogger, TNormPath } from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { javascript, StringUtils } from "@simplysm/sd-core-common";
|
|
4
|
-
import { SdBuildRunnerBase } from "../
|
|
4
|
+
import { SdBuildRunnerBase } from "../SdBuildRunnerBase";
|
|
5
5
|
import { SdServerBundler } from "./SdServerBundler";
|
|
6
6
|
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
7
|
-
import { ITsConfig } from "../../types/common-config/ITsConfig";
|
|
8
7
|
import { INpmConfig } from "../../types/common-config/INpmConfig";
|
|
9
8
|
|
|
10
9
|
export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
11
10
|
protected override _logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBuild2Runner"]);
|
|
12
11
|
|
|
13
12
|
#serverBundler?: SdServerBundler;
|
|
14
|
-
#extModules?: { name: string; exists: boolean }[];
|
|
15
13
|
|
|
16
14
|
protected override async _runAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
17
|
-
// prod일때 각종 파일들 생성
|
|
18
|
-
if (!this._dev) {
|
|
19
|
-
await this.#generateProductionFilesAsync();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
// 최초
|
|
23
16
|
if (!modifiedFileSet) {
|
|
24
|
-
|
|
17
|
+
const externalModules = this.#getExternalModules();
|
|
18
|
+
|
|
19
|
+
if (!this._opt.watch?.dev) {
|
|
20
|
+
this.#generateProductionFiles(
|
|
21
|
+
externalModules.filter((item) => item.exists).map((item) => item.name),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!this._opt.watch?.noEmit) {
|
|
25
26
|
this._debug("GEN .config...");
|
|
26
|
-
const confDistPath = path.resolve(this.
|
|
27
|
+
const confDistPath = path.resolve(this._opt.pkgPath, "dist/.config.json");
|
|
27
28
|
FsUtils.writeFile(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
this._debug(`BUILD 준비...`);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.#serverBundler = new SdServerBundler({
|
|
34
|
-
watch: this._watch,
|
|
35
|
-
dev: this._dev,
|
|
36
|
-
emitOnly: this._emitOnly ?? false,
|
|
37
|
-
noEmit: this._noEmit ?? false,
|
|
38
|
-
pkgPath: this._pkgPath,
|
|
39
|
-
entryPoints: tsConfig.files
|
|
40
|
-
? tsConfig.files.map((item) => path.resolve(this._pkgPath, item))
|
|
41
|
-
: [
|
|
42
|
-
path.resolve(this._pkgPath, "src/main.ts"),
|
|
43
|
-
...FsUtils.glob(path.resolve(this._pkgPath, "src/workers/*.ts")),
|
|
44
|
-
],
|
|
45
|
-
external: this.#extModules.map((item) => item.name),
|
|
46
|
-
scopePathSet: this._scopePathSet,
|
|
32
|
+
this.#serverBundler = new SdServerBundler(this._opt, {
|
|
33
|
+
external: externalModules.map((item) => item.name),
|
|
47
34
|
});
|
|
48
35
|
}
|
|
49
36
|
|
|
@@ -54,17 +41,14 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
|
54
41
|
return bundleResult;
|
|
55
42
|
}
|
|
56
43
|
|
|
57
|
-
|
|
58
|
-
const npmConf = FsUtils.readJson(path.resolve(this.
|
|
44
|
+
#generateProductionFiles(externals: string[]) {
|
|
45
|
+
const npmConf = FsUtils.readJson(path.resolve(this._opt.pkgPath, "package.json")) as INpmConfig;
|
|
59
46
|
|
|
60
47
|
this._debug("GEN package.json...");
|
|
61
48
|
{
|
|
62
49
|
const projNpmConf = FsUtils.readJson(
|
|
63
50
|
path.resolve(process.cwd(), "package.json"),
|
|
64
51
|
) as INpmConfig;
|
|
65
|
-
const extModules = await this.#getExternalModulesAsync();
|
|
66
|
-
|
|
67
|
-
const deps = extModules.filter((item) => item.exists).map((item) => item.name);
|
|
68
52
|
|
|
69
53
|
const distNpmConfig: INpmConfig = {
|
|
70
54
|
name: npmConf.name,
|
|
@@ -72,13 +56,13 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
|
72
56
|
type: npmConf.type,
|
|
73
57
|
};
|
|
74
58
|
distNpmConfig.dependencies = {};
|
|
75
|
-
for (const
|
|
76
|
-
distNpmConfig.dependencies[
|
|
59
|
+
for (const external of externals) {
|
|
60
|
+
distNpmConfig.dependencies[external] = "*";
|
|
77
61
|
}
|
|
78
62
|
|
|
79
63
|
distNpmConfig.volta = projNpmConf.volta;
|
|
80
64
|
|
|
81
|
-
FsUtils.writeJson(path.resolve(this.
|
|
65
|
+
FsUtils.writeJson(path.resolve(this._opt.pkgPath, "dist/package.json"), distNpmConfig, {
|
|
82
66
|
space: 2,
|
|
83
67
|
});
|
|
84
68
|
}
|
|
@@ -86,7 +70,7 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
|
86
70
|
this._debug("GEN .yarnrc.yml...");
|
|
87
71
|
{
|
|
88
72
|
FsUtils.writeFile(
|
|
89
|
-
path.resolve(this.
|
|
73
|
+
path.resolve(this._opt.pkgPath, "dist/.yarnrc.yml"),
|
|
90
74
|
"nodeLinker: node-modules",
|
|
91
75
|
);
|
|
92
76
|
}
|
|
@@ -94,7 +78,7 @@ export class SdServerBuildRunner extends SdBuildRunnerBase<"server"> {
|
|
|
94
78
|
this._debug("GEN openssl.cnf...");
|
|
95
79
|
{
|
|
96
80
|
FsUtils.writeFile(
|
|
97
|
-
path.resolve(this.
|
|
81
|
+
path.resolve(this._opt.pkgPath, "dist/openssl.cnf"),
|
|
98
82
|
`
|
|
99
83
|
nodejs_conf = openssl_init
|
|
100
84
|
|
|
@@ -157,13 +141,13 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
157
141
|
.replaceAll("\n ", "\n")
|
|
158
142
|
.trim();
|
|
159
143
|
|
|
160
|
-
FsUtils.writeFile(path.resolve(this.
|
|
144
|
+
FsUtils.writeFile(path.resolve(this._opt.pkgPath, "dist/pm2.config.cjs"), str);
|
|
161
145
|
}
|
|
162
146
|
|
|
163
147
|
if (this._pkgConf.iis) {
|
|
164
148
|
this._debug("GEN web.config...");
|
|
165
149
|
|
|
166
|
-
const iisDistPath = path.resolve(this.
|
|
150
|
+
const iisDistPath = path.resolve(this._opt.pkgPath, "dist/web.config");
|
|
167
151
|
const nodeVersion = process.versions.node.substring(1);
|
|
168
152
|
const serverExeFilePath =
|
|
169
153
|
this._pkgConf.iis.nodeExeFilePath ??
|
|
@@ -203,12 +187,10 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
203
187
|
}
|
|
204
188
|
}
|
|
205
189
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}[]
|
|
211
|
-
> {
|
|
190
|
+
#getExternalModules(): {
|
|
191
|
+
name: string;
|
|
192
|
+
exists: boolean;
|
|
193
|
+
}[] {
|
|
212
194
|
const loadedModuleNames: string[] = [];
|
|
213
195
|
const results: {
|
|
214
196
|
name: string;
|
|
@@ -217,7 +199,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
217
199
|
|
|
218
200
|
const npmConfigMap = new Map<string, INpmConfig>();
|
|
219
201
|
|
|
220
|
-
const fn =
|
|
202
|
+
const fn = (currPath: string) => {
|
|
221
203
|
const npmConfig = npmConfigMap.getOrCreate(
|
|
222
204
|
currPath,
|
|
223
205
|
FsUtils.readJson(path.resolve(currPath, "package.json")),
|
|
@@ -245,7 +227,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
245
227
|
const modulePath = FsUtils.findAllParentChildPaths(
|
|
246
228
|
"node_modules/" + moduleName,
|
|
247
229
|
currPath,
|
|
248
|
-
path.resolve(this.
|
|
230
|
+
path.resolve(this._opt.pkgPath, "../../"),
|
|
249
231
|
).first();
|
|
250
232
|
if (StringUtils.isNullOrEmpty(modulePath)) {
|
|
251
233
|
continue;
|
|
@@ -265,7 +247,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
265
247
|
});
|
|
266
248
|
}
|
|
267
249
|
|
|
268
|
-
|
|
250
|
+
fn(modulePath);
|
|
269
251
|
}
|
|
270
252
|
|
|
271
253
|
for (const optModuleName of deps.optionals) {
|
|
@@ -275,7 +257,7 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
275
257
|
const optModulePath = FsUtils.findAllParentChildPaths(
|
|
276
258
|
"node_modules/" + optModuleName,
|
|
277
259
|
currPath,
|
|
278
|
-
path.resolve(this.
|
|
260
|
+
path.resolve(this._opt.pkgPath, "../../"),
|
|
279
261
|
).first();
|
|
280
262
|
if (StringUtils.isNullOrEmpty(optModulePath)) {
|
|
281
263
|
results.push({
|
|
@@ -299,11 +281,11 @@ Options = UnsafeLegacyRenegotiation`.trim(),
|
|
|
299
281
|
});
|
|
300
282
|
}
|
|
301
283
|
|
|
302
|
-
|
|
284
|
+
fn(optModulePath);
|
|
303
285
|
}
|
|
304
286
|
};
|
|
305
287
|
|
|
306
|
-
|
|
288
|
+
fn(this._opt.pkgPath);
|
|
307
289
|
|
|
308
290
|
for (const external of this._pkgConf.externals ?? []) {
|
|
309
291
|
if (!results.some((item) => item.name === external)) {
|
|
@@ -9,9 +9,9 @@ import {
|
|
|
9
9
|
} from "@angular/build/src/tools/esbuild/bundler-context";
|
|
10
10
|
import { convertOutputFile } from "@angular/build/src/tools/esbuild/utils";
|
|
11
11
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
12
|
-
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
13
12
|
import { ISdCliServerPluginResultCache } from "../../types/plugin/ISdCliServerPluginResultCache";
|
|
14
13
|
import { ISdBuildResult } from "../../types/build/ISdBuildResult";
|
|
14
|
+
import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
|
|
15
15
|
|
|
16
16
|
export class SdServerBundler {
|
|
17
17
|
#logger = SdLogger.get(["simplysm", "sd-cli", "SdServerBundler"]);
|
|
@@ -24,16 +24,8 @@ export class SdServerBundler {
|
|
|
24
24
|
#outputHashCache = new Map<TNormPath, string>();
|
|
25
25
|
|
|
26
26
|
constructor(
|
|
27
|
-
private readonly _opt:
|
|
28
|
-
|
|
29
|
-
dev: boolean;
|
|
30
|
-
emitOnly: boolean;
|
|
31
|
-
noEmit: boolean;
|
|
32
|
-
pkgPath: TNormPath;
|
|
33
|
-
entryPoints: string[];
|
|
34
|
-
external?: string[];
|
|
35
|
-
scopePathSet: ScopePathSet;
|
|
36
|
-
},
|
|
27
|
+
private readonly _opt: ISdTsCompilerOptions,
|
|
28
|
+
private readonly _conf: { external: string[] },
|
|
37
29
|
) {}
|
|
38
30
|
|
|
39
31
|
async bundleAsync(modifiedFileSet?: Set<TNormPath>): Promise<ISdBuildResult> {
|
|
@@ -44,20 +36,23 @@ export class SdServerBundler {
|
|
|
44
36
|
|
|
45
37
|
if (!this.#context) {
|
|
46
38
|
this.#context = await esbuild.context({
|
|
47
|
-
entryPoints:
|
|
39
|
+
entryPoints: [
|
|
40
|
+
path.resolve(this._opt.pkgPath, "src/main.ts"),
|
|
41
|
+
...FsUtils.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")),
|
|
42
|
+
],
|
|
48
43
|
keepNames: true,
|
|
49
44
|
bundle: true,
|
|
50
|
-
sourcemap: this._opt.dev,
|
|
45
|
+
sourcemap: !!this._opt.watch?.dev,
|
|
51
46
|
target: "node18",
|
|
52
47
|
mainFields: ["es2020", "es2015", "module", "main"],
|
|
53
48
|
conditions: ["es2020", "es2015", "module"],
|
|
54
49
|
tsconfig: path.resolve(this._opt.pkgPath, "tsconfig.json"),
|
|
55
50
|
write: false,
|
|
56
51
|
metafile: true,
|
|
57
|
-
legalComments: this._opt.dev ? "eof" : "none",
|
|
58
|
-
minifyIdentifiers: !this._opt.dev,
|
|
59
|
-
minifySyntax: !this._opt.dev,
|
|
60
|
-
minifyWhitespace: !this._opt.dev,
|
|
52
|
+
legalComments: this._opt.watch?.dev ? "eof" : "none",
|
|
53
|
+
minifyIdentifiers: !this._opt.watch?.dev,
|
|
54
|
+
minifySyntax: !this._opt.watch?.dev,
|
|
55
|
+
minifyWhitespace: !this._opt.watch?.dev,
|
|
61
56
|
outdir: path.resolve(this._opt.pkgPath, "dist"),
|
|
62
57
|
format: "esm",
|
|
63
58
|
resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
|
|
@@ -91,7 +86,7 @@ export class SdServerBundler {
|
|
|
91
86
|
},
|
|
92
87
|
platform: "node",
|
|
93
88
|
logLevel: "silent",
|
|
94
|
-
external: this.
|
|
89
|
+
external: this._conf.external,
|
|
95
90
|
banner: {
|
|
96
91
|
js: `
|
|
97
92
|
import __path__ from 'path';
|
|
@@ -102,25 +97,14 @@ const require = __createRequire__(import.meta.url);
|
|
|
102
97
|
const __filename = __fileURLToPath__(import.meta.url);
|
|
103
98
|
const __dirname = __path__.dirname(__filename);`.trim(),
|
|
104
99
|
},
|
|
105
|
-
plugins: [
|
|
106
|
-
createSdServerPlugin({
|
|
107
|
-
modifiedFileSet: this.#modifiedFileSet,
|
|
108
|
-
watch: this._opt.watch,
|
|
109
|
-
dev: this._opt.dev,
|
|
110
|
-
emitOnly: this._opt.emitOnly,
|
|
111
|
-
noEmit: this._opt.noEmit,
|
|
112
|
-
pkgPath: this._opt.pkgPath,
|
|
113
|
-
result: this.#resultCache,
|
|
114
|
-
scopePathSet: this._opt.scopePathSet,
|
|
115
|
-
}),
|
|
116
|
-
],
|
|
100
|
+
plugins: [createSdServerPlugin(this._opt, this.#modifiedFileSet, this.#resultCache)],
|
|
117
101
|
});
|
|
118
102
|
}
|
|
119
103
|
|
|
120
104
|
let esbuildResult: esbuild.BuildResult | esbuild.BuildFailure;
|
|
121
105
|
esbuildResult = await this.#context.rebuild();
|
|
122
106
|
|
|
123
|
-
if (this._opt.noEmit) {
|
|
107
|
+
if (this._opt.watch?.noEmit) {
|
|
124
108
|
return {
|
|
125
109
|
buildMessages: SdCliConvertMessageUtils.convertToBuildMessagesFromEsbuild(
|
|
126
110
|
esbuildResult,
|
|
@@ -155,7 +139,7 @@ const __dirname = __path__.dirname(__filename);`.trim(),
|
|
|
155
139
|
const assetFiles = await resolveAssets(
|
|
156
140
|
[
|
|
157
141
|
{ input: "public", glob: "**/*", output: "." },
|
|
158
|
-
...(this._opt.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
|
|
142
|
+
...(this._opt.watch?.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
|
|
159
143
|
],
|
|
160
144
|
this._opt.pkgPath,
|
|
161
145
|
);
|
|
@@ -2,41 +2,27 @@ import esbuild from "esbuild";
|
|
|
2
2
|
import { SdCliConvertMessageUtils } from "../../utils/SdCliConvertMessageUtils";
|
|
3
3
|
import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import { SdTsCompiler } from "../../ts-compiler/SdTsCompiler";
|
|
5
|
-
import { ScopePathSet } from "../commons/ScopePathSet";
|
|
6
5
|
import { ISdCliServerPluginResultCache } from "../../types/plugin/ISdCliServerPluginResultCache";
|
|
7
6
|
import { ISdTsCompilerResult } from "../../types/build/ISdTsCompilerResult";
|
|
7
|
+
import { ISdTsCompilerOptions } from "../../types/build/ISdTsCompilerOptions";
|
|
8
8
|
|
|
9
|
-
export function createSdServerPlugin(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
noEmit: boolean;
|
|
15
|
-
modifiedFileSet: Set<TNormPath>;
|
|
16
|
-
result: ISdCliServerPluginResultCache;
|
|
17
|
-
scopePathSet: ScopePathSet;
|
|
18
|
-
}): esbuild.Plugin {
|
|
9
|
+
export function createSdServerPlugin(
|
|
10
|
+
conf: ISdTsCompilerOptions,
|
|
11
|
+
modifiedFileSet: Set<TNormPath>,
|
|
12
|
+
resultCache: ISdCliServerPluginResultCache,
|
|
13
|
+
): esbuild.Plugin {
|
|
19
14
|
return {
|
|
20
15
|
name: "sd-server-compile",
|
|
21
16
|
setup: (build: esbuild.PluginBuild) => {
|
|
22
|
-
const tsCompiler = new SdTsCompiler(
|
|
23
|
-
pkgPath: conf.pkgPath,
|
|
24
|
-
additionalOptions: { declaration: false },
|
|
25
|
-
isWatchMode: conf.watch,
|
|
26
|
-
isDevMode: conf.dev,
|
|
27
|
-
isNoEmit: conf.noEmit,
|
|
28
|
-
isEmitOnly: conf.emitOnly,
|
|
29
|
-
isForBundle: true,
|
|
30
|
-
scopePathSet: conf.scopePathSet,
|
|
31
|
-
});
|
|
17
|
+
const tsCompiler = new SdTsCompiler(conf, true);
|
|
32
18
|
|
|
33
19
|
let tsCompileResult: ISdTsCompilerResult;
|
|
34
20
|
|
|
35
21
|
build.onStart(async () => {
|
|
36
|
-
tsCompileResult = await tsCompiler.compileAsync(
|
|
22
|
+
tsCompileResult = await tsCompiler.compileAsync(modifiedFileSet);
|
|
37
23
|
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
resultCache.watchFileSet = tsCompileResult.watchFileSet;
|
|
25
|
+
resultCache.affectedFileSet = tsCompileResult.affectedFileSet;
|
|
40
26
|
|
|
41
27
|
//-- return err/warn
|
|
42
28
|
return SdCliConvertMessageUtils.convertToEsbuildFromBuildMessages(
|
|
@@ -63,7 +49,7 @@ export function createSdServerPlugin(conf: {
|
|
|
63
49
|
});
|
|
64
50
|
|
|
65
51
|
build.onLoad({ filter: /\.[cm]?js$/ }, (args) => {
|
|
66
|
-
|
|
52
|
+
resultCache.watchFileSet!.add(PathUtils.norm(args.path));
|
|
67
53
|
return null;
|
|
68
54
|
});
|
|
69
55
|
|
|
@@ -78,16 +64,16 @@ export function createSdServerPlugin(conf: {
|
|
|
78
64
|
),
|
|
79
65
|
},
|
|
80
66
|
(args) => {
|
|
81
|
-
|
|
67
|
+
resultCache.watchFileSet!.add(PathUtils.norm(args.path));
|
|
82
68
|
return null;
|
|
83
69
|
},
|
|
84
70
|
);
|
|
85
71
|
|
|
86
72
|
build.onEnd((result) => {
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
resultCache.outputFiles = result.outputFiles;
|
|
74
|
+
resultCache.metafile = result.metafile;
|
|
89
75
|
|
|
90
|
-
|
|
76
|
+
modifiedFileSet.clear();
|
|
91
77
|
});
|
|
92
78
|
},
|
|
93
79
|
};
|
package/src/sd-cli-entry.ts
CHANGED
|
@@ -16,8 +16,8 @@ import convertPrivateToHash from "./fix/convert-private-to-hash";
|
|
|
16
16
|
import removeSdAngularSymbolNames from "./fix/remove-sd-angular-symbol-names";
|
|
17
17
|
import convertSdAngularSymbolNames from "./fix/convert-sd-angular-symbol-names";
|
|
18
18
|
import { removeUnusedInjects } from "./fix/remove-unused-injects";
|
|
19
|
-
import { removeUnusedImports } from "./fix/remove-unused-imports";
|
|
20
19
|
import removeUnusedProtectedReadonly from "./fix/remove-unused-protected-readonly";
|
|
20
|
+
import { removeUnusedImports } from "./fix/remove-unused-imports";
|
|
21
21
|
|
|
22
22
|
Error.stackTraceLimit = Infinity;
|
|
23
23
|
EventEmitter.defaultMaxListeners = 0;
|
|
@@ -3,7 +3,7 @@ import { SdDepCache } from "./SdDepCache";
|
|
|
3
3
|
import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { NgtscProgram } from "@angular/compiler-cli";
|
|
6
|
-
import { ScopePathSet } from "
|
|
6
|
+
import { ScopePathSet } from "./ScopePathSet";
|
|
7
7
|
|
|
8
8
|
export class SdDepAnalyzer {
|
|
9
9
|
static analyze(
|
|
@@ -2,8 +2,9 @@ import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
|
2
2
|
import { ComponentStylesheetBundler } from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
|
|
3
3
|
import { transformSupportedBrowsersToTargets } from "@angular/build/src/tools/esbuild/utils";
|
|
4
4
|
import browserslist from "browserslist";
|
|
5
|
-
import { ScopePathSet } from "../pkg-builders/commons/ScopePathSet";
|
|
6
5
|
import { TStylesheetBundlingResult } from "../types/build/TStylesheetBundlingResult";
|
|
6
|
+
import { ScopePathSet } from "./ScopePathSet";
|
|
7
|
+
import path from "path";
|
|
7
8
|
|
|
8
9
|
export class SdStyleBundler {
|
|
9
10
|
#ngStyleBundler: ComponentStylesheetBundler;
|
|
@@ -12,30 +13,40 @@ export class SdStyleBundler {
|
|
|
12
13
|
#revRefCache = new Map<TNormPath, Set<TNormPath>>();
|
|
13
14
|
|
|
14
15
|
constructor(
|
|
15
|
-
private readonly
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
private readonly _opt: {
|
|
17
|
+
pkgPath: TNormPath;
|
|
18
|
+
scopePathSet: ScopePathSet;
|
|
19
|
+
dev: boolean;
|
|
20
|
+
},
|
|
18
21
|
) {
|
|
19
22
|
this.#ngStyleBundler = new ComponentStylesheetBundler(
|
|
20
23
|
{
|
|
21
|
-
workspaceRoot: this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
outputNames: { bundles: "[name]", media: "media/[name]" },
|
|
24
|
+
workspaceRoot: this._opt.pkgPath,
|
|
25
|
+
inlineFonts: !this._opt.dev,
|
|
26
|
+
optimization: !this._opt.dev,
|
|
27
|
+
sourcemap: this._opt.dev ? "linked" : false,
|
|
28
|
+
sourcesContent: this._opt.dev,
|
|
29
|
+
outputNames: { bundles: "[name]-[hash]", media: "media/[name]-[hash]" },
|
|
27
30
|
includePaths: [],
|
|
31
|
+
sass: {
|
|
32
|
+
fatalDeprecations: undefined,
|
|
33
|
+
silenceDeprecations: undefined,
|
|
34
|
+
futureDeprecations: undefined,
|
|
35
|
+
},
|
|
28
36
|
externalDependencies: [],
|
|
29
37
|
target: transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"])),
|
|
38
|
+
preserveSymlinks: false,
|
|
30
39
|
tailwindConfiguration: undefined,
|
|
40
|
+
postcssConfiguration: undefined,
|
|
31
41
|
cacheOptions: {
|
|
32
42
|
enabled: true,
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
basePath: path.resolve(this._opt.pkgPath, ".cache"),
|
|
44
|
+
path: path.resolve(this._opt.pkgPath, ".cache/angular"),
|
|
35
45
|
},
|
|
46
|
+
publicPath: undefined,
|
|
36
47
|
},
|
|
37
48
|
"scss",
|
|
38
|
-
this.
|
|
49
|
+
this._opt.dev,
|
|
39
50
|
);
|
|
40
51
|
}
|
|
41
52
|
|
|
@@ -68,8 +79,8 @@ export class SdStyleBundler {
|
|
|
68
79
|
|
|
69
80
|
for (const referencedFile of result.referencedFiles ?? []) {
|
|
70
81
|
if (
|
|
71
|
-
!this.
|
|
72
|
-
!this.
|
|
82
|
+
!this._opt.scopePathSet.inScope(fileNPath) ||
|
|
83
|
+
!this._opt.scopePathSet.inScope(PathUtils.norm(referencedFile))
|
|
73
84
|
)
|
|
74
85
|
continue;
|
|
75
86
|
|
|
@@ -127,10 +138,18 @@ export class SdStyleBundler {
|
|
|
127
138
|
}
|
|
128
139
|
|
|
129
140
|
#addReference(fileNPath: TNormPath, referencedFile: TNormPath) {
|
|
141
|
+
if (fileNPath === referencedFile) return;
|
|
130
142
|
this.#refCache.getOrCreate(fileNPath, new Set()).add(referencedFile);
|
|
131
143
|
this.#revRefCache.getOrCreate(referencedFile, new Set()).add(fileNPath);
|
|
132
144
|
}
|
|
133
145
|
|
|
146
|
+
getAllStyleFileSet() {
|
|
147
|
+
return new Set([
|
|
148
|
+
...this.#revRefCache.keys(),
|
|
149
|
+
...Array.from(this.#revRefCache.values()).mapMany((item) => Array.from(item)),
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
|
|
134
153
|
getAffectedFileSet(modifiedNPathSet: Set<TNormPath>) {
|
|
135
154
|
const affectedFileSet = new Set<TNormPath>();
|
|
136
155
|
// 수정파일중 Result에 있는것
|