@simplysm/sd-cli 11.1.20 → 11.1.21
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/SdLinter.d.ts +1 -1
- package/dist/build-tools/SdLinter.js +2 -2
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +2 -2
- package/dist/build-tools/SdNgBundler.js +2 -2
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/{SdTsBundler.d.ts → SdServerBundler.d.ts} +6 -2
- package/dist/build-tools/{SdTsBundler.js → SdServerBundler.js} +18 -14
- package/dist/build-tools/SdServerBundler.js.map +1 -0
- package/dist/build-tools/SdTsCompiler.d.ts +2 -2
- package/dist/build-tools/SdTsCompiler.js +10 -12
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +22 -12
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.js +31 -31
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +22 -12
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.js +1 -1
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +15 -0
- package/dist/bundle-plugins/sdServerPlugin.js +132 -0
- package/dist/bundle-plugins/sdServerPlugin.js.map +1 -0
- package/dist/commons.d.ts +0 -1
- package/dist/entry/SdCliLocalUpdate.js +2 -2
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.js +1 -1
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/build-tools/SdLinter.ts +2 -2
- package/src/build-tools/SdNgBundler.ts +4 -4
- package/src/build-tools/{SdTsBundler.ts → SdServerBundler.ts} +22 -18
- package/src/build-tools/SdTsCompiler.ts +12 -14
- package/src/builders/SdCliClientBuilder.ts +24 -14
- package/src/builders/SdCliServerBuilder.ts +38 -39
- package/src/builders/SdCliTsLibBuilder.ts +24 -14
- package/src/bundle-plugins/sdNgPlugin.ts +1 -1
- package/src/bundle-plugins/sdServerPlugin.ts +211 -0
- package/src/commons.ts +0 -1
- package/src/entry/SdCliLocalUpdate.ts +3 -8
- package/src/entry/SdCliProject.ts +1 -1
- package/src/index.ts +2 -3
- package/dist/build-tools/SdTsBundler.js.map +0 -1
- package/dist/bundle-plugins/sdLoadedFilesPlugin.d.ts +0 -4
- package/dist/bundle-plugins/sdLoadedFilesPlugin.js +0 -15
- package/dist/bundle-plugins/sdLoadedFilesPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdTscPlugin.d.ts +0 -5
- package/dist/bundle-plugins/sdTscPlugin.js +0 -21
- package/dist/bundle-plugins/sdTscPlugin.js.map +0 -1
- package/src/bundle-plugins/sdLoadedFilesPlugin.ts +0 -19
- package/src/bundle-plugins/sdTscPlugin.ts +0 -25
|
@@ -93,8 +93,8 @@ export class SdNgBundler {
|
|
|
93
93
|
|
|
94
94
|
public async bundleAsync(): Promise<{
|
|
95
95
|
program: ts.Program;
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
watchFileSet: Set<string>,
|
|
97
|
+
affectedFileSet: Set<string>,
|
|
98
98
|
results: ISdCliPackageBuildResult[]
|
|
99
99
|
}> {
|
|
100
100
|
const logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler", "bundleAsync"]);
|
|
@@ -211,8 +211,8 @@ export class SdNgBundler {
|
|
|
211
211
|
|
|
212
212
|
return {
|
|
213
213
|
program: this.#ngResultCache.program!,
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
watchFileSet: this.#ngResultCache.watchFileSet!,
|
|
215
|
+
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
216
216
|
results
|
|
217
217
|
};
|
|
218
218
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {ISdCliPackageBuildResult} from "../commons";
|
|
2
2
|
import esbuild from "esbuild";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import {IServerBundlerResultCache, sdServerPlugin} from "../bundle-plugins/sdServerPlugin";
|
|
4
5
|
import ts from "typescript";
|
|
5
|
-
import {FsUtil} from "@simplysm/sd-core-node";
|
|
6
|
-
import {sdLoadedFilesPlugin} from "../bundle-plugins/sdLoadedFilesPlugin";
|
|
7
|
-
import {sdTscPlugin} from "../bundle-plugins/sdTscPlugin";
|
|
8
6
|
|
|
9
|
-
export class
|
|
7
|
+
export class SdServerBundler {
|
|
10
8
|
#context?: esbuild.BuildContext;
|
|
11
9
|
|
|
10
|
+
#modifiedFileSet = new Set<string>();
|
|
11
|
+
#resultCache: Partial<IServerBundlerResultCache> = {};
|
|
12
|
+
|
|
12
13
|
constructor(private readonly _opt: {
|
|
13
14
|
dev: boolean;
|
|
14
15
|
pkgPath: string;
|
|
@@ -17,12 +18,18 @@ export class SdTsBundler {
|
|
|
17
18
|
}) {
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
public markForChanges(filePaths: string[]): void {
|
|
22
|
+
for (const filePath of filePaths) {
|
|
23
|
+
this.#modifiedFileSet.add(path.normalize(filePath));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
async bundleAsync(): Promise<{
|
|
21
|
-
|
|
28
|
+
program: ts.Program;
|
|
29
|
+
watchFileSet: Set<string>;
|
|
30
|
+
affectedFileSet: Set<string>;
|
|
22
31
|
results: ISdCliPackageBuildResult[];
|
|
23
32
|
}> {
|
|
24
|
-
const loadFilePathSet = new Set<string>();
|
|
25
|
-
|
|
26
33
|
if (!this.#context) {
|
|
27
34
|
this.#context = await esbuild.context({
|
|
28
35
|
entryPoints: this._opt.entryPoints,
|
|
@@ -65,7 +72,6 @@ export class SdTsBundler {
|
|
|
65
72
|
},
|
|
66
73
|
platform: "node",
|
|
67
74
|
logLevel: "silent",
|
|
68
|
-
// packages: "external",
|
|
69
75
|
external: this._opt.external,
|
|
70
76
|
banner: {
|
|
71
77
|
js: `
|
|
@@ -78,16 +84,12 @@ const __filename = __fileURLToPath__(import.meta.url);
|
|
|
78
84
|
const __dirname = __path__.dirname(__filename);`.trim()
|
|
79
85
|
},
|
|
80
86
|
plugins: [
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
+
sdServerPlugin({
|
|
88
|
+
modifiedFileSet: this.#modifiedFileSet,
|
|
89
|
+
dev: this._opt.dev,
|
|
90
|
+
pkgPath: this._opt.pkgPath,
|
|
91
|
+
result: this.#resultCache
|
|
87
92
|
}),
|
|
88
|
-
sdLoadedFilesPlugin({
|
|
89
|
-
loadedFileSet: loadFilePathSet
|
|
90
|
-
})
|
|
91
93
|
]
|
|
92
94
|
});
|
|
93
95
|
}
|
|
@@ -101,7 +103,9 @@ const __dirname = __path__.dirname(__filename);`.trim()
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
return {
|
|
104
|
-
|
|
106
|
+
program: this.#resultCache.program!,
|
|
107
|
+
watchFileSet: this.#resultCache.watchFileSet!,
|
|
108
|
+
affectedFileSet: this.#resultCache.affectedFileSet!,
|
|
105
109
|
results: [
|
|
106
110
|
...result.warnings.map((warn) => ({
|
|
107
111
|
type: "build" as const,
|
|
@@ -99,8 +99,8 @@ export class SdTsCompiler {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
public async buildAsync(): Promise<{
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
watchFileSet: Set<string>;
|
|
103
|
+
affectedFileSet: Set<string>;
|
|
104
104
|
results: ISdCliPackageBuildResult[];
|
|
105
105
|
}> {
|
|
106
106
|
const markedChanges = this._markedChanges;
|
|
@@ -156,7 +156,7 @@ export class SdTsCompiler {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
const diagnostics: ts.Diagnostic[] = [];
|
|
159
|
-
const
|
|
159
|
+
const affectedFileSet = new Set<string>();
|
|
160
160
|
|
|
161
161
|
if (this._ngProgram) {
|
|
162
162
|
diagnostics.push(...this._ngProgram.compiler.getOptionDiagnostics());
|
|
@@ -201,7 +201,7 @@ export class SdTsCompiler {
|
|
|
201
201
|
diagnostics.push(...semanticResult.result);
|
|
202
202
|
|
|
203
203
|
if ("fileName" in affectedSourceFile) {
|
|
204
|
-
|
|
204
|
+
affectedFileSet.add(path.normalize(affectedSourceFile.fileName));
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -209,21 +209,19 @@ export class SdTsCompiler {
|
|
|
209
209
|
for (const markedChange of markedChanges) {
|
|
210
210
|
const depsSet = this._styleDepsCache.get(markedChange);
|
|
211
211
|
if (depsSet) {
|
|
212
|
-
|
|
212
|
+
affectedFileSet.adds(...depsSet);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
affectedFilePaths.distinctThis();
|
|
216
215
|
}
|
|
217
216
|
|
|
218
217
|
const globalStyleFilePath = path.resolve(this._opt.pkgPath, "src/styles.scss");
|
|
219
218
|
if (this._opt.globalStyle && FsUtil.exists(globalStyleFilePath) && markedChanges.includes(globalStyleFilePath)) {
|
|
220
|
-
|
|
221
|
-
affectedFilePaths.distinctThis();
|
|
219
|
+
affectedFileSet.add(globalStyleFilePath);
|
|
222
220
|
}
|
|
223
221
|
|
|
224
222
|
this._logger.debug(`[${path.basename(this._opt.pkgPath)}] 영향받는 파일 ${this._opt.emit ? "EMIT" : "CHECK"}...`);
|
|
225
223
|
|
|
226
|
-
for (const affectedFilePath of
|
|
224
|
+
for (const affectedFilePath of affectedFileSet) {
|
|
227
225
|
if (this._opt.globalStyle && affectedFilePath === globalStyleFilePath) {
|
|
228
226
|
try {
|
|
229
227
|
const content = await FsUtil.readFileAsync(affectedFilePath);
|
|
@@ -294,16 +292,16 @@ export class SdTsCompiler {
|
|
|
294
292
|
}
|
|
295
293
|
}
|
|
296
294
|
|
|
297
|
-
this._logger.debug(`[${path.basename(this._opt.pkgPath)}] 영향받는 파일 ${this._opt.emit ? "EMIT" : "CHECK"} 완료`,
|
|
295
|
+
this._logger.debug(`[${path.basename(this._opt.pkgPath)}] 영향받는 파일 ${this._opt.emit ? "EMIT" : "CHECK"} 완료`, affectedFileSet);
|
|
298
296
|
|
|
299
297
|
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, this._opt.emit ? "build" : "check"));
|
|
300
298
|
|
|
301
299
|
return {
|
|
302
|
-
|
|
300
|
+
watchFileSet: new Set([
|
|
303
301
|
...Array.from(this._styleDepsCache.keys()),
|
|
304
|
-
...this._builder.getSourceFiles().map(item => path.
|
|
305
|
-
],
|
|
306
|
-
|
|
302
|
+
...this._builder.getSourceFiles().map(item => path.normalize(item.fileName))
|
|
303
|
+
]),
|
|
304
|
+
affectedFileSet: affectedFileSet,
|
|
307
305
|
results: buildResults
|
|
308
306
|
};
|
|
309
307
|
}
|
|
@@ -42,7 +42,11 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
42
42
|
const confDistPath = path.resolve(this._pkgPath, "dist/.config.json");
|
|
43
43
|
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
const result = await this._runAsync({dev: false});
|
|
46
|
+
return {
|
|
47
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
48
|
+
buildResults: result.buildResults
|
|
49
|
+
};
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
public async watchAsync() {
|
|
@@ -59,13 +63,16 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
59
63
|
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this._pkgConf.configs ?? {}, undefined, 2));
|
|
60
64
|
|
|
61
65
|
const result = await this._runAsync({dev: true});
|
|
62
|
-
this.emit("complete",
|
|
66
|
+
this.emit("complete", {
|
|
67
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
68
|
+
buildResults: result.buildResults
|
|
69
|
+
});
|
|
63
70
|
|
|
64
71
|
this._debug("WATCH...");
|
|
65
72
|
let changeFiles: string[] = [];
|
|
66
73
|
const fnQ = new FunctionQueue();
|
|
67
74
|
const watcher = SdFsWatcher
|
|
68
|
-
.watch(result.
|
|
75
|
+
.watch(Array.from(result.watchFileSet))
|
|
69
76
|
.onChange({delay: 100}, (changeInfos) => {
|
|
70
77
|
changeFiles.push(...changeInfos.map((item) => item.path));
|
|
71
78
|
|
|
@@ -81,9 +88,12 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
const watchResult = await this._runAsync({dev: true});
|
|
84
|
-
this.emit("complete",
|
|
91
|
+
this.emit("complete", {
|
|
92
|
+
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
93
|
+
buildResults: watchResult.buildResults
|
|
94
|
+
});
|
|
85
95
|
|
|
86
|
-
watcher.add(watchResult.
|
|
96
|
+
watcher.add(watchResult.watchFileSet);
|
|
87
97
|
});
|
|
88
98
|
});
|
|
89
99
|
}
|
|
@@ -91,8 +101,8 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
91
101
|
private async _runAsync(opt: {
|
|
92
102
|
dev: boolean;
|
|
93
103
|
}): Promise<{
|
|
94
|
-
|
|
95
|
-
|
|
104
|
+
watchFileSet: Set<string>;
|
|
105
|
+
affectedFileSet: Set<string>;
|
|
96
106
|
buildResults: ISdCliPackageBuildResult[];
|
|
97
107
|
}> {
|
|
98
108
|
const builderTypes = (Object.keys(this._pkgConf.builder ?? {web: {}}) as ("web" | "electron" | "cordova")[]);
|
|
@@ -126,8 +136,8 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
126
136
|
|
|
127
137
|
this._debug(`BUILD & CHECK...`);
|
|
128
138
|
const buildResults = await Promise.all(this._builders.map((builder) => builder.bundleAsync()));
|
|
129
|
-
const
|
|
130
|
-
const
|
|
139
|
+
const watchFileSet = new Set(buildResults.mapMany(item => Array.from(item.watchFileSet)));
|
|
140
|
+
const affectedFileSet = new Set(buildResults.mapMany(item => Array.from(item.affectedFileSet)));
|
|
131
141
|
const results = buildResults.mapMany((item) => item.results).distinct();
|
|
132
142
|
const firstProgram = buildResults.first()?.program;
|
|
133
143
|
|
|
@@ -140,7 +150,7 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
140
150
|
// oldProgram: this.#program
|
|
141
151
|
// });
|
|
142
152
|
// const pkgFilePaths = filePaths.filter(item => PathUtil.isChildPath(item, this._pkgPath));
|
|
143
|
-
const lintResults = await SdLinter.lintAsync(
|
|
153
|
+
const lintResults = await SdLinter.lintAsync(Array.from(affectedFileSet).filter(item => PathUtil.isChildPath(item, this._pkgPath)), firstProgram);
|
|
144
154
|
|
|
145
155
|
if (!opt.dev && this._cordova) {
|
|
146
156
|
this._debug("CORDOVA BUILD...");
|
|
@@ -150,13 +160,13 @@ export class SdCliClientBuilder extends EventEmitter {
|
|
|
150
160
|
this._debug(`빌드 완료`);
|
|
151
161
|
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
|
|
152
162
|
.mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
|
|
153
|
-
const
|
|
163
|
+
const currWatchFileSet = new Set(Array.from(watchFileSet).filter(item =>
|
|
154
164
|
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
155
165
|
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu))
|
|
156
|
-
);
|
|
166
|
+
));
|
|
157
167
|
return {
|
|
158
|
-
|
|
159
|
-
|
|
168
|
+
watchFileSet: currWatchFileSet,
|
|
169
|
+
affectedFileSet,
|
|
160
170
|
buildResults: [...results, ...lintResults]
|
|
161
171
|
};
|
|
162
172
|
}
|
|
@@ -9,16 +9,14 @@ import {
|
|
|
9
9
|
ITsConfig
|
|
10
10
|
} from "../commons";
|
|
11
11
|
import path from "path";
|
|
12
|
-
import {SdTsCompiler} from "../build-tools/SdTsCompiler";
|
|
13
12
|
import {SdLinter} from "../build-tools/SdLinter";
|
|
14
13
|
import {FunctionQueue, ObjectUtil, StringUtil} from "@simplysm/sd-core-common";
|
|
15
|
-
import {
|
|
14
|
+
import {SdServerBundler} from "../build-tools/SdServerBundler";
|
|
16
15
|
|
|
17
16
|
export class SdCliServerBuilder extends EventEmitter {
|
|
18
17
|
#logger = Logger.get(["simplysm", "sd-cli", "SdCliServerBuilder"]);
|
|
19
18
|
#pkgConf: ISdCliServerPackageConfig;
|
|
20
|
-
#builder?:
|
|
21
|
-
#checker?: SdTsCompiler;
|
|
19
|
+
#builder?: SdServerBundler;
|
|
22
20
|
#extModules?: { name: string; exists: boolean }[];
|
|
23
21
|
|
|
24
22
|
public constructor(private readonly _projConf: ISdCliConfig,
|
|
@@ -45,20 +43,34 @@ export class SdCliServerBuilder extends EventEmitter {
|
|
|
45
43
|
await FsUtil.writeFileAsync(confDistPath, JSON.stringify(this.#pkgConf.configs ?? {}, undefined, 2));
|
|
46
44
|
|
|
47
45
|
const result = await this._runAsync({dev: true});
|
|
48
|
-
this.emit("complete",
|
|
46
|
+
this.emit("complete", {
|
|
47
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
48
|
+
buildResults: result.buildResults
|
|
49
|
+
});
|
|
49
50
|
|
|
50
51
|
this._debug("WATCH...");
|
|
52
|
+
let changeFiles: string[] = [];
|
|
51
53
|
const fnQ = new FunctionQueue();
|
|
52
54
|
const watcher = SdFsWatcher
|
|
53
|
-
.watch(result.
|
|
54
|
-
.onChange({delay: 100}, () => {
|
|
55
|
+
.watch(Array.from(result.watchFileSet))
|
|
56
|
+
.onChange({delay: 100}, (changeInfos) => {
|
|
57
|
+
changeFiles.push(...changeInfos.map((item) => item.path));
|
|
58
|
+
|
|
55
59
|
fnQ.runLast(async () => {
|
|
60
|
+
const currChangeFiles = [...changeFiles];
|
|
61
|
+
changeFiles = [];
|
|
62
|
+
|
|
56
63
|
this.emit("change");
|
|
57
64
|
|
|
65
|
+
this.#builder!.markForChanges(currChangeFiles);
|
|
66
|
+
|
|
58
67
|
const watchResult = await this._runAsync({dev: true});
|
|
59
|
-
this.emit("complete",
|
|
68
|
+
this.emit("complete", {
|
|
69
|
+
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
70
|
+
buildResults: watchResult.buildResults
|
|
71
|
+
});
|
|
60
72
|
|
|
61
|
-
watcher.add(watchResult.
|
|
73
|
+
watcher.add(watchResult.watchFileSet);
|
|
62
74
|
});
|
|
63
75
|
});
|
|
64
76
|
}
|
|
@@ -190,22 +202,22 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
190
202
|
`.trim());
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
|
|
205
|
+
const result = await this._runAsync({dev: false});
|
|
206
|
+
return {
|
|
207
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
208
|
+
buildResults: result.buildResults
|
|
209
|
+
};
|
|
194
210
|
}
|
|
195
211
|
|
|
196
212
|
private async _runAsync(opt: { dev: boolean }): Promise<{
|
|
197
|
-
|
|
198
|
-
|
|
213
|
+
watchFileSet: Set<string>;
|
|
214
|
+
affectedFileSet: Set<string>;
|
|
199
215
|
buildResults: ISdCliPackageBuildResult[];
|
|
200
216
|
}> {
|
|
201
217
|
this._debug(`BUILD 준비...`);
|
|
202
|
-
|
|
203
|
-
this.#extModules = this.#extModules ?? await this._getExternalModulesAsync();
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this._debug(`BUILD...`);
|
|
207
218
|
const tsConfig = FsUtil.readJson(path.resolve(this._pkgPath, "tsconfig.json")) as ITsConfig;
|
|
208
|
-
this.#
|
|
219
|
+
this.#extModules = this.#extModules ?? await this._getExternalModulesAsync();
|
|
220
|
+
this.#builder = this.#builder ?? new SdServerBundler({
|
|
209
221
|
dev: opt.dev,
|
|
210
222
|
pkgPath: this._pkgPath,
|
|
211
223
|
entryPoints: tsConfig.files ? tsConfig.files.map((item) => path.resolve(this._pkgPath, item)) : [
|
|
@@ -213,40 +225,27 @@ Options = UnsafeLegacyRenegotiation`.trim()
|
|
|
213
225
|
],
|
|
214
226
|
external: this.#extModules.map((item) => item.name)
|
|
215
227
|
});
|
|
216
|
-
const buildResult = await this.#builder.bundleAsync();
|
|
217
228
|
|
|
218
|
-
this._debug(
|
|
219
|
-
|
|
220
|
-
pkgPath: this._pkgPath,
|
|
221
|
-
emit: false,
|
|
222
|
-
emitDts: false,
|
|
223
|
-
globalStyle: false
|
|
224
|
-
});
|
|
225
|
-
const checkResult = await this.#checker.buildAsync();
|
|
229
|
+
this._debug(`BUILD & CHECK...`);
|
|
230
|
+
const buildResult = await this.#builder.bundleAsync();
|
|
226
231
|
|
|
227
232
|
//-- filePaths
|
|
228
233
|
|
|
229
|
-
const filePaths = [
|
|
230
|
-
...buildResult.filePaths,
|
|
231
|
-
...checkResult.filePaths
|
|
232
|
-
];
|
|
233
|
-
const pkgFilePaths = filePaths.filter(item => PathUtil.isChildPath(item, this._pkgPath));
|
|
234
|
-
|
|
235
234
|
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
|
|
236
235
|
.mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
|
|
237
|
-
const
|
|
236
|
+
const watchFileSet = new Set(Array.from(buildResult.watchFileSet).filter(item =>
|
|
238
237
|
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
239
238
|
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu))
|
|
240
|
-
);
|
|
239
|
+
));
|
|
241
240
|
|
|
242
241
|
this._debug(`LINT...`);
|
|
243
|
-
const lintResults = await SdLinter.lintAsync(
|
|
242
|
+
const lintResults = await SdLinter.lintAsync(Array.from(buildResult.affectedFileSet).filter(item => PathUtil.isChildPath(item, this._pkgPath)), buildResult.program);
|
|
244
243
|
|
|
245
244
|
this._debug(`빌드 완료`);
|
|
246
245
|
return {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
buildResults: [...buildResult.results, ...
|
|
246
|
+
watchFileSet,
|
|
247
|
+
affectedFileSet: buildResult.affectedFileSet,
|
|
248
|
+
buildResults: [...buildResult.results, ...lintResults]
|
|
250
249
|
};
|
|
251
250
|
}
|
|
252
251
|
|
|
@@ -35,7 +35,11 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
35
35
|
await SdCliIndexFileGenerator.runAsync(this._pkgPath, this._pkgConf.polyfills);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
const result = await this._runAsync();
|
|
39
|
+
return {
|
|
40
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
41
|
+
buildResults: result.buildResults
|
|
42
|
+
};
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
public async watchAsync(): Promise<void> {
|
|
@@ -50,12 +54,15 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
const result = await this._runAsync();
|
|
53
|
-
this.emit("complete",
|
|
57
|
+
this.emit("complete", {
|
|
58
|
+
affectedFilePaths: Array.from(result.affectedFileSet),
|
|
59
|
+
buildResults: result.buildResults
|
|
60
|
+
});
|
|
54
61
|
|
|
55
62
|
this._debug("WATCH...");
|
|
56
63
|
const fnQ = new FunctionQueue();
|
|
57
64
|
const watcher = SdFsWatcher
|
|
58
|
-
.watch(result.
|
|
65
|
+
.watch(Array.from(result.watchFileSet))
|
|
59
66
|
.onChange({delay: 100,}, (changeInfos) => {
|
|
60
67
|
this._builder!.markChanges(changeInfos.map((item) => item.path));
|
|
61
68
|
|
|
@@ -63,16 +70,19 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
63
70
|
this.emit("change");
|
|
64
71
|
|
|
65
72
|
const watchResult = await this._runAsync();
|
|
66
|
-
this.emit("complete",
|
|
73
|
+
this.emit("complete", {
|
|
74
|
+
affectedFilePaths: Array.from(watchResult.affectedFileSet),
|
|
75
|
+
buildResults: watchResult.buildResults
|
|
76
|
+
});
|
|
67
77
|
|
|
68
|
-
watcher.add(watchResult.
|
|
78
|
+
watcher.add(watchResult.watchFileSet);
|
|
69
79
|
});
|
|
70
80
|
});
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
private async _runAsync(): Promise<{
|
|
74
|
-
|
|
75
|
-
|
|
84
|
+
watchFileSet: Set<string>;
|
|
85
|
+
affectedFileSet: Set<string>;
|
|
76
86
|
buildResults: ISdCliPackageBuildResult[];
|
|
77
87
|
}> {
|
|
78
88
|
this._debug(`BUILD && CHECK...`);
|
|
@@ -82,23 +92,23 @@ export class SdCliTsLibBuilder extends EventEmitter {
|
|
|
82
92
|
emitDts: true,
|
|
83
93
|
globalStyle: true
|
|
84
94
|
});
|
|
85
|
-
const
|
|
95
|
+
const buildResult = await this._builder.buildAsync();
|
|
86
96
|
|
|
87
97
|
this._debug("LINT...");
|
|
88
|
-
const lintResults = await SdLinter.lintAsync(
|
|
98
|
+
const lintResults = await SdLinter.lintAsync(Array.from(buildResult.affectedFileSet).filter(item => PathUtil.isChildPath(item, this._pkgPath)), this._builder.program);
|
|
89
99
|
|
|
90
100
|
this._debug(`빌드 완료`);
|
|
91
101
|
const localUpdatePaths = Object.keys(this._projConf.localUpdates ?? {})
|
|
92
102
|
.mapMany((key) => FsUtil.glob(path.resolve(this._pkgPath, "../../node_modules", key)));
|
|
93
|
-
const
|
|
103
|
+
const watchFileSet = new Set(Array.from(buildResult.watchFileSet).filter(item =>
|
|
94
104
|
PathUtil.isChildPath(item, path.resolve(this._pkgPath, "../")) ||
|
|
95
105
|
localUpdatePaths.some((lu) => PathUtil.isChildPath(item, lu))
|
|
96
|
-
);
|
|
106
|
+
));
|
|
97
107
|
|
|
98
108
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
buildResults: [...
|
|
109
|
+
watchFileSet,
|
|
110
|
+
affectedFileSet: buildResult.affectedFileSet,
|
|
111
|
+
buildResults: [...buildResult.results, ...lintResults]
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
114
|
|
|
@@ -146,7 +146,7 @@ export function sdNgPlugin(conf: {
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
return {
|
|
149
|
-
name: "sd-ng",
|
|
149
|
+
name: "sd-ng-compiler",
|
|
150
150
|
setup: (build: esbuild.PluginBuild) => {
|
|
151
151
|
//-- stylesheetBundler
|
|
152
152
|
const browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
|