@simplysm/sd-cli 12.5.21 → 12.5.22
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 → entry}/SdCliCordova.d.ts +5 -6
- package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/SdCliElectron.d.ts +2 -2
- package/dist/entry/SdCliElectron.js +50 -40
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
- package/dist/entry/SdCliLocalUpdate.js +26 -27
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -5
- package/dist/entry/SdCliProject.js +62 -288
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +23 -20
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +100 -95
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
- package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
- package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
- package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli.js +61 -54
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
- package/dist/ts-builder/SdTsCompileWorker.js +16 -0
- package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
- package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
- package/dist/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
- package/dist/ts-builder/SdTsCompiler.js.map +1 -0
- package/dist/types/build-plugin.type.d.ts +14 -0
- package/dist/types/build-plugin.type.js +2 -0
- package/dist/types/build-plugin.type.js.map +1 -0
- package/dist/types/build.type.d.ts +15 -0
- package/dist/types/build.type.js +2 -0
- package/dist/types/build.type.js.map +1 -0
- package/dist/types/common-configs.type.d.ts +22 -0
- package/dist/types/common-configs.type.js +2 -0
- package/dist/types/common-configs.type.js.map +1 -0
- package/dist/types/sd-configs.type.d.ts +99 -0
- package/dist/types/sd-configs.type.js +2 -0
- package/dist/types/sd-configs.type.js.map +1 -0
- package/dist/types/ts-compiler.type.d.ts +29 -0
- package/dist/types/ts-compiler.type.js +2 -0
- package/dist/types/ts-compiler.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +49 -0
- package/dist/types/workers.type.js +2 -0
- package/dist/types/workers.type.js.map +1 -0
- package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
- package/dist/utils/SdCliConvertMessageUtil.js +137 -0
- package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
- package/dist/workers/compile-worker.js +27 -0
- package/dist/workers/compile-worker.js.map +1 -0
- package/dist/workers/lint-worker.js +36 -0
- package/dist/workers/lint-worker.js.map +1 -0
- package/dist/workers/server-worker.d.ts +1 -0
- package/dist/workers/server-worker.js +49 -0
- package/dist/workers/server-worker.js.map +1 -0
- package/lib/dev-worker.cjs +5 -0
- package/package.json +7 -10
- package/src/entry/SdCliCordova.ts +363 -0
- package/src/entry/SdCliElectron.ts +96 -69
- package/src/entry/SdCliLocalUpdate.ts +43 -44
- package/src/entry/SdCliProject.ts +72 -417
- package/src/index.ts +23 -20
- package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
- package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
- package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
- package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +125 -121
- package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
- package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
- package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
- package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
- package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
- package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
- package/src/sd-cli.ts +197 -211
- package/src/ts-builder/SdTsCompileWorker.ts +21 -0
- package/src/ts-builder/SdTsCompiler.ts +758 -0
- package/src/types/build-plugin.type.ts +16 -0
- package/src/types/build.type.ts +17 -0
- package/src/types/common-configs.type.ts +27 -0
- package/src/types/sd-configs.type.ts +114 -0
- package/src/types/ts-compiler.type.ts +29 -0
- package/src/types/workers.type.ts +27 -0
- package/src/utils/SdCliConvertMessageUtil.ts +177 -0
- package/src/workers/compile-worker.ts +31 -0
- package/src/workers/lint-worker.ts +44 -0
- package/src/workers/server-worker.ts +52 -0
- package/tsconfig.json +7 -1
- package/dist/build-cluster.js +0 -201
- package/dist/build-cluster.js.map +0 -1
- package/dist/build-tools/SdCliCordova.js.map +0 -1
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
- package/dist/build-tools/SdLinter.d.ts +0 -5
- package/dist/build-tools/SdLinter.js +0 -49
- package/dist/build-tools/SdLinter.js.map +0 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -29
- package/dist/build-tools/SdNgBundler.js.map +0 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
- package/dist/build-tools/SdReactBundler.d.ts +0 -25
- package/dist/build-tools/SdReactBundler.js +0 -295
- 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/build-tools/SdServerBundler.d.ts +0 -20
- package/dist/build-tools/SdServerBundler.js.map +0 -1
- package/dist/build-tools/SdTsCompiler.d.ts +0 -34
- package/dist/build-tools/SdTsCompiler.js.map +0 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
- package/dist/build-tools/SdTsLibBundler.js +0 -58
- package/dist/build-tools/SdTsLibBundler.js.map +0 -1
- package/dist/builders/SdCliClientBuilder.d.ts +0 -18
- package/dist/builders/SdCliClientBuilder.js +0 -172
- package/dist/builders/SdCliClientBuilder.js.map +0 -1
- package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
- package/dist/builders/SdCliJsLibLinter.js +0 -60
- package/dist/builders/SdCliJsLibLinter.js.map +0 -1
- package/dist/builders/SdCliServerBuilder.d.ts +0 -15
- package/dist/builders/SdCliServerBuilder.js.map +0 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
- package/dist/builders/SdCliTsLibBuilder.js +0 -90
- package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdReactPlugin.js +0 -117
- package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdServerPlugin.js +0 -63
- package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
- package/dist/commons.d.ts +0 -145
- package/dist/commons.js +0 -2
- package/dist/commons.js.map +0 -1
- package/dist/server-worker.js +0 -57
- package/dist/server-worker.js.map +0 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
- package/dist/utils/SdCliBuildResultUtil.js +0 -54
- package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
- package/src/build-cluster.ts +0 -212
- package/src/build-tools/SdCliCordova.ts +0 -340
- package/src/build-tools/SdLinter.ts +0 -65
- package/src/build-tools/SdNgBundlerContext.ts +0 -137
- package/src/build-tools/SdReactBundler.ts +0 -372
- package/src/build-tools/SdReactBundlerContext.ts +0 -71
- package/src/build-tools/SdTsCompiler.ts +0 -754
- package/src/build-tools/SdTsLibBundler.ts +0 -72
- package/src/builders/SdCliClientBuilder.ts +0 -233
- package/src/builders/SdCliJsLibLinter.ts +0 -72
- package/src/builders/SdCliTsLibBuilder.ts +0 -126
- package/src/bundle-plugins/sdReactPlugin.ts +0 -164
- package/src/bundle-plugins/sdServerPlugin.ts +0 -94
- package/src/commons.ts +0 -171
- package/src/server-worker.ts +0 -65
- package/src/utils/SdCliBuildResultUtil.ts +0 -63
- /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
- /package/dist/{server-worker.d.ts → workers/lint-worker.d.ts} +0 -0
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import esbuild from "esbuild";
|
|
2
|
-
import ts from "typescript";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import os from "os";
|
|
5
|
-
import { ISdTsCompilerResult, SdTsCompiler } from "../build-tools/SdTsCompiler";
|
|
6
4
|
import { JavaScriptTransformer } from "@angular/build/src/tools/esbuild/javascript-transformer";
|
|
7
|
-
import {
|
|
8
|
-
import { SdCliPerformanceTimer } from "
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { Logger, PathUtil, TNormPath } from "@simplysm/sd-core-node";
|
|
6
|
+
import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTime";
|
|
7
|
+
import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
|
|
8
|
+
import { ISdCliNgPluginResultCache } from "../../types/build-plugin.type";
|
|
9
|
+
import { ISdTsCompilerResult } from "../../types/ts-compiler.type";
|
|
10
|
+
import { SdTsCompileWorker } from "../../ts-builder/SdTsCompileWorker";
|
|
11
|
+
|
|
12
|
+
export function createSdNgPlugin(conf: {
|
|
13
|
+
pkgPath: TNormPath;
|
|
13
14
|
dev: boolean;
|
|
14
|
-
modifiedFileSet: Set<
|
|
15
|
-
result:
|
|
16
|
-
watchScopePaths:
|
|
15
|
+
modifiedFileSet: Set<TNormPath>;
|
|
16
|
+
result: ISdCliNgPluginResultCache;
|
|
17
|
+
watchScopePaths: TNormPath[];
|
|
17
18
|
}): esbuild.Plugin {
|
|
18
19
|
let perf: SdCliPerformanceTimer;
|
|
19
|
-
const logger = Logger.get(["simplysm", "sd-cli", "
|
|
20
|
+
const logger = Logger.get(["simplysm", "sd-cli", "createSdNgPlugin"]);
|
|
20
21
|
|
|
21
22
|
function debug(...msg: any[]): void {
|
|
22
23
|
logger.debug(`[${path.basename(conf.pkgPath)}]`, ...msg);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
return {
|
|
26
|
-
name: "sd-ng-
|
|
27
|
-
setup: (build: esbuild.PluginBuild) => {
|
|
28
|
-
const
|
|
27
|
+
name: "sd-ng-compile",
|
|
28
|
+
setup: async (build: esbuild.PluginBuild) => {
|
|
29
|
+
const tsCompiler = await SdTsCompileWorker.new({
|
|
29
30
|
pkgPath: conf.pkgPath,
|
|
30
31
|
additionalOptions: { declaration: false },
|
|
31
32
|
isDevMode: conf.dev,
|
|
@@ -33,9 +34,10 @@ export function sdNgPlugin(conf: {
|
|
|
33
34
|
watchScopePaths: conf.watchScopePaths,
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
let
|
|
37
|
-
const outputContentsCacheMap = new Map<
|
|
37
|
+
let tsCompileResult: ISdTsCompilerResult;
|
|
38
|
+
const outputContentsCacheMap = new Map<TNormPath, Uint8Array>();
|
|
38
39
|
|
|
40
|
+
// const cacheStore = new LmbdCacheStore(path.join(process.cwd(), "angular-compiler.db"));
|
|
39
41
|
//-- js babel transformer
|
|
40
42
|
const javascriptTransformer = new JavaScriptTransformer(
|
|
41
43
|
{
|
|
@@ -45,6 +47,7 @@ export function sdNgPlugin(conf: {
|
|
|
45
47
|
advancedOptimizations: true,
|
|
46
48
|
},
|
|
47
49
|
os.cpus().length,
|
|
50
|
+
// cacheStore.createCache("jstransformer"),
|
|
48
51
|
);
|
|
49
52
|
|
|
50
53
|
//---------------------------
|
|
@@ -53,30 +56,32 @@ export function sdNgPlugin(conf: {
|
|
|
53
56
|
perf = new SdCliPerformanceTimer("esbuild");
|
|
54
57
|
|
|
55
58
|
const res = await perf.run("typescript build", async () => {
|
|
56
|
-
compiler.invalidate(conf.modifiedFileSet);
|
|
57
59
|
for (const modifiedFile of conf.modifiedFileSet) {
|
|
58
60
|
outputContentsCacheMap.delete(modifiedFile);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
tsCompileResult = await tsCompiler.compileAsync(conf.modifiedFileSet);
|
|
62
64
|
|
|
63
|
-
conf.result.watchFileSet =
|
|
64
|
-
conf.result.affectedFileSet =
|
|
65
|
-
conf.result.program = buildResult.program;
|
|
65
|
+
conf.result.watchFileSet = tsCompileResult.watchFileSet;
|
|
66
|
+
conf.result.affectedFileSet = tsCompileResult.affectedFileSet;
|
|
66
67
|
|
|
68
|
+
const tsEsbuildResult = SdCliConvertMessageUtil.convertToEsbuildFromBuildMessages(
|
|
69
|
+
tsCompileResult.messages,
|
|
70
|
+
conf.pkgPath,
|
|
71
|
+
);
|
|
67
72
|
//-- return err/warn
|
|
68
73
|
return {
|
|
69
74
|
errors: [
|
|
70
|
-
...
|
|
71
|
-
|
|
72
|
-
.
|
|
73
|
-
|
|
75
|
+
...tsEsbuildResult.errors,
|
|
76
|
+
...Array.from(tsCompileResult.stylesheetBundlingResultMap.values())
|
|
77
|
+
.flatMap((item) => item.errors)
|
|
78
|
+
.filterExists(),
|
|
74
79
|
].filterExists(),
|
|
75
80
|
warnings: [
|
|
76
|
-
...
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
81
|
+
...tsEsbuildResult.warnings,
|
|
82
|
+
...Array.from(tsCompileResult.stylesheetBundlingResultMap.values())
|
|
83
|
+
.flatMap((item) => item.warnings)
|
|
84
|
+
.filterExists(),
|
|
80
85
|
],
|
|
81
86
|
};
|
|
82
87
|
});
|
|
@@ -86,12 +91,12 @@ export function sdNgPlugin(conf: {
|
|
|
86
91
|
});
|
|
87
92
|
|
|
88
93
|
build.onLoad({ filter: /\.ts$/ }, async (args) => {
|
|
89
|
-
const output = outputContentsCacheMap.get(
|
|
94
|
+
const output = outputContentsCacheMap.get(PathUtil.norm(args.path));
|
|
90
95
|
if (output != null) {
|
|
91
96
|
return { contents: output, loader: "js" };
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
const emittedJsFile =
|
|
99
|
+
const emittedJsFile = tsCompileResult.emittedFilesCacheMap.get(PathUtil.norm(args.path))?.last();
|
|
95
100
|
if (!emittedJsFile) {
|
|
96
101
|
throw new Error(`ts 빌더 결과 emit 파일이 존재하지 않습니다. ${args.path}`);
|
|
97
102
|
}
|
|
@@ -105,15 +110,15 @@ export function sdNgPlugin(conf: {
|
|
|
105
110
|
|
|
106
111
|
const newContents = await javascriptTransformer.transformData(args.path, contents, true, sideEffects);
|
|
107
112
|
|
|
108
|
-
outputContentsCacheMap.set(
|
|
113
|
+
outputContentsCacheMap.set(PathUtil.norm(args.path), newContents);
|
|
109
114
|
|
|
110
115
|
return { contents: newContents, loader: "js" };
|
|
111
116
|
});
|
|
112
117
|
|
|
113
118
|
build.onLoad({ filter: /\.[cm]?js$/ }, async (args) => {
|
|
114
|
-
conf.result.watchFileSet!.add(
|
|
119
|
+
conf.result.watchFileSet!.add(PathUtil.norm(args.path));
|
|
115
120
|
|
|
116
|
-
const output = outputContentsCacheMap.get(
|
|
121
|
+
const output = outputContentsCacheMap.get(PathUtil.norm(args.path));
|
|
117
122
|
if (output != null) {
|
|
118
123
|
return { contents: output, loader: "js" };
|
|
119
124
|
}
|
|
@@ -125,7 +130,7 @@ export function sdNgPlugin(conf: {
|
|
|
125
130
|
|
|
126
131
|
const newContents = await javascriptTransformer.transformFile(args.path, false, sideEffects);
|
|
127
132
|
|
|
128
|
-
outputContentsCacheMap.set(
|
|
133
|
+
outputContentsCacheMap.set(PathUtil.norm(args.path), newContents);
|
|
129
134
|
|
|
130
135
|
return {
|
|
131
136
|
contents: newContents,
|
|
@@ -144,7 +149,7 @@ export function sdNgPlugin(conf: {
|
|
|
144
149
|
),
|
|
145
150
|
},
|
|
146
151
|
(args) => {
|
|
147
|
-
conf.result.watchFileSet!.add(
|
|
152
|
+
conf.result.watchFileSet!.add(PathUtil.norm(args.path));
|
|
148
153
|
return null;
|
|
149
154
|
},
|
|
150
155
|
);
|
|
@@ -153,7 +158,7 @@ export function sdNgPlugin(conf: {
|
|
|
153
158
|
perf.end("transform & bundling");
|
|
154
159
|
debug(perf.toString());
|
|
155
160
|
|
|
156
|
-
for (const { outputFiles, metafile } of
|
|
161
|
+
for (const { outputFiles, metafile } of tsCompileResult.stylesheetBundlingResultMap.values()) {
|
|
157
162
|
result.outputFiles = result.outputFiles ?? [];
|
|
158
163
|
result.outputFiles.push(...outputFiles);
|
|
159
164
|
|
|
@@ -171,11 +176,3 @@ export function sdNgPlugin(conf: {
|
|
|
171
176
|
},
|
|
172
177
|
};
|
|
173
178
|
}
|
|
174
|
-
|
|
175
|
-
export interface INgPluginResultCache {
|
|
176
|
-
watchFileSet?: Set<string>;
|
|
177
|
-
affectedFileSet?: Set<string>;
|
|
178
|
-
program?: ts.Program;
|
|
179
|
-
outputFiles?: esbuild.OutputFile[];
|
|
180
|
-
metafile?: esbuild.Metafile;
|
|
181
|
-
}
|
|
@@ -2,18 +2,18 @@ import { FsUtil, PathUtil, SdFsWatcher } from "@simplysm/sd-core-node";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
export class SdCliIndexFileGenerator {
|
|
5
|
-
|
|
5
|
+
static watch(pkgPath: string, polyfills?: string[]) {
|
|
6
6
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
7
7
|
let cache = FsUtil.exists(indexFilePath) ? FsUtil.readFile(indexFilePath) : undefined;
|
|
8
8
|
|
|
9
|
-
SdFsWatcher.watch([path.resolve(pkgPath, "src")]).onChange({},
|
|
10
|
-
cache =
|
|
9
|
+
SdFsWatcher.watch([path.resolve(pkgPath, "src")]).onChange({ delay: 100 }, () => {
|
|
10
|
+
cache = this.run(pkgPath, polyfills, cache);
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
cache =
|
|
13
|
+
cache = this.run(pkgPath, polyfills, cache);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
static run(pkgPath: string, polyfills?: string[], cache?: string): string {
|
|
17
17
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
18
18
|
|
|
19
19
|
const importTexts: string[] = [];
|
|
@@ -26,13 +26,13 @@ export class SdCliIndexFileGenerator {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// 내부 파일들 import
|
|
29
|
-
const filePaths =
|
|
29
|
+
const filePaths = this.#getFilePaths(pkgPath);
|
|
30
30
|
for (const filePath of filePaths.orderBy()) {
|
|
31
31
|
const requirePath = PathUtil.posix(path.relative(path.dirname(indexFilePath), filePath))
|
|
32
32
|
.replace(/\.tsx?$/, "")
|
|
33
33
|
.replace(/\/index$/, "");
|
|
34
34
|
|
|
35
|
-
const sourceTsFileContent =
|
|
35
|
+
const sourceTsFileContent = FsUtil.readFile(filePath);
|
|
36
36
|
if (sourceTsFileContent.split("\n").some((line) => line.startsWith("export "))) {
|
|
37
37
|
importTexts.push(`export * from "./${requirePath}";`);
|
|
38
38
|
} else {
|
|
@@ -42,18 +42,18 @@ export class SdCliIndexFileGenerator {
|
|
|
42
42
|
|
|
43
43
|
const content = importTexts.join("\n") + "\n";
|
|
44
44
|
if (content.trim() !== cache?.trim()) {
|
|
45
|
-
|
|
45
|
+
FsUtil.writeFile(indexFilePath, content);
|
|
46
46
|
}
|
|
47
47
|
return content;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
static #getFilePaths(pkgPath: string): string[] {
|
|
51
51
|
const indexFilePath = path.resolve(pkgPath, "src/index.ts");
|
|
52
52
|
|
|
53
|
-
const tsconfig =
|
|
53
|
+
const tsconfig = FsUtil.readJson(path.resolve(pkgPath, "tsconfig.json"));
|
|
54
54
|
const entryFilePaths: string[] = tsconfig.files?.map((item) => path.resolve(pkgPath, item)) ?? [];
|
|
55
55
|
|
|
56
|
-
return
|
|
56
|
+
return FsUtil.glob(path.resolve(pkgPath, "src/**/*{.ts,.tsx}"), { nodir: true }).filter(
|
|
57
57
|
(item) => !entryFilePaths.includes(item) && item !== indexFilePath && !item.endsWith(".d.ts"),
|
|
58
58
|
);
|
|
59
59
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { FsUtil, Logger, PathUtil, SdFsWatcher, SdWorker } from "@simplysm/sd-core-node";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
|
|
5
|
+
import { TSdLintWorkerType } from "../../types/workers.type";
|
|
6
|
+
import { ISdProjectConfig } from "../../types/sd-configs.type";
|
|
7
|
+
import { ISdBuildRunnerResult } from "../../types/build.type";
|
|
8
|
+
|
|
9
|
+
export class SdJsLibBuildRunner extends EventEmitter {
|
|
10
|
+
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdJsLibBuildRunner"]);
|
|
11
|
+
private readonly _pkgName: string;
|
|
12
|
+
private readonly _lintWorker: SdWorker<TSdLintWorkerType>;
|
|
13
|
+
|
|
14
|
+
public constructor(
|
|
15
|
+
private readonly _projConf: ISdProjectConfig,
|
|
16
|
+
private readonly _pkgPath: string,
|
|
17
|
+
) {
|
|
18
|
+
super();
|
|
19
|
+
this._pkgName = path.basename(_pkgPath);
|
|
20
|
+
|
|
21
|
+
this._lintWorker = new SdWorker(import.meta.resolve("../../workers/lint-worker"));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public override on(event: "change", listener: () => void): this;
|
|
25
|
+
public override on(event: "complete", listener: (result: ISdBuildRunnerResult) => void): this;
|
|
26
|
+
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
27
|
+
super.on(event, listener);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public async buildAsync(): Promise<ISdBuildRunnerResult> {
|
|
32
|
+
this._debug("LINT...");
|
|
33
|
+
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
|
|
34
|
+
const srcFilePaths = FsUtil.glob(srcGlobPath);
|
|
35
|
+
|
|
36
|
+
const lintResults = await this._lintWorker.run("lint", [
|
|
37
|
+
{
|
|
38
|
+
cwd: this._pkgPath,
|
|
39
|
+
fileSet: new Set(srcFilePaths),
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
const messages = SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults);
|
|
43
|
+
|
|
44
|
+
this._debug(`LINT 완료`);
|
|
45
|
+
return {
|
|
46
|
+
affectedFilePathSet: new Set(srcFilePaths.map((item) => PathUtil.norm(item))),
|
|
47
|
+
buildMessages: messages,
|
|
48
|
+
emitFileSet: new Set(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public async watchAsync(): Promise<void> {
|
|
53
|
+
this.emit("change");
|
|
54
|
+
this._debug("LINT...");
|
|
55
|
+
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.js");
|
|
56
|
+
const srcFilePaths = FsUtil.glob(srcGlobPath);
|
|
57
|
+
|
|
58
|
+
const lintResults = await this._lintWorker.run("lint", [
|
|
59
|
+
{
|
|
60
|
+
cwd: this._pkgPath,
|
|
61
|
+
fileSet: new Set(srcFilePaths),
|
|
62
|
+
},
|
|
63
|
+
]);
|
|
64
|
+
const messages = SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(lintResults);
|
|
65
|
+
|
|
66
|
+
this._debug(`LINT 완료`);
|
|
67
|
+
const res: ISdBuildRunnerResult = {
|
|
68
|
+
affectedFilePathSet: new Set(srcFilePaths.map((item) => PathUtil.norm(item))),
|
|
69
|
+
buildMessages: messages,
|
|
70
|
+
emitFileSet: new Set(),
|
|
71
|
+
};
|
|
72
|
+
this.emit("complete", res);
|
|
73
|
+
|
|
74
|
+
SdFsWatcher.watch([srcGlobPath]).onChange({ delay: 300 }, async (changeInfos) => {
|
|
75
|
+
const watchFilePaths = changeInfos.filter((item) => FsUtil.exists(item.path)).map((item) => item.path);
|
|
76
|
+
if (watchFilePaths.length < 1) return;
|
|
77
|
+
|
|
78
|
+
this.emit("change");
|
|
79
|
+
|
|
80
|
+
this._debug("LINT...");
|
|
81
|
+
|
|
82
|
+
const watchLintResults = await this._lintWorker.run("lint", [
|
|
83
|
+
{
|
|
84
|
+
cwd: this._pkgPath,
|
|
85
|
+
fileSet: new Set(watchFilePaths),
|
|
86
|
+
},
|
|
87
|
+
]);
|
|
88
|
+
const watchMessages = SdCliConvertMessageUtil.convertToBuildMessagesFromEslint(watchLintResults);
|
|
89
|
+
|
|
90
|
+
this._debug(`LINT 완료`);
|
|
91
|
+
|
|
92
|
+
const watchRes: ISdBuildRunnerResult = {
|
|
93
|
+
affectedFilePathSet: new Set(changeInfos.map((item) => PathUtil.norm(item.path))),
|
|
94
|
+
buildMessages: watchMessages,
|
|
95
|
+
emitFileSet: new Set(),
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
this.emit("complete", watchRes);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private _debug(msg: string): void {
|
|
103
|
+
this._logger.debug(`[${this._pkgName}] ${msg}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { FsUtil, Logger, PathUtil, SdFsWatcher, TNormPath } from "@simplysm/sd-core-node";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { EventEmitter } from "events";
|
|
4
|
+
import { SdCliIndexFileGenerator } from "./SdCliIndexFileGenerator";
|
|
5
|
+
import { SdTsLibBuilder } from "./SdTsLibBuilder";
|
|
6
|
+
import { ISdLibPackageConfig, ISdProjectConfig } from "../../types/sd-configs.type";
|
|
7
|
+
import { ISdBuildMessage, ISdBuildRunnerResult } from "../../types/build.type";
|
|
8
|
+
|
|
9
|
+
export class SdTsLibBuildRunner extends EventEmitter {
|
|
10
|
+
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdCliTsLibBuilder"]);
|
|
11
|
+
|
|
12
|
+
readonly #projConf: ISdProjectConfig;
|
|
13
|
+
readonly #pkgPath: string;
|
|
14
|
+
readonly #pkgConf: ISdLibPackageConfig;
|
|
15
|
+
|
|
16
|
+
#builder?: SdTsLibBuilder;
|
|
17
|
+
|
|
18
|
+
public constructor(projConf: ISdProjectConfig, pkgPath: string) {
|
|
19
|
+
super();
|
|
20
|
+
this.#projConf = projConf;
|
|
21
|
+
this.#pkgPath = pkgPath;
|
|
22
|
+
|
|
23
|
+
this.#pkgConf = projConf.packages[path.basename(pkgPath)] as ISdLibPackageConfig;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public override on(event: "change", listener: () => void): this;
|
|
27
|
+
public override on(event: "complete", listener: (result: ISdBuildRunnerResult) => void): this;
|
|
28
|
+
public override on(event: string | symbol, listener: (...args: any[]) => void): this {
|
|
29
|
+
super.on(event, listener);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public async buildAsync(): Promise<ISdBuildRunnerResult> {
|
|
34
|
+
this._debug("dist 초기화...");
|
|
35
|
+
FsUtil.remove(path.resolve(this.#pkgPath, "dist"));
|
|
36
|
+
|
|
37
|
+
if (!this.#pkgConf.noGenIndex) {
|
|
38
|
+
this._debug("GEN index.ts...");
|
|
39
|
+
SdCliIndexFileGenerator.run(this.#pkgPath, this.#pkgConf.polyfills);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = await this._runAsync(false);
|
|
43
|
+
return {
|
|
44
|
+
affectedFilePathSet: result.affectedFileSet,
|
|
45
|
+
buildMessages: result.buildMessages,
|
|
46
|
+
emitFileSet: result.emitFileSet,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public async watchAsync(): Promise<void> {
|
|
51
|
+
this.emit("change");
|
|
52
|
+
|
|
53
|
+
this._debug("dist 초기화...");
|
|
54
|
+
FsUtil.remove(path.resolve(this.#pkgPath, "dist"));
|
|
55
|
+
|
|
56
|
+
if (!this.#pkgConf.noGenIndex) {
|
|
57
|
+
this._debug("WATCH GEN index.ts...");
|
|
58
|
+
SdCliIndexFileGenerator.watch(this.#pkgPath, this.#pkgConf.polyfills);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = await this._runAsync(true);
|
|
62
|
+
const res: ISdBuildRunnerResult = {
|
|
63
|
+
affectedFilePathSet: result.affectedFileSet,
|
|
64
|
+
buildMessages: result.buildMessages,
|
|
65
|
+
emitFileSet: result.emitFileSet,
|
|
66
|
+
};
|
|
67
|
+
this.emit("complete", res);
|
|
68
|
+
|
|
69
|
+
this._debug("WATCH...");
|
|
70
|
+
const watcher = SdFsWatcher.watch(Array.from(result.watchFileSet)).onChange({ delay: 300 }, async (changeInfos) => {
|
|
71
|
+
this.emit("change");
|
|
72
|
+
|
|
73
|
+
const changeFileSet = new Set(changeInfos.map((item) => PathUtil.norm(item.path)));
|
|
74
|
+
|
|
75
|
+
const watchResult = await this._runAsync(true, changeFileSet);
|
|
76
|
+
const watchRes: ISdBuildRunnerResult = {
|
|
77
|
+
affectedFilePathSet: watchResult.affectedFileSet,
|
|
78
|
+
buildMessages: watchResult.buildMessages,
|
|
79
|
+
emitFileSet: watchResult.emitFileSet,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
this.emit("complete", watchRes);
|
|
83
|
+
|
|
84
|
+
watcher.replaceWatchPaths(watchResult.watchFileSet);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private async _runAsync(
|
|
89
|
+
dev: boolean,
|
|
90
|
+
modifiedFileSet?: Set<TNormPath>,
|
|
91
|
+
): Promise<{
|
|
92
|
+
watchFileSet: Set<TNormPath>;
|
|
93
|
+
affectedFileSet: Set<TNormPath>;
|
|
94
|
+
buildMessages: ISdBuildMessage[];
|
|
95
|
+
emitFileSet: Set<TNormPath>;
|
|
96
|
+
}> {
|
|
97
|
+
const localUpdatePaths = Object.keys(this.#projConf.localUpdates ?? {})
|
|
98
|
+
.mapMany((key) => FsUtil.glob(path.resolve(this.#pkgPath, "../../node_modules", key)))
|
|
99
|
+
.map((item) => PathUtil.norm(item));
|
|
100
|
+
|
|
101
|
+
this._debug(`BUILD...`);
|
|
102
|
+
this.#builder ??= await SdTsLibBuilder.new(PathUtil.norm(this.#pkgPath), dev, [
|
|
103
|
+
PathUtil.norm(this.#pkgPath, "../"),
|
|
104
|
+
...localUpdatePaths,
|
|
105
|
+
]);
|
|
106
|
+
const buildResult = await this.#builder.buildAsync(modifiedFileSet);
|
|
107
|
+
|
|
108
|
+
this._debug(`빌드 완료`);
|
|
109
|
+
const watchFileSet = new Set(
|
|
110
|
+
Array.from(buildResult.watchFileSet).filter(
|
|
111
|
+
(item) =>
|
|
112
|
+
PathUtil.isChildPath(item, path.resolve(this.#pkgPath, "../")) ||
|
|
113
|
+
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu)),
|
|
114
|
+
),
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
watchFileSet,
|
|
119
|
+
affectedFileSet: buildResult.affectedFileSet,
|
|
120
|
+
buildMessages: buildResult.results,
|
|
121
|
+
emitFileSet: buildResult.emitFileSet,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private _debug(msg: string): void {
|
|
126
|
+
this.#logger.debug(`[${path.basename(this.#pkgPath)}] ${msg}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
|
|
3
|
+
import { FsUtil, PathUtil, TNormPath } from "@simplysm/sd-core-node";
|
|
4
|
+
import { ISdBuildMessage } from "../../types/build.type";
|
|
5
|
+
import { SdTsCompileWorker } from "../../ts-builder/SdTsCompileWorker";
|
|
6
|
+
|
|
7
|
+
export class SdTsLibBuilder {
|
|
8
|
+
static async new(pkgPath: TNormPath, dev: boolean, watchScopePaths: TNormPath[]) {
|
|
9
|
+
const tsCompiler = await SdTsCompileWorker.new({
|
|
10
|
+
pkgPath,
|
|
11
|
+
additionalOptions: { declaration: true },
|
|
12
|
+
isDevMode: dev,
|
|
13
|
+
globalStyleFilePath: PathUtil.norm(pkgPath, "src/styles.scss"),
|
|
14
|
+
isForBundle: false,
|
|
15
|
+
watchScopePaths: watchScopePaths,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return new SdTsLibBuilder(tsCompiler, pkgPath);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private constructor(
|
|
22
|
+
private _compiler: SdTsCompileWorker,
|
|
23
|
+
private _pkgPath: string,
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
public async buildAsync(modifiedFileSet?: Set<TNormPath>): Promise<{
|
|
27
|
+
watchFileSet: Set<TNormPath>;
|
|
28
|
+
affectedFileSet: Set<TNormPath>;
|
|
29
|
+
results: ISdBuildMessage[];
|
|
30
|
+
emitFileSet: Set<TNormPath>;
|
|
31
|
+
}> {
|
|
32
|
+
const tsCompileResult = await this._compiler.compileAsync(modifiedFileSet);
|
|
33
|
+
|
|
34
|
+
const emitFileSet = new Set<TNormPath>();
|
|
35
|
+
for (const emitFile of tsCompileResult.emitFileSet) {
|
|
36
|
+
const emitFileInfos = tsCompileResult.emittedFilesCacheMap.get(emitFile);
|
|
37
|
+
if (emitFileInfos) {
|
|
38
|
+
for (const emitFileInfo of emitFileInfos) {
|
|
39
|
+
if (emitFileInfo.outAbsPath != null) {
|
|
40
|
+
FsUtil.writeFile(emitFileInfo.outAbsPath, emitFileInfo.text);
|
|
41
|
+
emitFileSet.add(emitFileInfo.outAbsPath);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const globalStylesheetBundlingResult = tsCompileResult.stylesheetBundlingResultMap.get(emitFile);
|
|
47
|
+
if (globalStylesheetBundlingResult) {
|
|
48
|
+
for (const outputFile of globalStylesheetBundlingResult.outputFiles) {
|
|
49
|
+
const distPath = PathUtil.norm(this._pkgPath, "dist", path.relative(this._pkgPath, outputFile.path));
|
|
50
|
+
if (PathUtil.isChildPath(distPath, path.resolve(this._pkgPath, "dist"))) {
|
|
51
|
+
FsUtil.writeFile(distPath, outputFile.text);
|
|
52
|
+
emitFileSet.add(distPath);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const styleResults = Array.from(tsCompileResult.stylesheetBundlingResultMap.values()).mapMany((item) =>
|
|
59
|
+
SdCliConvertMessageUtil.convertToBuildMessagesFromEsbuild(item, this._pkgPath),
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
watchFileSet: tsCompileResult.watchFileSet,
|
|
64
|
+
affectedFileSet: tsCompileResult.affectedFileSet,
|
|
65
|
+
results: [...tsCompileResult.messages, ...styleResults],
|
|
66
|
+
emitFileSet,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|