@simplysm/sd-cli 10.0.40 → 10.0.47
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/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/build-tools/SdCliIndexFileGenerator.js +51 -0
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/{SdLinter.d.ts → build-tools/SdLinter.d.ts} +1 -1
- package/dist/{SdLinter.js → build-tools/SdLinter.js} +2 -1
- package/dist/build-tools/SdLinter.js.map +1 -0
- package/dist/{SdTsIncrementalBuilder.d.ts → build-tools/SdTsIncrementalBuilder.d.ts} +1 -1
- package/dist/{SdTsIncrementalBuilder.js → build-tools/SdTsIncrementalBuilder.js} +1 -1
- package/dist/build-tools/SdTsIncrementalBuilder.js.map +1 -0
- package/dist/builders/SdCliClientBuilder.js +91 -8
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliJsLibLinter.js +1 -1
- package/dist/builders/SdCliJsLibLinter.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.js +110 -11
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.js +6 -5
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +28 -7
- package/dist/entry/SdCliElectron.d.ts +5 -0
- package/dist/entry/SdCliElectron.js +59 -1
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliProject.js +85 -22
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +26 -21
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.js +3 -2
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/dist/utils/SdCliViteElectronMainPlugin.js +24 -7
- package/dist/utils/SdCliViteElectronMainPlugin.js.map +1 -1
- package/dist/utils/SdCliViteExternalPlugin.d.ts +1 -0
- package/dist/utils/SdCliViteExternalPlugin.js +9 -6
- package/dist/utils/SdCliViteExternalPlugin.js.map +1 -1
- package/dist/utils/SdCliViteReactSwcPlugin.js +2 -4
- package/dist/utils/SdCliViteReactSwcPlugin.js.map +1 -1
- package/dist/utils/sdCliTsDefineTransformer.js.map +1 -1
- package/package.json +14 -13
- package/src/build-tools/SdCliIndexFileGenerator.ts +62 -0
- package/src/{SdLinter.ts → build-tools/SdLinter.ts} +3 -2
- package/src/{SdTsIncrementalBuilder.ts → build-tools/SdTsIncrementalBuilder.ts} +2 -2
- package/src/builders/SdCliClientBuilder.ts +305 -203
- package/src/builders/SdCliJsLibLinter.ts +1 -1
- package/src/builders/SdCliServerBuilder.ts +420 -306
- package/src/builders/SdCliTsLibBuilder.ts +135 -133
- package/src/commons.ts +84 -61
- package/src/entry/SdCliElectron.ts +124 -48
- package/src/entry/SdCliProject.ts +537 -455
- package/src/index.ts +19 -1
- package/src/sd-cli.ts +190 -179
- package/src/utils/SdCliBuildResultUtil.ts +4 -3
- package/src/utils/SdCliViteElectronMainPlugin.ts +25 -7
- package/src/utils/SdCliViteExternalPlugin.ts +12 -7
- package/src/utils/SdCliViteReactSwcPlugin.ts +6 -8
- package/src/utils/sdCliTsDefineTransformer.ts +23 -23
- package/tsconfig.json +7 -1
- package/dist/SdLinter.js.map +0 -1
- package/dist/SdTsIncrementalBuilder.js.map +0 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +0 -12
- package/dist/entry/SdCliLocalUpdate.js +0 -94
- package/dist/entry/SdCliLocalUpdate.js.map +0 -1
- package/src/entry/SdCliLocalUpdate.ts +0 -125
package/src/index.ts
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "./build-tools/SdCliIndexFileGenerator";
|
|
2
|
+
export * from "./build-tools/SdLinter";
|
|
3
|
+
export * from "./build-tools/SdTsIncrementalBuilder";
|
|
4
|
+
export * from "./builders/SdCliClientBuilder";
|
|
5
|
+
export * from "./builders/SdCliJsLibLinter";
|
|
6
|
+
export * from "./builders/SdCliServerBuilder";
|
|
7
|
+
export * from "./builders/SdCliTsLibBuilder";
|
|
8
|
+
export * from "./commons";
|
|
9
|
+
export * from "./entry/SdCliElectron";
|
|
10
|
+
export * from "./entry/SdCliProject";
|
|
11
|
+
export * from "./utils/getElectronReactExternals";
|
|
12
|
+
export * from "./utils/SdCliBuildResultUtil";
|
|
13
|
+
export * from "./utils/sdCliTsDefineTransformer";
|
|
14
|
+
export * from "./utils/SdCliViteElectronMainPlugin";
|
|
15
|
+
export * from "./utils/SdCliViteExternalPlugin";
|
|
16
|
+
export * from "./utils/SdCliViteLoggerPlugin";
|
|
17
|
+
export * from "./utils/SdCliViteNodeGlobalPlugin";
|
|
18
|
+
export * from "./utils/SdCliViteReactSwcPlugin";
|
|
19
|
+
export * from "./utils/SdCliViteWatchWithResolutionsPlugin";
|
package/src/sd-cli.ts
CHANGED
|
@@ -6,196 +6,207 @@ import {SdCliProject} from "./entry/SdCliProject";
|
|
|
6
6
|
import {Logger, LoggerSeverity} from "@simplysm/sd-core-node";
|
|
7
7
|
import {EventEmitter} from "events";
|
|
8
8
|
import {SdCliElectron} from "./entry/SdCliElectron";
|
|
9
|
-
import {SdCliLocalUpdate} from "./entry/SdCliLocalUpdate";
|
|
10
9
|
|
|
11
10
|
Error.stackTraceLimit = Infinity;
|
|
12
11
|
EventEmitter.defaultMaxListeners = 0;
|
|
13
12
|
|
|
14
13
|
const argv = (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
await yargs(hideBin(process.argv))
|
|
15
|
+
.help("help", "도움말")
|
|
16
|
+
.alias("help", "h")
|
|
17
|
+
.options({
|
|
18
|
+
debug: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
describe: "디버그 로그를 표시할 것인지 여부",
|
|
21
|
+
default: false
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
.command(
|
|
25
|
+
"watch",
|
|
26
|
+
"프로젝트의 각 패키지에 대한 변경감지 빌드를 수행합니다.",
|
|
27
|
+
(cmd) => cmd.version(false).hide("help").hide("debug")
|
|
18
28
|
.options({
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
config: {
|
|
30
|
+
string: true,
|
|
31
|
+
describe: "simplysm.cjs 파일 경로"
|
|
32
|
+
},
|
|
33
|
+
options: {
|
|
34
|
+
string: true,
|
|
35
|
+
array: true,
|
|
36
|
+
describe: "옵션 설정"
|
|
37
|
+
},
|
|
38
|
+
packages: {
|
|
39
|
+
string: true,
|
|
40
|
+
array: true,
|
|
41
|
+
describe: "수행할 패키지 설정"
|
|
42
|
+
},
|
|
43
|
+
withoutLint: {
|
|
44
|
+
type: "boolean",
|
|
45
|
+
default: false,
|
|
46
|
+
describe: "린트 수행 여부"
|
|
47
|
+
}
|
|
24
48
|
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.",
|
|
127
|
-
(cmd) => cmd
|
|
128
|
-
.positional("package", {
|
|
129
|
-
type: "string",
|
|
130
|
-
describe: "패키지명",
|
|
131
|
-
demandOption: true
|
|
132
|
-
})
|
|
133
|
-
.options({
|
|
134
|
-
config: {
|
|
135
|
-
type: "string",
|
|
136
|
-
describe: "simplysm.json 파일 경로"
|
|
137
|
-
},
|
|
138
|
-
options: {
|
|
139
|
-
type: "string",
|
|
140
|
-
array: true,
|
|
141
|
-
describe: "옵션 설정 (설정파일에서 @로 시작하는 부분)"
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
)
|
|
145
|
-
.parseAsync()
|
|
49
|
+
)
|
|
50
|
+
.command(
|
|
51
|
+
"build",
|
|
52
|
+
"프로젝트의 각 패키지에 대한 빌드를 수행합니다.",
|
|
53
|
+
(cmd) => cmd.version(false).hide("help").hide("debug")
|
|
54
|
+
.options({
|
|
55
|
+
config: {
|
|
56
|
+
string: true,
|
|
57
|
+
describe: "simplysm.cjs 파일 경로"
|
|
58
|
+
},
|
|
59
|
+
options: {
|
|
60
|
+
string: true,
|
|
61
|
+
array: true,
|
|
62
|
+
describe: "옵션 설정"
|
|
63
|
+
},
|
|
64
|
+
packages: {
|
|
65
|
+
string: true,
|
|
66
|
+
array: true,
|
|
67
|
+
describe: "수행할 패키지 설정"
|
|
68
|
+
},
|
|
69
|
+
withoutLint: {
|
|
70
|
+
type: "boolean",
|
|
71
|
+
default: false,
|
|
72
|
+
describe: "린트 수행 여부"
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
)
|
|
76
|
+
.command(
|
|
77
|
+
"publish",
|
|
78
|
+
"프로젝트의 각 패키지를 배포합니다.",
|
|
79
|
+
(cmd) => cmd.version(false).hide("help").hide("debug")
|
|
80
|
+
.options({
|
|
81
|
+
noBuild: {
|
|
82
|
+
type: "boolean",
|
|
83
|
+
describe: "빌드를 하지않고 배포합니다.",
|
|
84
|
+
default: false
|
|
85
|
+
},
|
|
86
|
+
config: {
|
|
87
|
+
type: "string",
|
|
88
|
+
describe: "simplysm.cjs 파일 경로"
|
|
89
|
+
},
|
|
90
|
+
options: {
|
|
91
|
+
type: "string",
|
|
92
|
+
array: true,
|
|
93
|
+
describe: "옵션 설정"
|
|
94
|
+
},
|
|
95
|
+
packages: {
|
|
96
|
+
type: "string",
|
|
97
|
+
array: true,
|
|
98
|
+
describe: "수행할 패키지 설정"
|
|
99
|
+
},
|
|
100
|
+
withoutLint: {
|
|
101
|
+
type: "boolean",
|
|
102
|
+
default: false,
|
|
103
|
+
describe: "린트 수행 여부"
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
)
|
|
107
|
+
.command(
|
|
108
|
+
"run-electron <package>",
|
|
109
|
+
"변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.",
|
|
110
|
+
(cmd) => cmd
|
|
111
|
+
.positional("package", {
|
|
112
|
+
type: "string",
|
|
113
|
+
describe: "패키지명",
|
|
114
|
+
demandOption: true
|
|
115
|
+
})
|
|
116
|
+
.options({
|
|
117
|
+
config: {
|
|
118
|
+
type: "string",
|
|
119
|
+
describe: "simplysm.json 파일 경로"
|
|
120
|
+
},
|
|
121
|
+
options: {
|
|
122
|
+
type: "string",
|
|
123
|
+
array: true,
|
|
124
|
+
describe: "옵션 설정"
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
)
|
|
128
|
+
.command(
|
|
129
|
+
"build-electron-for-dev <package>",
|
|
130
|
+
"변경감지중인 플랫폼을 ELECTRON 앱 형태로 띄웁니다.",
|
|
131
|
+
(cmd) => cmd
|
|
132
|
+
.positional("package", {
|
|
133
|
+
type: "string",
|
|
134
|
+
describe: "패키지명",
|
|
135
|
+
demandOption: true
|
|
136
|
+
})
|
|
137
|
+
.options({
|
|
138
|
+
config: {
|
|
139
|
+
type: "string",
|
|
140
|
+
describe: "simplysm.json 파일 경로"
|
|
141
|
+
},
|
|
142
|
+
options: {
|
|
143
|
+
type: "string",
|
|
144
|
+
array: true,
|
|
145
|
+
describe: "옵션 설정"
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
)
|
|
149
|
+
.parseAsync()
|
|
146
150
|
) as any;
|
|
147
151
|
|
|
148
152
|
if (Boolean(argv.debug)) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
process.env["SD_DEBUG"] = "true";
|
|
154
|
+
Logger.setConfig({
|
|
155
|
+
console: {
|
|
156
|
+
level: LoggerSeverity.debug
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
Logger.setConfig({
|
|
162
|
+
dot: true
|
|
163
|
+
});
|
|
159
164
|
}
|
|
160
165
|
|
|
161
166
|
if (argv._[0] === "watch") {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
167
|
+
await SdCliProject
|
|
168
|
+
.watchAsync({
|
|
169
|
+
confFileRelPath: argv.config ?? "simplysm.cjs",
|
|
170
|
+
optNames: argv.options ?? [],
|
|
171
|
+
pkgNames: argv.packages ?? [],
|
|
172
|
+
withLint: argv.withoutLint !== true
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else if (argv._[0] === "build") {
|
|
176
|
+
await SdCliProject
|
|
177
|
+
.buildAsync({
|
|
178
|
+
confFileRelPath: argv.config ?? "simplysm.cjs",
|
|
179
|
+
optNames: argv.options ?? [],
|
|
180
|
+
pkgNames: argv.packages ?? [],
|
|
181
|
+
withLint: argv.withoutLint !== true
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
else if (argv._[0] === "publish") {
|
|
185
|
+
await SdCliProject
|
|
186
|
+
.publishAsync({
|
|
187
|
+
noBuild: argv.noBuild,
|
|
188
|
+
confFileRelPath: argv.config ?? "simplysm.cjs",
|
|
189
|
+
optNames: argv.options ?? [],
|
|
190
|
+
pkgNames: argv.packages ?? [],
|
|
191
|
+
withLint: argv.withoutLint !== true
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
else if (argv._[0] === "run-electron") {
|
|
195
|
+
await SdCliElectron
|
|
196
|
+
.runAsync({
|
|
197
|
+
confFileRelPath: argv.config ?? "simplysm.cjs",
|
|
198
|
+
optNames: argv.options ?? [],
|
|
199
|
+
pkgName: argv.package
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
else if (argv._[0] === "build-electron-for-dev") {
|
|
203
|
+
await SdCliElectron
|
|
204
|
+
.buildForDevAsync({
|
|
205
|
+
confFileRelPath: argv.config ?? "simplysm.cjs",
|
|
206
|
+
optNames: argv.options ?? [],
|
|
207
|
+
pkgName: argv.package
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
throw new Error(`명령어가 잘못 되었습니다.\n\t${argv._[0]}\n`);
|
|
201
212
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import os from "os";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import {
|
|
4
|
+
import {ISdCliPackageBuildResult} from "../commons";
|
|
5
5
|
|
|
6
6
|
export class SdCliBuildResultUtil {
|
|
7
7
|
public static convertFromTsDiag(diag: ts.Diagnostic): ISdCliPackageBuildResult {
|
|
@@ -24,7 +24,8 @@ export class SdCliBuildResultUtil {
|
|
|
24
24
|
char,
|
|
25
25
|
code,
|
|
26
26
|
severity,
|
|
27
|
-
message
|
|
27
|
+
message,
|
|
28
|
+
type: "build" as const
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -36,7 +37,7 @@ export class SdCliBuildResultUtil {
|
|
|
36
37
|
if (result.code !== undefined) {
|
|
37
38
|
str += `${result.code}: `;
|
|
38
39
|
}
|
|
39
|
-
str +=
|
|
40
|
+
str += `(${result.type}) ${result.severity} ${result.message}`;
|
|
40
41
|
|
|
41
42
|
return str;
|
|
42
43
|
}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import {build, defineConfig, PluginOption, UserConfig} from "vite";
|
|
2
2
|
import {SdCliViteExternalPlugin} from "./SdCliViteExternalPlugin";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import {SdCliViteLoggerPlugin} from "./SdCliViteLoggerPlugin";
|
|
5
|
+
import {Logger} from "@simplysm/sd-core-node";
|
|
4
6
|
|
|
5
7
|
export const SdCliViteElectronMainPlugin = (opt: {
|
|
6
8
|
entry: string;
|
|
7
9
|
distPath: string;
|
|
8
10
|
cachePath: string;
|
|
9
11
|
}): PluginOption[] => {
|
|
12
|
+
const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
|
|
13
|
+
|
|
10
14
|
let mainConfig: UserConfig;
|
|
11
15
|
|
|
12
16
|
return [
|
|
@@ -30,11 +34,16 @@ export const SdCliViteElectronMainPlugin = (opt: {
|
|
|
30
34
|
entry: opt.entry,
|
|
31
35
|
formats: ["cjs"],
|
|
32
36
|
fileName: () => "[name].js"
|
|
33
|
-
}
|
|
37
|
+
},
|
|
38
|
+
emptyOutDir: false
|
|
34
39
|
},
|
|
35
|
-
customLogger: server.config.customLogger,
|
|
36
40
|
plugins: [
|
|
41
|
+
SdCliViteLoggerPlugin({
|
|
42
|
+
logger,
|
|
43
|
+
name: path.basename(opt.entry)
|
|
44
|
+
}),
|
|
37
45
|
SdCliViteExternalPlugin({
|
|
46
|
+
target: "node",
|
|
38
47
|
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
39
48
|
nodeBuiltinModules: true,
|
|
40
49
|
includes: ["electron"]
|
|
@@ -59,9 +68,6 @@ export const SdCliViteElectronMainPlugin = (opt: {
|
|
|
59
68
|
mode: config.mode,
|
|
60
69
|
define: config.define,
|
|
61
70
|
root: config.root,
|
|
62
|
-
resolve: {
|
|
63
|
-
alias: config.resolve?.alias
|
|
64
|
-
},
|
|
65
71
|
optimizeDeps: {
|
|
66
72
|
force: config.optimizeDeps?.force
|
|
67
73
|
},
|
|
@@ -73,9 +79,21 @@ export const SdCliViteElectronMainPlugin = (opt: {
|
|
|
73
79
|
entry: opt.entry,
|
|
74
80
|
formats: ["cjs"],
|
|
75
81
|
fileName: () => "[name].js"
|
|
76
|
-
}
|
|
82
|
+
},
|
|
83
|
+
emptyOutDir: false
|
|
77
84
|
},
|
|
78
|
-
|
|
85
|
+
plugins: [
|
|
86
|
+
SdCliViteLoggerPlugin({
|
|
87
|
+
logger,
|
|
88
|
+
name: path.basename(opt.entry)
|
|
89
|
+
}),
|
|
90
|
+
SdCliViteExternalPlugin({
|
|
91
|
+
target: "node",
|
|
92
|
+
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
93
|
+
nodeBuiltinModules: true,
|
|
94
|
+
includes: ["electron"]
|
|
95
|
+
}),
|
|
96
|
+
]
|
|
79
97
|
});
|
|
80
98
|
},
|
|
81
99
|
closeBundle: async () => {
|
|
@@ -8,6 +8,7 @@ import libEsm from "lib-esm";
|
|
|
8
8
|
import esbuild from "esbuild";
|
|
9
9
|
|
|
10
10
|
export const SdCliViteExternalPlugin = (opt: {
|
|
11
|
+
target: "browser" | "node";
|
|
11
12
|
cachePath: string;
|
|
12
13
|
nodeBuiltinModules?: boolean;
|
|
13
14
|
dependencies?: boolean;
|
|
@@ -15,16 +16,15 @@ export const SdCliViteExternalPlugin = (opt: {
|
|
|
15
16
|
}): PluginOption[] => {
|
|
16
17
|
const externals = opt.includes ?? [];
|
|
17
18
|
|
|
18
|
-
const builtins =[
|
|
19
|
+
const builtins = [
|
|
19
20
|
...builtinModules,
|
|
20
21
|
...builtinModules.map((item) => `node:${item}`)
|
|
21
22
|
];
|
|
22
23
|
|
|
23
24
|
return [
|
|
24
|
-
{
|
|
25
|
+
opt.target === "node" ? {
|
|
25
26
|
name: "sd-cli:vite:external",
|
|
26
27
|
enforce: "pre",
|
|
27
|
-
apply: "build",
|
|
28
28
|
config: (conf) => {
|
|
29
29
|
if (opt.dependencies) {
|
|
30
30
|
const npmConfigPath = FsUtil.findAllParentChildPaths("package.json", conf.root ?? opt.cachePath).first()!;
|
|
@@ -37,20 +37,25 @@ export const SdCliViteExternalPlugin = (opt: {
|
|
|
37
37
|
resolveId: (source, importer) => {
|
|
38
38
|
if (importer === undefined) return;
|
|
39
39
|
|
|
40
|
-
if (
|
|
40
|
+
if (externals.includes(source)) {
|
|
41
41
|
return {
|
|
42
42
|
id: source,
|
|
43
43
|
external: true
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
if (builtins.includes(source)) {
|
|
48
|
+
return {
|
|
49
|
+
id: `node:${source}`,
|
|
50
|
+
external: true
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
49
|
-
}
|
|
50
|
-
{
|
|
56
|
+
} : {
|
|
51
57
|
name: "sd-cli:vite:external",
|
|
52
58
|
enforce: "pre",
|
|
53
|
-
apply: "serve",
|
|
54
59
|
config: (conf) => {
|
|
55
60
|
if (opt.dependencies) {
|
|
56
61
|
const npmConfigPath = FsUtil.findAllParentChildPaths("package.json", conf.root ?? opt.cachePath).first()!;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {PluginOption} from "vite";
|
|
2
|
+
import {FsUtil} from "@simplysm/sd-core-node";
|
|
3
|
+
import {SourceMapPayload} from "module";
|
|
4
|
+
import {Output, ParserConfig, transform,} from "@swc/core";
|
|
5
5
|
import path from "path";
|
|
6
6
|
|
|
7
7
|
const runtimePublicPath = "/@react-refresh";
|
|
@@ -127,10 +127,8 @@ const transformWithOptions = async (
|
|
|
127
127
|
react: {
|
|
128
128
|
runtime: "automatic",
|
|
129
129
|
importSource: "react",
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
development: true,
|
|
133
|
-
} : {}
|
|
130
|
+
refresh: dev,
|
|
131
|
+
development: dev,
|
|
134
132
|
},
|
|
135
133
|
decoratorMetadata: true
|
|
136
134
|
},
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
|
|
3
3
|
export function sdCliTsDefineTransformer(_: ts.Program, args: { replace: Record<string, string> }): ts.TransformerFactory<ts.SourceFile> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
4
|
+
return (context: ts.TransformationContext) => {
|
|
5
|
+
return (sourceFile: ts.SourceFile): ts.SourceFile => {
|
|
6
|
+
const visitor = (node: ts.Node): ts.Node => {
|
|
7
|
+
if (
|
|
8
|
+
ts.isCallExpression(node) ||
|
|
9
|
+
ts.isIdentifier(node) ||
|
|
10
|
+
ts.isExpressionStatement(node) ||
|
|
11
|
+
ts.isPropertyAccessExpression(node) ||
|
|
12
|
+
ts.isTypeOfExpression(node) ||
|
|
13
|
+
ts.isElementAccessExpression(node)
|
|
14
|
+
) {
|
|
15
|
+
const regex = /\[["'`](.*)["'`]]/;
|
|
16
|
+
const replaceKey = node.getText().replace(new RegExp(regex, "g"), str => `.${str.match(regex)![1]}`);
|
|
17
|
+
const replaceValue = args.replace[replaceKey];
|
|
18
|
+
if (replaceValue !== undefined) {
|
|
19
|
+
return ts.factory.createIdentifier(replaceValue);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
return ts.visitEachChild(node, visitor, context);
|
|
26
|
+
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
};
|
|
28
|
+
return ts.visitNode(sourceFile, visitor) as ts.SourceFile;
|
|
30
29
|
};
|
|
30
|
+
};
|
|
31
31
|
}
|