@simplysm/sd-cli 11.1.44 → 11.1.46
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-cluster.js +124 -105
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdCliCordova.js.map +1 -1
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -1
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +1 -1
- package/dist/build-tools/SdNgBundler.js +8 -5
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +1 -1
- package/dist/build-tools/SdServerBundler.js +1 -1
- package/dist/build-tools/SdServerBundler.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +5 -21
- package/dist/build-tools/SdTsCompiler.js +211 -188
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/build-tools2/SdTsCompiler2.d.ts +26 -0
- package/dist/build-tools2/SdTsCompiler2.js +280 -0
- package/dist/build-tools2/SdTsCompiler2.js.map +1 -0
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +7 -12
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +3 -3
- package/dist/bundle-plugins/sdNgPlugin.js +23 -213
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +2 -2
- package/dist/bundle-plugins/sdServerPlugin.js +17 -110
- package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
- package/dist/commons.d.ts +1 -0
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -0
- package/dist/entry/SdCliProject.js +20 -37
- 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/sd-cli.js +7 -1
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +10 -0
- package/dist/utils/SdCliBuildResultUtil.js +17 -1
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/package.json +16 -16
- package/src/build-cluster.ts +152 -132
- package/src/build-tools/SdNgBundler.ts +7 -4
- package/src/build-tools/SdServerBundler.ts +2 -2
- package/src/build-tools/SdTsCompiler.ts +64 -94
- package/src/build-tools2/SdTsCompiler2.ts +427 -0
- package/src/builders/SdCliTsLibBuilder.ts +7 -12
- package/src/bundle-plugins/sdNgPlugin.ts +26 -320
- package/src/bundle-plugins/sdServerPlugin.ts +20 -168
- package/src/commons.ts +1 -0
- package/src/entry/SdCliProject.ts +33 -38
- package/src/index.ts +1 -0
- package/src/sd-cli.ts +7 -1
- package/src/server-worker.ts +3 -3
- package/src/utils/SdCliBuildResultUtil.ts +22 -3
package/src/build-cluster.ts
CHANGED
|
@@ -39,9 +39,10 @@ if (cluster.isPrimary) {
|
|
|
39
39
|
sendMessage(message);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
process.on("message", (message) => {
|
|
42
|
+
process.on("message", (message: ISdCliBuildClusterReqMessage) => {
|
|
43
43
|
cluster.fork({
|
|
44
|
-
"SD_CLUSTER_MESSAGE": JSON.stringify(message)
|
|
44
|
+
"SD_CLUSTER_MESSAGE": JSON.stringify(message),
|
|
45
|
+
"NODE_OPTIONS": message.execArgs?.join(" ")
|
|
45
46
|
});
|
|
46
47
|
});
|
|
47
48
|
process.send!("ready");
|
|
@@ -50,143 +51,162 @@ else {
|
|
|
50
51
|
const message = JSON.parse(process.env["SD_CLUSTER_MESSAGE"]!) as ISdCliBuildClusterReqMessage;
|
|
51
52
|
const pkgConf = message.projConf.packages[path.basename(message.pkgPath)]!;
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
try {
|
|
55
|
+
if (message.cmd === "watch") {
|
|
56
|
+
// [library] javascript
|
|
57
|
+
if (pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
58
|
+
await new SdCliJsLibLinter(message.pkgPath)
|
|
59
|
+
.on("change", () => {
|
|
60
|
+
sendMessage({
|
|
61
|
+
type: "change",
|
|
62
|
+
req: message
|
|
63
|
+
});
|
|
64
|
+
})
|
|
65
|
+
.on("complete", (result) => {
|
|
66
|
+
sendMessage({
|
|
67
|
+
type: "complete",
|
|
68
|
+
result,
|
|
69
|
+
req: message
|
|
70
|
+
});
|
|
71
|
+
logMemory(message);
|
|
72
|
+
})
|
|
73
|
+
.watchAsync();
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
sendMessage({
|
|
76
|
+
type: "ready",
|
|
77
|
+
req: message
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// [library] typescript
|
|
81
|
+
else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
82
|
+
await new SdCliTsLibBuilder(message.projConf, message.pkgPath)
|
|
83
|
+
.on("change", () => {
|
|
84
|
+
sendMessage({
|
|
85
|
+
type: "change",
|
|
86
|
+
req: message
|
|
87
|
+
});
|
|
88
|
+
})
|
|
89
|
+
.on("complete", (result) => {
|
|
90
|
+
sendMessage({
|
|
91
|
+
type: "complete",
|
|
92
|
+
result,
|
|
93
|
+
req: message
|
|
94
|
+
});
|
|
95
|
+
logMemory(message);
|
|
96
|
+
})
|
|
97
|
+
.watchAsync();
|
|
98
|
+
sendMessage({
|
|
99
|
+
type: "ready",
|
|
100
|
+
req: message
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// [server]
|
|
104
|
+
else if (pkgConf.type === "server") {
|
|
105
|
+
await new SdCliServerBuilder(message.projConf, message.pkgPath)
|
|
106
|
+
.on("change", () => {
|
|
107
|
+
sendMessage({
|
|
108
|
+
type: "change",
|
|
109
|
+
req: message
|
|
110
|
+
});
|
|
111
|
+
})
|
|
112
|
+
.on("complete", (result) => {
|
|
113
|
+
sendMessage({
|
|
114
|
+
type: "complete",
|
|
115
|
+
result,
|
|
116
|
+
req: message
|
|
117
|
+
});
|
|
118
|
+
logMemory(message);
|
|
119
|
+
})
|
|
120
|
+
.watchAsync();
|
|
121
|
+
sendMessage({
|
|
122
|
+
type: "ready",
|
|
123
|
+
req: message
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// [client]
|
|
127
|
+
else if (pkgConf.type === "client") {
|
|
128
|
+
await new SdCliClientBuilder(message.projConf, message.pkgPath)
|
|
129
|
+
.on("change", () => {
|
|
130
|
+
sendMessage({
|
|
131
|
+
type: "change",
|
|
132
|
+
req: message
|
|
133
|
+
});
|
|
134
|
+
})
|
|
135
|
+
.on("complete", (result) => {
|
|
136
|
+
sendMessage({
|
|
137
|
+
type: "complete",
|
|
138
|
+
result,
|
|
139
|
+
req: message
|
|
140
|
+
});
|
|
141
|
+
logMemory(message);
|
|
142
|
+
})
|
|
143
|
+
.watchAsync();
|
|
144
|
+
sendMessage({
|
|
145
|
+
type: "ready",
|
|
146
|
+
req: message
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new NeverEntryError();
|
|
151
|
+
}
|
|
76
152
|
}
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// [client]
|
|
122
|
-
else if (pkgConf.type === "client") {
|
|
123
|
-
await new SdCliClientBuilder(message.projConf, message.pkgPath)
|
|
124
|
-
.on("change", () => {
|
|
125
|
-
sendMessage({
|
|
126
|
-
type: "change",
|
|
127
|
-
req: message
|
|
128
|
-
});
|
|
129
|
-
})
|
|
130
|
-
.on("complete", (result) => {
|
|
131
|
-
sendMessage({
|
|
132
|
-
type: "complete",
|
|
133
|
-
result,
|
|
134
|
-
req: message
|
|
135
|
-
});
|
|
136
|
-
})
|
|
137
|
-
.watchAsync();
|
|
138
|
-
sendMessage({
|
|
139
|
-
type: "ready",
|
|
140
|
-
req: message
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
throw new NeverEntryError();
|
|
153
|
+
else { // build
|
|
154
|
+
// [library] javascript
|
|
155
|
+
if (pkgConf.type === "library" && !FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
156
|
+
const result = await new SdCliJsLibLinter(message.pkgPath).buildAsync();
|
|
157
|
+
sendMessage({
|
|
158
|
+
type: "complete",
|
|
159
|
+
result,
|
|
160
|
+
req: message
|
|
161
|
+
});
|
|
162
|
+
logMemory(message);
|
|
163
|
+
}
|
|
164
|
+
// [library] typescript
|
|
165
|
+
else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
166
|
+
const result = await new SdCliTsLibBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
167
|
+
sendMessage({
|
|
168
|
+
type: "complete",
|
|
169
|
+
result,
|
|
170
|
+
req: message
|
|
171
|
+
});
|
|
172
|
+
logMemory(message);
|
|
173
|
+
}
|
|
174
|
+
// [server]
|
|
175
|
+
else if (pkgConf.type === "server") {
|
|
176
|
+
const result = await new SdCliServerBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
177
|
+
sendMessage({
|
|
178
|
+
type: "complete",
|
|
179
|
+
result,
|
|
180
|
+
req: message,
|
|
181
|
+
});
|
|
182
|
+
logMemory(message);
|
|
183
|
+
}
|
|
184
|
+
// [client]
|
|
185
|
+
else if (pkgConf.type === "client") {
|
|
186
|
+
const result = await new SdCliClientBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
187
|
+
sendMessage({
|
|
188
|
+
type: "complete",
|
|
189
|
+
result,
|
|
190
|
+
req: message,
|
|
191
|
+
});
|
|
192
|
+
logMemory(message);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
throw new NeverEntryError();
|
|
196
|
+
}
|
|
145
197
|
}
|
|
146
198
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const result = await new SdCliJsLibLinter(message.pkgPath).buildAsync();
|
|
151
|
-
sendMessage({
|
|
152
|
-
type: "complete",
|
|
153
|
-
result,
|
|
154
|
-
req: message
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
// [library] typescript
|
|
158
|
-
else if (pkgConf.type === "library" && FsUtil.exists(path.resolve(message.pkgPath, "tsconfig.json"))) {
|
|
159
|
-
const result = await new SdCliTsLibBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
160
|
-
sendMessage({
|
|
161
|
-
type: "complete",
|
|
162
|
-
result,
|
|
163
|
-
req: message
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
// [server]
|
|
167
|
-
else if (pkgConf.type === "server") {
|
|
168
|
-
const result = await new SdCliServerBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
169
|
-
sendMessage({
|
|
170
|
-
type: "complete",
|
|
171
|
-
result,
|
|
172
|
-
req: message
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
// [client]
|
|
176
|
-
else if (pkgConf.type === "client") {
|
|
177
|
-
const result = await new SdCliClientBuilder(message.projConf, message.pkgPath).buildAsync();
|
|
178
|
-
sendMessage({
|
|
179
|
-
type: "complete",
|
|
180
|
-
result,
|
|
181
|
-
req: message
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
throw new NeverEntryError();
|
|
186
|
-
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
logger.error(`${message.pkgPath}:${message.cmd}`, err);
|
|
201
|
+
throw err;
|
|
187
202
|
}
|
|
188
203
|
}
|
|
189
204
|
|
|
190
205
|
function sendMessage(message: ISdCliBuildClusterResMessage): void {
|
|
191
206
|
process.send!(message);
|
|
192
207
|
}
|
|
208
|
+
|
|
209
|
+
function logMemory(message: ISdCliBuildClusterReqMessage) {
|
|
210
|
+
/*global.gc!();
|
|
211
|
+
logger.log(`[${process.pid}:${path.basename(message.pkgPath)}] 메모리 사용량: ${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`);*/
|
|
212
|
+
}
|
|
@@ -37,7 +37,7 @@ import {Entrypoint} from "@angular-devkit/build-angular/src/utils/index-file/aug
|
|
|
37
37
|
import {CrossOrigin} from "@angular-devkit/build-angular";
|
|
38
38
|
import {InlineCriticalCssProcessor} from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
|
|
39
39
|
import {SdNgBundlerContext} from "./SdNgBundlerContext";
|
|
40
|
-
import {
|
|
40
|
+
import {INgPluginResultCache, sdNgPlugin} from "../bundle-plugins/sdNgPlugin";
|
|
41
41
|
import {MemoryLoadResultCache} from "@angular-devkit/build-angular/src/tools/esbuild/load-result-cache";
|
|
42
42
|
import ts from "typescript";
|
|
43
43
|
|
|
@@ -47,7 +47,10 @@ export class SdNgBundler {
|
|
|
47
47
|
// );
|
|
48
48
|
|
|
49
49
|
#modifiedFileSet = new Set<string>();
|
|
50
|
-
#ngResultCache:
|
|
50
|
+
#ngResultCache: INgPluginResultCache = {
|
|
51
|
+
affectedFileSet: new Set<string>(),
|
|
52
|
+
watchFileSet: new Set<string>()
|
|
53
|
+
};
|
|
51
54
|
#styleLoadResultCache = new MemoryLoadResultCache();
|
|
52
55
|
|
|
53
56
|
private _contexts: SdNgBundlerContext[] | undefined;
|
|
@@ -92,7 +95,7 @@ export class SdNgBundler {
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
public async bundleAsync(): Promise<{
|
|
95
|
-
program
|
|
98
|
+
program?: ts.Program;
|
|
96
99
|
watchFileSet: Set<string>,
|
|
97
100
|
affectedFileSet: Set<string>,
|
|
98
101
|
results: ISdCliPackageBuildResult[]
|
|
@@ -213,7 +216,7 @@ export class SdNgBundler {
|
|
|
213
216
|
logger.debug(`[${path.basename(this._opt.pkgPath)}] 번들링중 영향받은 파일`, Array.from(this.#ngResultCache.affectedFileSet!));
|
|
214
217
|
|
|
215
218
|
return {
|
|
216
|
-
program: this.#ngResultCache.program
|
|
219
|
+
program: this.#ngResultCache.program,
|
|
217
220
|
watchFileSet: new Set([
|
|
218
221
|
...this.#ngResultCache.watchFileSet!,
|
|
219
222
|
...this.#styleLoadResultCache.watchFiles
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {ISdCliPackageBuildResult} from "../commons";
|
|
2
2
|
import esbuild from "esbuild";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import {
|
|
4
|
+
import {IServerPluginResultCache, sdServerPlugin} from "../bundle-plugins/sdServerPlugin";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
import {Logger} from "@simplysm/sd-core-node";
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ export class SdServerBundler {
|
|
|
11
11
|
#context?: esbuild.BuildContext;
|
|
12
12
|
|
|
13
13
|
#modifiedFileSet = new Set<string>();
|
|
14
|
-
#resultCache:
|
|
14
|
+
#resultCache: IServerPluginResultCache = {};
|
|
15
15
|
|
|
16
16
|
constructor(private readonly _opt: {
|
|
17
17
|
dev: boolean;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
1
|
import {SdCliBuildResultUtil} from "../utils/SdCliBuildResultUtil";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import * as sass from "sass";
|
|
2
|
+
import {ISdCliPackageBuildResult} from "../commons";
|
|
3
|
+
import {SdTsCompiler2} from "../build-tools2/SdTsCompiler2";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import {FsUtil, PathUtil} from "@simplysm/sd-core-node";
|
|
10
7
|
|
|
11
8
|
export class SdTsCompiler {
|
|
12
|
-
private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
|
|
9
|
+
/*private readonly _logger = Logger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
|
|
13
10
|
|
|
14
11
|
private readonly _parsedTsConfig: ts.ParsedCommandLine;
|
|
15
12
|
private readonly _writeFileCache = new Map<string, string>();
|
|
@@ -21,81 +18,33 @@ export class SdTsCompiler {
|
|
|
21
18
|
private readonly _isForAngular: boolean;
|
|
22
19
|
private _ngProgram?: NgtscProgram;
|
|
23
20
|
private readonly _styleDepsCache = new Map<string, Set<string>>();
|
|
24
|
-
private _markedChanges: string[] = []
|
|
21
|
+
private _markedChanges: string[] = [];*/
|
|
22
|
+
|
|
23
|
+
program?: ts.Program;
|
|
24
|
+
|
|
25
|
+
readonly #compiler: SdTsCompiler2;
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
readonly #pkgPath: string;
|
|
28
|
+
|
|
29
|
+
/*public get program(): ts.Program {
|
|
27
30
|
if (!this._program) {
|
|
28
31
|
throw new Error("TS 프로그램 NULL");
|
|
29
32
|
}
|
|
30
33
|
return this._program;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public constructor(
|
|
34
|
-
pkgPath
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const tsConfigFilePath = path.resolve(_opt.pkgPath, "tsconfig.json");
|
|
41
|
-
const tsConfig = FsUtil.readJson(tsConfigFilePath) as ITsConfig;
|
|
42
|
-
this._parsedTsConfig = ts.parseJsonConfigFileContent(
|
|
43
|
-
tsConfig,
|
|
44
|
-
ts.sys,
|
|
45
|
-
_opt.pkgPath,
|
|
46
|
-
{
|
|
47
|
-
...tsConfig.angularCompilerOptions ?? {},
|
|
48
|
-
..._opt.emitDts !== undefined ? {declaration: _opt.emitDts} : {}
|
|
49
|
-
}
|
|
34
|
+
}*/
|
|
35
|
+
|
|
36
|
+
public constructor(pkgPath: string, dev: boolean) {
|
|
37
|
+
this.#pkgPath = pkgPath;
|
|
38
|
+
this.#compiler = new SdTsCompiler2(
|
|
39
|
+
pkgPath,
|
|
40
|
+
{declaration: true},
|
|
41
|
+
dev,
|
|
42
|
+
path.resolve(pkgPath, "src/styles.scss")
|
|
50
43
|
);
|
|
51
|
-
|
|
52
|
-
//-- vars
|
|
53
|
-
this._isForAngular = Boolean(tsConfig.angularCompilerOptions);
|
|
54
|
-
|
|
55
|
-
//-- host
|
|
56
|
-
this._compilerHost = ts.createIncrementalCompilerHost(this._parsedTsConfig.options);
|
|
57
|
-
if (tsConfig.angularCompilerOptions) {
|
|
58
|
-
this._compilerHost["readResource"] = (fileName: string) => {
|
|
59
|
-
return this._compilerHost.readFile(fileName);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
this._compilerHost["transformResource"] = async (data: string, context: {
|
|
63
|
-
type: string,
|
|
64
|
-
containingFile: string,
|
|
65
|
-
resourceFile: any
|
|
66
|
-
}) => {
|
|
67
|
-
if (context.resourceFile != null || context.type !== "style") {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
const scssResult = await sass.compileStringAsync(data, {
|
|
73
|
-
url: new URL((context.containingFile as string) + ".scss"),
|
|
74
|
-
importer: {
|
|
75
|
-
findFileUrl: (url) => pathToFileURL(url)
|
|
76
|
-
},
|
|
77
|
-
logger: sass.Logger.silent
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const styleContent = scssResult.css.toString();
|
|
81
|
-
|
|
82
|
-
const deps = scssResult.loadedUrls.slice(1).map((item) => path.resolve(fileURLToPath(item.href)));
|
|
83
|
-
for (const dep of deps) {
|
|
84
|
-
const depCache = this._styleDepsCache.getOrCreate(dep, new Set<string>());
|
|
85
|
-
depCache.add(path.resolve(context.containingFile));
|
|
86
|
-
}
|
|
87
|
-
return {content: styleContent};
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
this._logger.error("scss 파싱 에러", err);
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
44
|
}
|
|
96
45
|
|
|
97
|
-
public markChanges(
|
|
98
|
-
this.
|
|
46
|
+
public markChanges(modifiedFileSet: Set<string>): void {
|
|
47
|
+
this.#compiler.invalidate(modifiedFileSet);
|
|
99
48
|
}
|
|
100
49
|
|
|
101
50
|
public async buildAsync(): Promise<{
|
|
@@ -103,11 +52,36 @@ export class SdTsCompiler {
|
|
|
103
52
|
affectedFileSet: Set<string>;
|
|
104
53
|
results: ISdCliPackageBuildResult[];
|
|
105
54
|
}> {
|
|
106
|
-
const
|
|
55
|
+
const buildResult = await this.#compiler.buildAsync();
|
|
56
|
+
this.program = buildResult.program;
|
|
57
|
+
|
|
58
|
+
for (const affectedFilePath of buildResult.affectedFileSet) {
|
|
59
|
+
const emittedFiles = buildResult.emittedFilesCacheMap.get(affectedFilePath) ?? [];
|
|
60
|
+
for (const emittedFile of emittedFiles) {
|
|
61
|
+
if (emittedFile.outRelPath != null) {
|
|
62
|
+
const distPath = path.resolve(this.#pkgPath, "dist", emittedFile.outRelPath);
|
|
63
|
+
if (PathUtil.isChildPath(distPath, path.resolve(this.#pkgPath, "dist"))) {
|
|
64
|
+
await FsUtil.writeFileAsync(distPath, emittedFile.text);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const globalStylesheetResult = buildResult.stylesheetResultMap.get(affectedFilePath);
|
|
70
|
+
if (globalStylesheetResult) {
|
|
71
|
+
for (const outputFile of globalStylesheetResult.outputFiles) {
|
|
72
|
+
const distPath = path.resolve(this.#pkgPath, "dist", path.relative(this.#pkgPath, outputFile.path));
|
|
73
|
+
if (PathUtil.isChildPath(distPath, path.resolve(this.#pkgPath, "dist"))) {
|
|
74
|
+
await FsUtil.writeFileAsync(distPath, outputFile.text);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/*const markedChanges = this._markedChanges;
|
|
107
81
|
this._markedChanges = [];
|
|
108
82
|
|
|
109
83
|
const distPath = path.resolve(this._opt.pkgPath, "dist");
|
|
110
|
-
const srcFilePaths = await FsUtil.globAsync(path.resolve(this._opt.pkgPath, "src
|
|
84
|
+
const srcFilePaths = await FsUtil.globAsync(path.resolve(this._opt.pkgPath, "src/!**!/!*.{ts,tsx}"));
|
|
111
85
|
const srcFilePathSet = new Set<string>(srcFilePaths);
|
|
112
86
|
|
|
113
87
|
if (this._isForAngular) {
|
|
@@ -139,12 +113,12 @@ export class SdTsCompiler {
|
|
|
139
113
|
);
|
|
140
114
|
}
|
|
141
115
|
else {
|
|
142
|
-
|
|
116
|
+
/!*this._program = ts.createProgram(
|
|
143
117
|
srcFilePaths,
|
|
144
118
|
this._parsedTsConfig.options,
|
|
145
119
|
this._compilerHost,
|
|
146
120
|
this._program
|
|
147
|
-
)
|
|
121
|
+
);*!/
|
|
148
122
|
|
|
149
123
|
this._builder = ts.createIncrementalProgram({
|
|
150
124
|
rootNames: srcFilePaths,
|
|
@@ -295,22 +269,18 @@ export class SdTsCompiler {
|
|
|
295
269
|
|
|
296
270
|
this._logger.debug(`[${path.basename(this._opt.pkgPath)}] 영향받는 파일 ${this._opt.emit ? "EMIT" : "CHECK"} 완료`, affectedFileSet);
|
|
297
271
|
|
|
298
|
-
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, this._opt.emit ? "build" : "check"))
|
|
272
|
+
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, this._opt.emit ? "build" : "check"));*/
|
|
299
273
|
|
|
300
274
|
return {
|
|
301
|
-
watchFileSet:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
275
|
+
watchFileSet: buildResult.watchFileSet,
|
|
276
|
+
affectedFileSet: buildResult.affectedFileSet,
|
|
277
|
+
results: [
|
|
278
|
+
...buildResult.typescriptDiagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, "build")),
|
|
279
|
+
...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.errors!)
|
|
280
|
+
.map(err => SdCliBuildResultUtil.convertFromEsbuildResult(err, "build", "error")),
|
|
281
|
+
/*...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.warnings!)
|
|
282
|
+
.map(warn => SdCliBuildResultUtil.convertFromEsbuildResult(warn, "build", "warning"))*/
|
|
283
|
+
]
|
|
307
284
|
};
|
|
308
285
|
}
|
|
309
|
-
|
|
310
|
-
private _writeFile(filePath: string, data: string): void {
|
|
311
|
-
if (this._writeFileCache.get(filePath) !== data) {
|
|
312
|
-
this._compilerHost.writeFile(filePath, data, false);
|
|
313
|
-
}
|
|
314
|
-
this._writeFileCache.set(filePath, data);
|
|
315
|
-
}
|
|
316
286
|
}
|