@simplysm/sd-cli 10.0.66 → 11.0.4
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 +16 -15
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +20 -0
- package/dist/build-tools/SdNgBundler.js +312 -0
- package/dist/build-tools/SdNgBundler.js.map +1 -0
- package/dist/build-tools/SdTsBundler.d.ts +15 -0
- package/dist/build-tools/SdTsBundler.js +96 -0
- package/dist/build-tools/SdTsBundler.js.map +1 -0
- package/dist/build-tools/SdTsCompiler.d.ts +28 -0
- package/dist/build-tools/SdTsCompiler.js +212 -0
- package/dist/build-tools/SdTsCompiler.js.map +1 -0
- package/dist/builders/SdCliClientBuilder.d.ts +5 -7
- package/dist/builders/SdCliClientBuilder.js +75 -267
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +4 -3
- package/dist/builders/SdCliServerBuilder.js +82 -218
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +3 -4
- package/dist/builders/SdCliTsLibBuilder.js +37 -87
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +11 -5
- package/dist/entry/SdCliProject.js +22 -18
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +3 -11
- package/dist/index.js +3 -11
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +0 -19
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js +3 -0
- package/dist/server-worker.js.map +1 -1
- package/package.json +17 -19
- package/src/build-cluster.ts +16 -15
- package/src/build-tools/SdNgBundler.ts +381 -0
- package/src/build-tools/SdTsBundler.ts +106 -0
- package/src/build-tools/SdTsCompiler.ts +304 -0
- package/src/builders/SdCliClientBuilder.ts +93 -312
- package/src/builders/SdCliServerBuilder.ts +99 -242
- package/src/builders/SdCliTsLibBuilder.ts +41 -111
- package/src/commons.ts +11 -5
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliLocalUpdate.ts +3 -3
- package/src/entry/SdCliProject.ts +33 -26
- package/src/index.ts +3 -11
- package/src/sd-cli.ts +0 -23
- package/src/server-worker.ts +3 -0
- package/dist/build-tools/SdTsIncrementalBuilder.d.ts +0 -29
- package/dist/build-tools/SdTsIncrementalBuilder.js +0 -75
- package/dist/build-tools/SdTsIncrementalBuilder.js.map +0 -1
- package/dist/entry/SdCliPwaAssets.d.ts +0 -6
- package/dist/entry/SdCliPwaAssets.js +0 -39
- package/dist/entry/SdCliPwaAssets.js.map +0 -1
- package/dist/utils/SdCliViteElectronMainPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteElectronMainPlugin.js +0 -96
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +0 -1
- package/dist/utils/SdCliViteExternalPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteExternalPlugin.js +0 -85
- package/dist/utils/SdCliViteExternalPlugin.js.map +0 -1
- package/dist/utils/SdCliViteLazyImportPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteLazyImportPlugin.js +0 -23
- package/dist/utils/SdCliViteLazyImportPlugin.js.map +0 -1
- package/dist/utils/SdCliViteLoggerPlugin.d.ts +0 -6
- package/dist/utils/SdCliViteLoggerPlugin.js +0 -24
- package/dist/utils/SdCliViteLoggerPlugin.js.map +0 -1
- package/dist/utils/SdCliViteNodeGlobalPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteNodeGlobalPlugin.js +0 -29
- package/dist/utils/SdCliViteNodeGlobalPlugin.js.map +0 -1
- package/dist/utils/SdCliViteReactSwcPlugin.d.ts +0 -2
- package/dist/utils/SdCliViteReactSwcPlugin.js +0 -139
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +0 -1
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.d.ts +0 -2
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js +0 -36
- package/dist/utils/SdCliViteServeOptimizeExcludePlugin.js.map +0 -1
- package/dist/utils/getElectronReactExternals.d.ts +0 -1
- package/dist/utils/getElectronReactExternals.js +0 -17
- package/dist/utils/getElectronReactExternals.js.map +0 -1
- package/dist/utils/sdCliTsDefineTransformer.d.ts +0 -4
- package/dist/utils/sdCliTsDefineTransformer.js +0 -26
- package/dist/utils/sdCliTsDefineTransformer.js.map +0 -1
- package/src/build-tools/SdTsIncrementalBuilder.ts +0 -125
- package/src/entry/SdCliPwaAssets.ts +0 -50
- package/src/utils/SdCliViteElectronMainPlugin.ts +0 -102
- package/src/utils/SdCliViteExternalPlugin.ts +0 -98
- package/src/utils/SdCliViteLazyImportPlugin.ts +0 -26
- package/src/utils/SdCliViteLoggerPlugin.ts +0 -29
- package/src/utils/SdCliViteNodeGlobalPlugin.ts +0 -31
- package/src/utils/SdCliViteReactSwcPlugin.ts +0 -153
- package/src/utils/SdCliViteServeOptimizeExcludePlugin.ts +0 -42
- package/src/utils/getElectronReactExternals.ts +0 -19
- package/src/utils/sdCliTsDefineTransformer.ts +0 -33
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {FsUtil, Logger, PathUtil, SdFsWatcher} from "@simplysm/sd-core-node";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import {pathToFileURL} from "url";
|
|
4
|
-
import {
|
|
4
|
+
import {ISdCliConfig} from "../commons";
|
|
5
5
|
|
|
6
6
|
export class SdCliLocalUpdate {
|
|
7
7
|
public static async runAsync(opt: {
|
|
@@ -11,7 +11,7 @@ export class SdCliLocalUpdate {
|
|
|
11
11
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "runAsync"]);
|
|
12
12
|
|
|
13
13
|
logger.debug("프로젝트 설정 가져오기...");
|
|
14
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as
|
|
14
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
|
|
15
15
|
if (!projConf.localUpdates) return;
|
|
16
16
|
|
|
17
17
|
const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
|
|
@@ -39,7 +39,7 @@ export class SdCliLocalUpdate {
|
|
|
39
39
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliLocalUpdate", "watchAsync"]);
|
|
40
40
|
|
|
41
41
|
logger.debug("프로젝트 설정 가져오기...");
|
|
42
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as
|
|
42
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
|
|
43
43
|
if (!projConf.localUpdates) return;
|
|
44
44
|
|
|
45
45
|
const updatePathInfos = await this._getUpdatePathInfosAsync(projConf.localUpdates);
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
INpmConfig,
|
|
5
5
|
ISdCliBuildClusterReqMessage,
|
|
6
6
|
ISdCliBuildClusterResMessage,
|
|
7
|
+
ISdCliConfig,
|
|
7
8
|
ISdCliPackageBuildResult,
|
|
8
9
|
ISdCliServerPackageConfig,
|
|
9
|
-
TSdCliConfig,
|
|
10
10
|
TSdCliPackageConfig
|
|
11
11
|
} from "../commons";
|
|
12
12
|
import cp from "child_process";
|
|
@@ -28,7 +28,7 @@ export class SdCliProject {
|
|
|
28
28
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "watchAsync"]);
|
|
29
29
|
|
|
30
30
|
logger.debug("프로젝트 설정 가져오기...");
|
|
31
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as
|
|
31
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(true, opt.optNames) as ISdCliConfig;
|
|
32
32
|
|
|
33
33
|
if (projConf.localUpdates) {
|
|
34
34
|
logger.debug("로컬 라이브러리 업데이트 변경감지 시작...");
|
|
@@ -79,8 +79,8 @@ export class SdCliProject {
|
|
|
79
79
|
hasChanges: boolean;
|
|
80
80
|
|
|
81
81
|
//client
|
|
82
|
-
pathProxy: Record<string, number | undefined>; // persist
|
|
83
|
-
changeFilePaths: string[];
|
|
82
|
+
pathProxy: Record<string, string | number | undefined>; // persist
|
|
83
|
+
// changeFilePaths: string[];
|
|
84
84
|
}>();
|
|
85
85
|
cluster.on("message", (message: ISdCliBuildClusterResMessage) => {
|
|
86
86
|
if (message.type === "change") {
|
|
@@ -99,37 +99,44 @@ export class SdCliProject {
|
|
|
99
99
|
cacheItem.push(buildResult);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
const pkgConf = message.req.projConf.packages[path.basename(message.req.pkgPath)]!;
|
|
103
|
+
|
|
104
|
+
if (pkgConf.type === "server") {
|
|
103
105
|
const pkgName = path.basename(message.req.pkgPath);
|
|
104
106
|
const serverInfo = serverInfoMap.getOrCreate(pkgName, {
|
|
105
107
|
hasChanges: false,
|
|
106
108
|
pathProxy: {},
|
|
107
|
-
changeFilePaths: []
|
|
109
|
+
// changeFilePaths: []
|
|
108
110
|
});
|
|
109
111
|
serverInfo.pkgPath = message.req.pkgPath;
|
|
110
112
|
serverInfo.hasChanges = true;
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
if (
|
|
115
|
+
if (pkgConf.type === "client") {
|
|
114
116
|
const pkgName = path.basename(message.req.pkgPath);
|
|
115
117
|
|
|
116
|
-
if (
|
|
117
|
-
const serverInfo = serverInfoMap.getOrCreate(
|
|
118
|
+
if (pkgConf.server !== undefined) {
|
|
119
|
+
const serverInfo = serverInfoMap.getOrCreate(pkgConf.server, {
|
|
118
120
|
hasChanges: false,
|
|
119
121
|
pathProxy: {},
|
|
120
|
-
changeFilePaths: []
|
|
122
|
+
// changeFilePaths: []
|
|
121
123
|
});
|
|
122
|
-
serverInfo.pathProxy[pkgName] = message.
|
|
123
|
-
|
|
124
|
+
serverInfo.pathProxy[pkgName] = path.resolve(message.req.pkgPath, "dist");
|
|
125
|
+
//message.result!.port;
|
|
126
|
+
// serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
127
|
+
|
|
128
|
+
serverInfo.worker?.send({type: "broadcastReload"});
|
|
124
129
|
}
|
|
125
130
|
else {
|
|
126
131
|
const serverInfo = serverInfoMap.getOrCreate(pkgName, {
|
|
127
132
|
hasChanges: false,
|
|
128
133
|
pathProxy: {},
|
|
129
|
-
changeFilePaths: []
|
|
134
|
+
// changeFilePaths: []
|
|
130
135
|
});
|
|
131
136
|
serverInfo.port = message.result!.port;
|
|
132
|
-
serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
137
|
+
// serverInfo.changeFilePaths.push(...message.result!.affectedFilePaths);
|
|
138
|
+
|
|
139
|
+
serverInfo.worker?.send({type: "broadcastReload"});
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
142
|
|
|
@@ -195,11 +202,11 @@ export class SdCliProject {
|
|
|
195
202
|
if (pkgConf.type === "client") {
|
|
196
203
|
const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
|
|
197
204
|
await builderKeys.parallelAsync(async (builderKey) => {
|
|
198
|
-
await this._runCommandAsync(cluster, "watch",
|
|
205
|
+
await this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.withLint, builderKey);
|
|
199
206
|
});
|
|
200
207
|
}
|
|
201
208
|
else {
|
|
202
|
-
await this._runCommandAsync(cluster, "watch",
|
|
209
|
+
await this._runCommandAsync(cluster, "watch", projConf, pkgPath, opt.withLint);
|
|
203
210
|
}
|
|
204
211
|
});
|
|
205
212
|
|
|
@@ -219,7 +226,7 @@ export class SdCliProject {
|
|
|
219
226
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "buildAsync"]);
|
|
220
227
|
|
|
221
228
|
logger.debug("프로젝트 설정 가져오기...");
|
|
222
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as
|
|
229
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as ISdCliConfig;
|
|
223
230
|
|
|
224
231
|
logger.debug("프로젝트 package.json 가져오기...");
|
|
225
232
|
const projNpmConf = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json"))) as INpmConfig;
|
|
@@ -255,11 +262,11 @@ export class SdCliProject {
|
|
|
255
262
|
if (pkgConf.type === "client") {
|
|
256
263
|
const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
|
|
257
264
|
return (await builderKeys.parallelAsync(async (builderKey) => {
|
|
258
|
-
return await this._runCommandAsync(cluster, "build",
|
|
265
|
+
return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint, builderKey);
|
|
259
266
|
})).mapMany();
|
|
260
267
|
}
|
|
261
268
|
else {
|
|
262
|
-
return await this._runCommandAsync(cluster, "build",
|
|
269
|
+
return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint);
|
|
263
270
|
}
|
|
264
271
|
})
|
|
265
272
|
).mapMany();
|
|
@@ -280,7 +287,7 @@ export class SdCliProject {
|
|
|
280
287
|
const logger = Logger.get(["simplysm", "sd-cli", "SdCliProject", "publishAsync"]);
|
|
281
288
|
|
|
282
289
|
logger.debug("프로젝트 설정 가져오기...");
|
|
283
|
-
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as
|
|
290
|
+
const projConf = (await import(pathToFileURL(path.resolve(process.cwd(), opt.confFileRelPath)).href)).default(false, opt.optNames) as ISdCliConfig;
|
|
284
291
|
|
|
285
292
|
logger.debug("프로젝트 package.json 가져오기...");
|
|
286
293
|
const projNpmConf = (await FsUtil.readJsonAsync(path.resolve(process.cwd(), "package.json"))) as INpmConfig;
|
|
@@ -332,11 +339,11 @@ export class SdCliProject {
|
|
|
332
339
|
if (pkgConf.type === "client") {
|
|
333
340
|
const builderKeys = Object.keys(pkgConf.builder ?? {web: {}});
|
|
334
341
|
return (await builderKeys.parallelAsync(async (builderKey) => {
|
|
335
|
-
return await this._runCommandAsync(cluster, "build",
|
|
342
|
+
return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint, builderKey);
|
|
336
343
|
})).mapMany();
|
|
337
344
|
}
|
|
338
345
|
else {
|
|
339
|
-
return await this._runCommandAsync(cluster, "build",
|
|
346
|
+
return await this._runCommandAsync(cluster, "build", projConf, pkgPath, opt.withLint);
|
|
340
347
|
}
|
|
341
348
|
})
|
|
342
349
|
).mapMany();
|
|
@@ -529,9 +536,9 @@ export class SdCliProject {
|
|
|
529
536
|
});
|
|
530
537
|
}
|
|
531
538
|
|
|
532
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch",
|
|
533
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build",
|
|
534
|
-
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build",
|
|
539
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<void>;
|
|
540
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "build", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[]>;
|
|
541
|
+
private static async _runCommandAsync(cluster: cp.ChildProcess, cmd: "watch" | "build", projConf: ISdCliConfig, pkgPath: string, withLint: boolean, builderKey?: string): Promise<ISdCliPackageBuildResult[] | void> {
|
|
535
542
|
return await new Promise<ISdCliPackageBuildResult[] | void>((resolve) => {
|
|
536
543
|
const cb = (message: ISdCliBuildClusterResMessage): void => {
|
|
537
544
|
if (cmd === "watch" && message.type === "ready" && message.req.cmd === cmd && message.req.pkgPath === pkgPath) {
|
|
@@ -547,8 +554,8 @@ export class SdCliProject {
|
|
|
547
554
|
|
|
548
555
|
cluster.send({
|
|
549
556
|
cmd,
|
|
557
|
+
projConf,
|
|
550
558
|
pkgPath,
|
|
551
|
-
pkgConf,
|
|
552
559
|
builderKey,
|
|
553
560
|
withLint
|
|
554
561
|
} as ISdCliBuildClusterReqMessage);
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from "./build-tools/SdCliIndexFileGenerator";
|
|
2
2
|
export * from "./build-tools/SdLinter";
|
|
3
|
-
export * from "./build-tools/
|
|
3
|
+
export * from "./build-tools/SdNgBundler";
|
|
4
|
+
export * from "./build-tools/SdTsBundler";
|
|
5
|
+
export * from "./build-tools/SdTsCompiler";
|
|
4
6
|
export * from "./builders/SdCliClientBuilder";
|
|
5
7
|
export * from "./builders/SdCliJsLibLinter";
|
|
6
8
|
export * from "./builders/SdCliServerBuilder";
|
|
@@ -9,14 +11,4 @@ export * from "./commons";
|
|
|
9
11
|
export * from "./entry/SdCliElectron";
|
|
10
12
|
export * from "./entry/SdCliLocalUpdate";
|
|
11
13
|
export * from "./entry/SdCliProject";
|
|
12
|
-
export * from "./entry/SdCliPwaAssets";
|
|
13
|
-
export * from "./utils/getElectronReactExternals";
|
|
14
14
|
export * from "./utils/SdCliBuildResultUtil";
|
|
15
|
-
export * from "./utils/sdCliTsDefineTransformer";
|
|
16
|
-
export * from "./utils/SdCliViteElectronMainPlugin";
|
|
17
|
-
export * from "./utils/SdCliViteExternalPlugin";
|
|
18
|
-
export * from "./utils/SdCliViteLazyImportPlugin";
|
|
19
|
-
export * from "./utils/SdCliViteLoggerPlugin";
|
|
20
|
-
export * from "./utils/SdCliViteNodeGlobalPlugin";
|
|
21
|
-
export * from "./utils/SdCliViteReactSwcPlugin";
|
|
22
|
-
export * from "./utils/SdCliViteServeOptimizeExcludePlugin";
|
package/src/sd-cli.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {Logger, LoggerSeverity} from "@simplysm/sd-core-node";
|
|
|
7
7
|
import {EventEmitter} from "events";
|
|
8
8
|
import {SdCliElectron} from "./entry/SdCliElectron";
|
|
9
9
|
import {SdCliLocalUpdate} from "./entry/SdCliLocalUpdate";
|
|
10
|
-
import {SdCliPwaAssets} from "./entry/SdCliPwaAssets";
|
|
11
10
|
|
|
12
11
|
Error.stackTraceLimit = Infinity;
|
|
13
12
|
EventEmitter.defaultMaxListeners = 0;
|
|
@@ -164,21 +163,6 @@ const argv = (
|
|
|
164
163
|
}
|
|
165
164
|
})
|
|
166
165
|
)
|
|
167
|
-
.command(
|
|
168
|
-
"gen-pwa-assets <fileName> <package>",
|
|
169
|
-
"PWA Asset 파일들을 생성합니다.",
|
|
170
|
-
(cmd) => cmd
|
|
171
|
-
.positional("fileName", {
|
|
172
|
-
type: "string",
|
|
173
|
-
describe: "이미지 파일",
|
|
174
|
-
demandOption: true
|
|
175
|
-
})
|
|
176
|
-
.positional("package", {
|
|
177
|
-
type: "string",
|
|
178
|
-
describe: "패키지명",
|
|
179
|
-
demandOption: true
|
|
180
|
-
})
|
|
181
|
-
)
|
|
182
166
|
.parseAsync()
|
|
183
167
|
) as any;
|
|
184
168
|
|
|
@@ -246,13 +230,6 @@ else if (argv._[0] === "build-electron-for-dev") {
|
|
|
246
230
|
pkgName: argv.package
|
|
247
231
|
});
|
|
248
232
|
}
|
|
249
|
-
else if (argv._[0] === "gen-pwa-assets") {
|
|
250
|
-
await SdCliPwaAssets
|
|
251
|
-
.genAsync({
|
|
252
|
-
relFilePath: argv.fileName!,
|
|
253
|
-
pkgName: argv.package
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
233
|
else {
|
|
257
234
|
throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
|
|
258
235
|
}
|
package/src/server-worker.ts
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { ISdCliPackageBuildResult } from "../commons";
|
|
3
|
-
interface IOptTransform<T> {
|
|
4
|
-
fn: (_: ts.Program, arg: T) => ts.TransformerFactory<ts.SourceFile>;
|
|
5
|
-
args: T;
|
|
6
|
-
}
|
|
7
|
-
export declare class SdTsIncrementalBuilder {
|
|
8
|
-
private readonly _pkgPath;
|
|
9
|
-
private readonly _compilerOptions;
|
|
10
|
-
private readonly _host;
|
|
11
|
-
private readonly _opt;
|
|
12
|
-
builderProgram?: ts.SemanticDiagnosticsBuilderProgram;
|
|
13
|
-
private readonly _writeFileCache;
|
|
14
|
-
constructor(_pkgPath: string, _compilerOptions: ts.CompilerOptions, _host: ts.CompilerHost, _opt: {
|
|
15
|
-
emitJs: boolean | string[];
|
|
16
|
-
compilerOptions?: ts.CompilerOptions;
|
|
17
|
-
transforms?: IOptTransform<any>[];
|
|
18
|
-
});
|
|
19
|
-
static createAsync(pkgPath: string, optFn: (compilerOptions: ts.CompilerOptions) => {
|
|
20
|
-
emitJs: boolean | string[];
|
|
21
|
-
compilerOptions?: ts.CompilerOptions;
|
|
22
|
-
transforms?: IOptTransform<any>[];
|
|
23
|
-
}): Promise<SdTsIncrementalBuilder>;
|
|
24
|
-
buildAsync(): Promise<{
|
|
25
|
-
affectedFilePaths: string[];
|
|
26
|
-
results: ISdCliPackageBuildResult[];
|
|
27
|
-
}>;
|
|
28
|
-
}
|
|
29
|
-
export {};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
|
|
4
|
-
import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
|
|
5
|
-
export class SdTsIncrementalBuilder {
|
|
6
|
-
constructor(_pkgPath, _compilerOptions, _host, _opt) {
|
|
7
|
-
this._pkgPath = _pkgPath;
|
|
8
|
-
this._compilerOptions = _compilerOptions;
|
|
9
|
-
this._host = _host;
|
|
10
|
-
this._opt = _opt;
|
|
11
|
-
this._writeFileCache = new Map();
|
|
12
|
-
}
|
|
13
|
-
static async createAsync(pkgPath, optFn) {
|
|
14
|
-
const tsConfigFilePath = path.resolve(pkgPath, "tsconfig.json");
|
|
15
|
-
const parsedTsConfig = ts.parseJsonConfigFileContent(await FsUtil.readJsonAsync(tsConfigFilePath), ts.sys, pkgPath);
|
|
16
|
-
const opt = optFn(parsedTsConfig.options);
|
|
17
|
-
const compilerOptions = {
|
|
18
|
-
...parsedTsConfig.options,
|
|
19
|
-
...opt?.compilerOptions
|
|
20
|
-
};
|
|
21
|
-
const host = ts.createIncrementalCompilerHost(compilerOptions);
|
|
22
|
-
return new SdTsIncrementalBuilder(pkgPath, compilerOptions, host, opt);
|
|
23
|
-
}
|
|
24
|
-
async buildAsync() {
|
|
25
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdTsIncrementalBuilder", "buildAsync"]);
|
|
26
|
-
const distPath = this._compilerOptions.outDir ?? path.resolve(this._pkgPath, "dist");
|
|
27
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.{ts,tsx}");
|
|
28
|
-
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
29
|
-
this.builderProgram = ts.createSemanticDiagnosticsBuilderProgram(srcFilePaths, this._compilerOptions, this._host, this.builderProgram);
|
|
30
|
-
const diagnostics = [];
|
|
31
|
-
const affectedFilePaths = [];
|
|
32
|
-
diagnostics.push(...this.builderProgram.getOptionsDiagnostics(), ...this.builderProgram.getGlobalDiagnostics());
|
|
33
|
-
const program = this.builderProgram.getProgram();
|
|
34
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리중...`);
|
|
35
|
-
const srcFilePathSet = new Set(srcFilePaths);
|
|
36
|
-
while (true) {
|
|
37
|
-
const semanticResult = this.builderProgram.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
38
|
-
return !srcFilePathSet.has(path.resolve(sourceFile.fileName));
|
|
39
|
-
});
|
|
40
|
-
if (!semanticResult)
|
|
41
|
-
break;
|
|
42
|
-
diagnostics.push(...semanticResult.result);
|
|
43
|
-
if ("fileName" in semanticResult.affected) {
|
|
44
|
-
const emitResult = this.builderProgram.emit(semanticResult.affected, (filePath, data, writeByteOrderMark) => {
|
|
45
|
-
let realFilePath = filePath;
|
|
46
|
-
let realData = data;
|
|
47
|
-
if (PathUtil.isChildPath(realFilePath, path.resolve(distPath, path.basename(this._pkgPath), "src"))) {
|
|
48
|
-
realFilePath = path.resolve(distPath, path.relative(path.resolve(distPath, path.basename(this._pkgPath), "src"), realFilePath));
|
|
49
|
-
if (filePath.endsWith(".js.map")) {
|
|
50
|
-
const sourceMapContents = JSON.parse(realData);
|
|
51
|
-
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
52
|
-
realData = JSON.stringify(sourceMapContents);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (this._writeFileCache.get(realFilePath) !== realData) {
|
|
56
|
-
this._host.writeFile(realFilePath, realData, writeByteOrderMark);
|
|
57
|
-
}
|
|
58
|
-
this._writeFileCache.set(realFilePath, realData);
|
|
59
|
-
}, undefined, Array.isArray(this._opt.emitJs) ? !this._opt.emitJs.includes(path.resolve(semanticResult.affected.fileName)) : !this._opt.emitJs, this._opt.transforms ? {
|
|
60
|
-
before: this._opt.transforms.map((item) => typeof item.fn === "function" ? item.fn(program, item.args) : item.fn["default"](program, item.args))
|
|
61
|
-
} : undefined);
|
|
62
|
-
diagnostics.push(...emitResult.diagnostics);
|
|
63
|
-
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(semanticResult.affected));
|
|
64
|
-
affectedFilePaths.push(path.resolve(semanticResult.affected.fileName));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리 완료`, affectedFilePaths);
|
|
68
|
-
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item));
|
|
69
|
-
return {
|
|
70
|
-
affectedFilePaths,
|
|
71
|
-
results: buildResults
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=SdTsIncrementalBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdTsIncrementalBuilder.js","sourceRoot":"","sources":["../../src/build-tools/SdTsIncrementalBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAShE,MAAM,OAAO,sBAAsB;IAIjC,YAAoC,QAAgB,EAChB,gBAAoC,EACpC,KAAsB,EACtB,IAIhB;QAPgB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,qBAAgB,GAAhB,gBAAgB,CAAoB;QACpC,UAAK,GAAL,KAAK,CAAiB;QACtB,SAAI,GAAJ,IAAI,CAIpB;QATH,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAU7D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,KAIhD;QACC,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAChE,MAAM,cAAc,GAAG,EAAE,CAAC,0BAA0B,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACpH,MAAM,GAAG,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,eAAe,GAAG;YACtB,GAAG,cAAc,CAAC,OAAO;YACzB,GAAG,GAAG,EAAE,eAAe;SACxB,CAAC;QACF,MAAM,IAAI,GAAG,EAAE,CAAC,6BAA6B,CAAC,eAAe,CAAC,CAAC;QAC/D,OAAO,IAAI,sBAAsB,CAC/B,OAAO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,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAC;QAExF,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;QAE7F,OAAO;YACL,iBAAiB;YACjB,OAAO,EAAE,YAAY;SACtB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { defaultPngCompressionOptions, generatePWAAssets, toResolvedAsset, } from "@vite-pwa/assets-generator";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { PathUtil } from "@simplysm/sd-core-node";
|
|
4
|
-
export class SdCliPwaAssets {
|
|
5
|
-
static async genAsync(opt) {
|
|
6
|
-
const pkgSrcPath = PathUtil.posix(path.resolve(), "packages", opt.pkgName, "src");
|
|
7
|
-
const assets = {
|
|
8
|
-
assets: {
|
|
9
|
-
transparent: toResolvedAsset('transparent', {
|
|
10
|
-
sizes: [64, 192, 512],
|
|
11
|
-
favicons: [[64, PathUtil.posix(pkgSrcPath, "favicon.ico")]]
|
|
12
|
-
}),
|
|
13
|
-
maskable: toResolvedAsset('maskable', {
|
|
14
|
-
sizes: [512]
|
|
15
|
-
}),
|
|
16
|
-
apple: toResolvedAsset('apple', {
|
|
17
|
-
sizes: [180]
|
|
18
|
-
}),
|
|
19
|
-
},
|
|
20
|
-
png: defaultPngCompressionOptions,
|
|
21
|
-
assetName: (type, size) => {
|
|
22
|
-
switch (type) {
|
|
23
|
-
case 'transparent':
|
|
24
|
-
return PathUtil.posix(pkgSrcPath, `public/icons/icon-${size.width}x${size.height}.png`);
|
|
25
|
-
case 'maskable':
|
|
26
|
-
return PathUtil.posix(pkgSrcPath, `assets/icons/maskable-icon-${size.width}x${size.height}.png`);
|
|
27
|
-
case 'apple':
|
|
28
|
-
return PathUtil.posix(pkgSrcPath, `assets/icons/apple-touch-icon-${size.width}x${size.height}.png`);
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
await generatePWAAssets([opt.relFilePath], assets, {
|
|
33
|
-
root: process.cwd(),
|
|
34
|
-
logLevel: "info",
|
|
35
|
-
overrideAssets: true
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=SdCliPwaAssets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliPwaAssets.js","sourceRoot":"","sources":["../../src/entry/SdCliPwaAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EAEjB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAEhD,MAAM,OAAgB,cAAc;IAC3B,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAA6C;QACxE,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAElF,MAAM,MAAM,GAAmB;YAC7B,MAAM,EAAE;gBACN,WAAW,EAAE,eAAe,CAAC,aAAa,EAAE;oBAC1C,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC;oBACrB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;iBAC5D,CAAC;gBACF,QAAQ,EAAE,eAAe,CAAC,UAAU,EAAE;oBACpC,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC;gBACF,KAAK,EAAE,eAAe,CAAC,OAAO,EAAE;oBAC9B,KAAK,EAAE,CAAC,GAAG,CAAC;iBACb,CAAC;aACH;YACD,GAAG,EAAE,4BAA4B;YACjC,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;gBACxB,QAAQ,IAAI,EAAE;oBACZ,KAAK,aAAa;wBAChB,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,qBAAqB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;oBAC1F,KAAK,UAAU;wBACb,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,8BAA8B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;oBACnG,KAAK,OAAO;wBACV,OAAO,QAAQ,CAAC,KAAK,CAAC,UAAU,EAAE,iCAAiC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,MAAM,CAAC,CAAC;iBACvG;YACH,CAAC;SACF,CAAC;QAEF,MAAM,iBAAiB,CACrB,CAAC,GAAG,CAAC,WAAW,CAAC,EACjB,MAAM,EACN;YACE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;YACnB,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,IAAI;SACrB,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { build, defineConfig } from "vite";
|
|
2
|
-
import { SdCliViteExternalPlugin } from "./SdCliViteExternalPlugin";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { SdCliViteLoggerPlugin } from "./SdCliViteLoggerPlugin";
|
|
5
|
-
import { Logger } from "@simplysm/sd-core-node";
|
|
6
|
-
export const SdCliViteElectronMainPlugin = (opt) => {
|
|
7
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
|
|
8
|
-
let mainConfig;
|
|
9
|
-
return [
|
|
10
|
-
{
|
|
11
|
-
name: "sd-cli:vite:electron-main",
|
|
12
|
-
apply: "serve",
|
|
13
|
-
configureServer: (server) => {
|
|
14
|
-
server.httpServer?.on("listening", async () => {
|
|
15
|
-
mainConfig = defineConfig({
|
|
16
|
-
mode: server.config.mode,
|
|
17
|
-
define: server.config.define,
|
|
18
|
-
root: server.config.root,
|
|
19
|
-
optimizeDeps: {
|
|
20
|
-
force: server.config.optimizeDeps?.force
|
|
21
|
-
},
|
|
22
|
-
build: {
|
|
23
|
-
sourcemap: true,
|
|
24
|
-
minify: false,
|
|
25
|
-
outDir: opt.distPath,
|
|
26
|
-
lib: {
|
|
27
|
-
entry: opt.entry,
|
|
28
|
-
formats: ["cjs"],
|
|
29
|
-
fileName: () => "[name].js"
|
|
30
|
-
},
|
|
31
|
-
emptyOutDir: false
|
|
32
|
-
},
|
|
33
|
-
plugins: [
|
|
34
|
-
SdCliViteLoggerPlugin({
|
|
35
|
-
logger,
|
|
36
|
-
name: path.basename(opt.entry)
|
|
37
|
-
}),
|
|
38
|
-
SdCliViteExternalPlugin({
|
|
39
|
-
target: "node",
|
|
40
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
41
|
-
includes: ["electron"]
|
|
42
|
-
}),
|
|
43
|
-
{
|
|
44
|
-
name: ":startup",
|
|
45
|
-
closeBundle: () => {
|
|
46
|
-
server.ws.send({ type: "full-reload" });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
});
|
|
51
|
-
await build(mainConfig);
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "sd-cli:vite:electron-main",
|
|
57
|
-
apply: "build",
|
|
58
|
-
config: (config) => {
|
|
59
|
-
mainConfig = defineConfig({
|
|
60
|
-
mode: config.mode,
|
|
61
|
-
define: config.define,
|
|
62
|
-
root: config.root,
|
|
63
|
-
optimizeDeps: {
|
|
64
|
-
force: config.optimizeDeps?.force
|
|
65
|
-
},
|
|
66
|
-
build: {
|
|
67
|
-
sourcemap: false,
|
|
68
|
-
minify: true,
|
|
69
|
-
outDir: opt.distPath,
|
|
70
|
-
lib: {
|
|
71
|
-
entry: opt.entry,
|
|
72
|
-
formats: ["cjs"],
|
|
73
|
-
fileName: () => "[name].js"
|
|
74
|
-
},
|
|
75
|
-
emptyOutDir: false
|
|
76
|
-
},
|
|
77
|
-
plugins: [
|
|
78
|
-
SdCliViteLoggerPlugin({
|
|
79
|
-
logger,
|
|
80
|
-
name: path.basename(opt.entry)
|
|
81
|
-
}),
|
|
82
|
-
SdCliViteExternalPlugin({
|
|
83
|
-
target: "node",
|
|
84
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
85
|
-
includes: ["electron"]
|
|
86
|
-
}),
|
|
87
|
-
]
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
closeBundle: async () => {
|
|
91
|
-
await build(mainConfig);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
];
|
|
95
|
-
};
|
|
96
|
-
//# sourceMappingURL=SdCliViteElectronMainPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteElectronMainPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteElectronMainPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,YAAY,EAA2B,MAAM,MAAM,CAAC;AACnE,OAAO,EAAC,uBAAuB,EAAC,MAAM,2BAA2B,CAAC;AAClE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAE9C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,GAI3C,EAAkB,EAAE;IACnB,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,QAAQ,EAAE,6BAA6B,CAAC,CAAC,CAAC;IAEjF,IAAI,UAAsB,CAAC;IAE3B,OAAO;QACL;YACE,IAAI,EAAE,2BAA2B;YACjC,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,CAAC,CAAC,CAAC;YACL,CAAC;SACF;QACD;YACE,IAAI,EAAE,2BAA2B;YACjC,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjB,UAAU,GAAG,YAAY,CAAC;oBACxB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,MAAM,EAAE,MAAM,CAAC,MAAM;oBACrB,IAAI,EAAE,MAAM,CAAC,IAAI;oBACjB,YAAY,EAAE;wBACZ,KAAK,EAAE,MAAM,CAAC,YAAY,EAAE,KAAK;qBAClC;oBACD,KAAK,EAAE;wBACL,SAAS,EAAE,KAAK;wBAChB,MAAM,EAAE,IAAI;wBACZ,MAAM,EAAE,GAAG,CAAC,QAAQ;wBACpB,GAAG,EAAE;4BACH,KAAK,EAAE,GAAG,CAAC,KAAK;4BAChB,OAAO,EAAE,CAAC,KAAK,CAAC;4BAChB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW;yBAC5B;wBACD,WAAW,EAAE,KAAK;qBACnB;oBACD,OAAO,EAAE;wBACP,qBAAqB,CAAC;4BACpB,MAAM;4BACN,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;yBAC/B,CAAC;wBACF,uBAAuB,CAAC;4BACtB,MAAM,EAAE,MAAM;4BACd,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC;4BACnD,QAAQ,EAAE,CAAC,UAAU,CAAC;yBACvB,CAAC;qBACH;iBACF,CAAC,CAAC;YACL,CAAC;YACD,WAAW,EAAE,KAAK,IAAI,EAAE;gBACtB,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;YAC1B,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { builtinModules, createRequire } from "node:module";
|
|
2
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { pathToFileURL } from "url";
|
|
5
|
-
import libEsm from "lib-esm";
|
|
6
|
-
import esbuild from "esbuild";
|
|
7
|
-
export const SdCliViteExternalPlugin = (opt) => {
|
|
8
|
-
const externals = opt.includes ?? [];
|
|
9
|
-
const builtins = [
|
|
10
|
-
...builtinModules,
|
|
11
|
-
...builtinModules.map((item) => `node:${item}`)
|
|
12
|
-
];
|
|
13
|
-
return [
|
|
14
|
-
opt.target === "node" ? {
|
|
15
|
-
name: "sd-cli:vite:external",
|
|
16
|
-
enforce: "pre",
|
|
17
|
-
resolveId: (source, importer) => {
|
|
18
|
-
if (importer === undefined)
|
|
19
|
-
return;
|
|
20
|
-
if (externals.includes(source)) {
|
|
21
|
-
return {
|
|
22
|
-
id: source,
|
|
23
|
-
external: true
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (builtins.includes(source)) {
|
|
27
|
-
return {
|
|
28
|
-
id: `node:${source}`,
|
|
29
|
-
external: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
} : {
|
|
35
|
-
name: "sd-cli:vite:external",
|
|
36
|
-
enforce: "pre",
|
|
37
|
-
config: () => {
|
|
38
|
-
async function _getSnippetsAsync(moduleName, importer) {
|
|
39
|
-
const myRequire = createRequire(pathToFileURL(importer ?? process.cwd()).toString());
|
|
40
|
-
let realModuleName;
|
|
41
|
-
try {
|
|
42
|
-
realModuleName = moduleName;
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
realModuleName = await _getPreBundleAsync(moduleName);
|
|
46
|
-
}
|
|
47
|
-
const module = myRequire(realModuleName);
|
|
48
|
-
const members = Object.getOwnPropertyNames(module);
|
|
49
|
-
const { exports } = libEsm({ exports: members });
|
|
50
|
-
return `const avoid_parse_require = require; const _M_ = avoid_parse_require("${PathUtil.posix(realModuleName)}"); ${exports}`;
|
|
51
|
-
}
|
|
52
|
-
async function _getPreBundleAsync(moduleName) {
|
|
53
|
-
const outfile = path.posix.join(opt.cachePath, moduleName) + ".cjs";
|
|
54
|
-
await esbuild.build({
|
|
55
|
-
entryPoints: [moduleName],
|
|
56
|
-
outfile,
|
|
57
|
-
target: 'node18',
|
|
58
|
-
format: 'cjs',
|
|
59
|
-
bundle: true,
|
|
60
|
-
sourcemap: 'inline',
|
|
61
|
-
platform: 'node',
|
|
62
|
-
external: builtins
|
|
63
|
-
});
|
|
64
|
-
return outfile;
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
resolve: {
|
|
68
|
-
alias: [{
|
|
69
|
-
find: new RegExp(`^(${[...externals, ...builtins].join("|")})$`),
|
|
70
|
-
replacement: "$1",
|
|
71
|
-
customResolver: async (source, importer) => {
|
|
72
|
-
const id = path.posix.join(opt.cachePath, source) + ".mjs";
|
|
73
|
-
if (!FsUtil.exists(id)) {
|
|
74
|
-
await FsUtil.writeFileAsync(id, await _getSnippetsAsync(source, importer));
|
|
75
|
-
}
|
|
76
|
-
return { id };
|
|
77
|
-
}
|
|
78
|
-
}],
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
};
|
|
85
|
-
//# sourceMappingURL=SdCliViteExternalPlugin.js.map
|