@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteExternalPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteExternalPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAClC,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAIvC,EAAkB,EAAE;IACnB,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;IAErC,MAAM,QAAQ,GAAG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,CAAC;6BACF,CAAC;qBACH;iBACF,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
3
|
-
export const SdCliViteLazyImportPlugin = () => {
|
|
4
|
-
return [
|
|
5
|
-
{
|
|
6
|
-
name: "sd-cli:vite:lazy-import",
|
|
7
|
-
apply: "serve",
|
|
8
|
-
transform: (code, id) => {
|
|
9
|
-
const realId = id.split("?").first();
|
|
10
|
-
if (/[\\\/]AppPage\.tsx/.test(realId) && code.includes("lazy(")) {
|
|
11
|
-
const pageFileRelPaths = FsUtil.glob(path.resolve(path.dirname(realId), "pages/**/*.tsx"))
|
|
12
|
-
.map((item) => PathUtil.posix(path.relative(path.dirname(realId), item)));
|
|
13
|
-
return `
|
|
14
|
-
${pageFileRelPaths.map((item) => `import ("./${item}");`).join("\n")}
|
|
15
|
-
|
|
16
|
-
${code}`;
|
|
17
|
-
}
|
|
18
|
-
return null;
|
|
19
|
-
},
|
|
20
|
-
}
|
|
21
|
-
];
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=SdCliViteLazyImportPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteLazyImportPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteLazyImportPlugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAmB,EAAE;IAC5D,OAAO;QACL;YACE,IAAI,EAAE,yBAAyB;YAC/B,KAAK,EAAE,OAAO;YACd,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE;gBACtB,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAG,CAAC;gBACtC,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;oBAC/D,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC;yBACvF,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;oBAE5E,OAAO;EACf,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;EAElE,IAAI,EAAE,CAAC;iBACA;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as vite from "vite";
|
|
2
|
-
export const SdCliViteLoggerPlugin = (opt) => {
|
|
3
|
-
return [
|
|
4
|
-
{
|
|
5
|
-
name: "sd-cli:vite:logger",
|
|
6
|
-
enforce: "pre",
|
|
7
|
-
config: () => ({
|
|
8
|
-
customLogger: {
|
|
9
|
-
...vite.createLogger(),
|
|
10
|
-
info: (msg) => {
|
|
11
|
-
opt.logger.debug(`[${opt.name}] ${msg}`);
|
|
12
|
-
},
|
|
13
|
-
warn: (msg) => {
|
|
14
|
-
opt.logger.warn(`[${opt.name}] ${msg}`);
|
|
15
|
-
},
|
|
16
|
-
error: (msg) => {
|
|
17
|
-
opt.logger.error(`[${opt.name}] ${msg}`);
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
];
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=SdCliViteLoggerPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteLoggerPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteLoggerPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAGrC,EAAkB,EAAE;IACnB,OAAO;QACL;YACE,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACb,YAAY,EAAE;oBACZ,GAAG,IAAI,CAAC,YAAY,EAAE;oBACtB,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;wBACZ,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;oBAC3C,CAAC;oBACD,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;wBACZ,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;oBAC1C,CAAC;oBACD,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;wBACb,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC,CAAC;oBAC3C,CAAC;iBACF;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import stdLibBrowser from "node-stdlib-browser";
|
|
2
|
-
import inject from "@rollup/plugin-inject";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
const esbuildShim = fileURLToPath(await import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim"));
|
|
5
|
-
export const SdCliViteNodeGlobalPlugin = () => {
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: "sd-cli:vite:node-global",
|
|
9
|
-
enforce: "pre",
|
|
10
|
-
config: () => ({
|
|
11
|
-
optimizeDeps: {
|
|
12
|
-
include: ["buffer", "process"]
|
|
13
|
-
},
|
|
14
|
-
resolve: {
|
|
15
|
-
alias: stdLibBrowser
|
|
16
|
-
}
|
|
17
|
-
}),
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
enforce: "post",
|
|
21
|
-
...inject({
|
|
22
|
-
global: [esbuildShim, 'global'],
|
|
23
|
-
process: [esbuildShim, 'process'],
|
|
24
|
-
Buffer: [esbuildShim, 'Buffer']
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
};
|
|
29
|
-
//# sourceMappingURL=SdCliViteNodeGlobalPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteNodeGlobalPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteNodeGlobalPlugin.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,qBAAqB,CAAC;AAChD,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAC;AAElC,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,OAAQ,CAAC,0CAA0C,CAAC,CAAC,CAAC;AAE1G,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAmB,EAAE;IAC5D,OAAO;QACL;YACE,IAAI,EAAE,yBAAyB;YAC/B,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACb,YAAY,EAAE;oBACZ,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;iBAC/B;gBACD,OAAO,EAAE;oBACP,KAAK,EAAE,aAAa;iBACrB;aACF,CAAC;SACH;QACD;YACE,OAAO,EAAE,MAAM;YACf,GAAG,MAAM,CAAC;gBACR,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC;gBAC/B,OAAO,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC;gBACjC,MAAM,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC;aAChC,CAAC;SACa;KAClB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { FsUtil } from "@simplysm/sd-core-node";
|
|
2
|
-
import { transform, } from "@swc/core";
|
|
3
|
-
import path from "path";
|
|
4
|
-
const runtimePublicPath = "/@react-refresh";
|
|
5
|
-
export const SdCliViteReactSwcPlugin = () => {
|
|
6
|
-
return [
|
|
7
|
-
{
|
|
8
|
-
name: "sd-cli:vite:react-swc:resolve-runtime",
|
|
9
|
-
apply: "serve",
|
|
10
|
-
enforce: "pre",
|
|
11
|
-
resolveId: (source) => (source === runtimePublicPath ? source : undefined),
|
|
12
|
-
load: (id) => {
|
|
13
|
-
if (id !== runtimePublicPath)
|
|
14
|
-
return;
|
|
15
|
-
return FsUtil.readFile(path.resolve(process.cwd(), "node_modules/@vitejs/plugin-react-swc/refresh-runtime.js"));
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: "sd-cli:vite:react-swc",
|
|
20
|
-
apply: "serve",
|
|
21
|
-
config: () => ({
|
|
22
|
-
esbuild: false,
|
|
23
|
-
optimizeDeps: {
|
|
24
|
-
include: [`react/jsx-dev-runtime`, `react/jsx-runtime`],
|
|
25
|
-
},
|
|
26
|
-
}),
|
|
27
|
-
transformIndexHtml: (html, ctx) => [
|
|
28
|
-
{
|
|
29
|
-
tag: "script",
|
|
30
|
-
attrs: { type: "module" },
|
|
31
|
-
children: `import { injectIntoGlobalHook } from "${ctx.server.config.base + runtimePublicPath.slice(1)}";
|
|
32
|
-
injectIntoGlobalHook(window);
|
|
33
|
-
window.$RefreshReg$ = () => {};
|
|
34
|
-
window.$RefreshSig$ = () => (type) => type;`,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
transform: async (code, id) => {
|
|
38
|
-
const realId = id.split("?").first();
|
|
39
|
-
const result = await transformWithOptions(realId, code, true);
|
|
40
|
-
if (!result)
|
|
41
|
-
return;
|
|
42
|
-
if (!/\$Refresh(?:Reg|Sig)\$\(/.test(result.code)) {
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
result.code = `import * as RefreshRuntime from "${runtimePublicPath}";
|
|
46
|
-
|
|
47
|
-
if (!window.$RefreshReg$) throw new Error("React refresh preamble was not loaded. Something is wrong.");
|
|
48
|
-
const prevRefreshReg = window.$RefreshReg$;
|
|
49
|
-
const prevRefreshSig = window.$RefreshSig$;
|
|
50
|
-
window.$RefreshReg$ = RefreshRuntime.getRefreshReg("${realId}");
|
|
51
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
52
|
-
|
|
53
|
-
${result.code}
|
|
54
|
-
|
|
55
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
56
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
57
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
58
|
-
RefreshRuntime.registerExportsForReactRefresh("${realId}", currentExports);
|
|
59
|
-
import.meta.hot.accept((nextExports) => {
|
|
60
|
-
if (!nextExports) return;
|
|
61
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports);
|
|
62
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
`;
|
|
66
|
-
const sourceMap = JSON.parse(result.map);
|
|
67
|
-
sourceMap.mappings = ";;;;;;;;" + sourceMap.mappings;
|
|
68
|
-
return { code: result.code, map: sourceMap };
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: "sd-cli:vite:react-swc",
|
|
73
|
-
apply: "build",
|
|
74
|
-
enforce: "pre",
|
|
75
|
-
config: () => ({
|
|
76
|
-
esbuild: {
|
|
77
|
-
minifyIdentifiers: false,
|
|
78
|
-
},
|
|
79
|
-
build: {
|
|
80
|
-
rollupOptions: {
|
|
81
|
-
onwarn: (warning, defaultHandler) => {
|
|
82
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" &&
|
|
83
|
-
warning.message.includes("use client")) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
defaultHandler(warning);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
transform: (code, _id) => transformWithOptions(_id.split("?")[0], code, false)
|
|
92
|
-
}
|
|
93
|
-
];
|
|
94
|
-
};
|
|
95
|
-
const transformWithOptions = async (id, code, dev) => {
|
|
96
|
-
const parser = id.endsWith(".tsx") ? { syntax: "typescript", tsx: true, decorators: true }
|
|
97
|
-
: id.endsWith(".ts") ? { syntax: "typescript", tsx: false, decorators: true }
|
|
98
|
-
: id.endsWith(".jsx") ? { syntax: "ecmascript", jsx: true }
|
|
99
|
-
: undefined;
|
|
100
|
-
if (!parser)
|
|
101
|
-
return;
|
|
102
|
-
let result;
|
|
103
|
-
try {
|
|
104
|
-
result = await transform(code, {
|
|
105
|
-
filename: id,
|
|
106
|
-
swcrc: false,
|
|
107
|
-
configFile: false,
|
|
108
|
-
sourceMaps: true,
|
|
109
|
-
jsc: {
|
|
110
|
-
target: "es2021",
|
|
111
|
-
parser,
|
|
112
|
-
transform: {
|
|
113
|
-
useDefineForClassFields: true,
|
|
114
|
-
react: {
|
|
115
|
-
runtime: "automatic",
|
|
116
|
-
importSource: "react",
|
|
117
|
-
refresh: dev,
|
|
118
|
-
development: dev,
|
|
119
|
-
},
|
|
120
|
-
decoratorMetadata: true
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
const message = e.message;
|
|
127
|
-
const fileStartIndex = message.indexOf("╭─[");
|
|
128
|
-
if (fileStartIndex !== -1) {
|
|
129
|
-
const match = message.slice(fileStartIndex).match(/:(\d+):(\d+)]/);
|
|
130
|
-
if (match) {
|
|
131
|
-
e.line = match[1];
|
|
132
|
-
e.column = match[2];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
throw e;
|
|
136
|
-
}
|
|
137
|
-
return result;
|
|
138
|
-
};
|
|
139
|
-
//# sourceMappingURL=SdCliViteReactSwcPlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteReactSwcPlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteReactSwcPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAE9C,OAAO,EAAuB,SAAS,GAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAmB,EAAE;IAC1D,OAAO;QACL;YACE,IAAI,EAAE,uCAAuC;YAC7C,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,KAAK;YACd,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1E,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;gBACX,IAAI,EAAE,KAAK,iBAAiB;oBAAE,OAAO;gBACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,0DAA0D,CAAC,CAAC,CAAC;YAClH,CAAC;SACF;QACD;YACE,IAAI,EAAE,uBAAuB;YAC7B,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACb,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE;oBACZ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;YACZ,KAAK,EAAE,KAAK;YACZ,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE;gBACH,MAAM,EAAE,QAAQ;gBAChB,MAAM;gBACN,SAAS,EAAE;oBACT,uBAAuB,EAAE,IAAI;oBAC7B,KAAK,EAAE;wBACL,OAAO,EAAE,WAAW;wBACpB,YAAY,EAAE,OAAO;wBACrB,OAAO,EAAE,GAAG;wBACZ,WAAW,EAAE,GAAG;qBACjB;oBACD,iBAAiB,EAAE,IAAI;iBACxB;aACF;SACF,CAAC,CAAC;KACJ;IACD,OAAO,CAAM,EAAE;QACb,MAAM,OAAO,GAAW,CAAC,CAAC,OAAO,CAAC;QAClC,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9C,IAAI,cAAc,KAAK,CAAC,CAAC,EAAE;YACzB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YACnE,IAAI,KAAK,EAAE;gBACT,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClB,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aACrB;SACF;QACD,MAAM,CAAC,CAAC;KACT;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { FsUtil } from "@simplysm/sd-core-node";
|
|
3
|
-
export const SdCliViteServeOptimizeExcludePlugin = (moduleGlobs) => {
|
|
4
|
-
return [{
|
|
5
|
-
name: "sd-cli:vite:serve-optimize-exclude",
|
|
6
|
-
apply: "serve",
|
|
7
|
-
enforce: "pre",
|
|
8
|
-
config: (conf) => {
|
|
9
|
-
const pkgPath = path.resolve(conf.root, "..");
|
|
10
|
-
const pkgNpmConf = FsUtil.readJson(path.resolve(pkgPath, "package.json"));
|
|
11
|
-
const pkgDeps = Object.keys(pkgNpmConf.dependencies ?? {});
|
|
12
|
-
const modulePaths = moduleGlobs.mapMany((item) => FsUtil.glob(path.resolve(process.cwd(), "node_modules", item))).distinct();
|
|
13
|
-
const moduleNames = modulePaths.map((item) => item.match(/[\\\/]node_modules[\\\/](.*)/)[1].replace(/\\/g, "/"))
|
|
14
|
-
.filter((item) => pkgDeps.includes(item))
|
|
15
|
-
.distinct();
|
|
16
|
-
const subDeps = [];
|
|
17
|
-
for (const moduleName of moduleNames) {
|
|
18
|
-
const moduleNpmConf = FsUtil.readJson(path.resolve(process.cwd(), "node_modules", moduleName, "package.json"));
|
|
19
|
-
const depNames = Object.keys(moduleNpmConf.dependencies ?? {});
|
|
20
|
-
subDeps.push(...depNames.filter((item) => !moduleNames.includes(item)));
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
server: {
|
|
24
|
-
watch: {
|
|
25
|
-
ignored: moduleNames.map((item) => `!**/node_modules/${item}/**`)
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
optimizeDeps: {
|
|
29
|
-
exclude: moduleNames,
|
|
30
|
-
include: subDeps
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}];
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=SdCliViteServeOptimizeExcludePlugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SdCliViteServeOptimizeExcludePlugin.js","sourceRoot":"","sources":["../../src/utils/SdCliViteServeOptimizeExcludePlugin.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAG9C,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,WAAqB,EAAkB,EAAE;IAC3F,OAAO,CAAC;YACN,IAAI,EAAE,oCAAoC;YAC1C,KAAK,EAAE,OAAO;YACd,OAAO,EAAE,KAAK;Y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,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACzE;gBAED,OAAO;oBACL,MAAM,EAAE;wBACN,KAAK,EAAE;4BACL,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,oBAAoB,IAAI,KAAK,CAAC;yBAClE;qBACF;oBACD,YAAY,EAAE;wBACZ,OAAO,EAAE,WAAW;wBACpB,OAAO,EAAE,OAAO;qBACjB;iBACF,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getElectronReactExternals: (pkgPath: string, deps: string[]) => string[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { FsUtil } from "@simplysm/sd-core-node";
|
|
2
|
-
export const getElectronReactExternals = (pkgPath, deps) => {
|
|
3
|
-
const result = [];
|
|
4
|
-
for (const dep of deps) {
|
|
5
|
-
if (dep === "electron")
|
|
6
|
-
continue;
|
|
7
|
-
const depNpmConfFilePath = FsUtil.findAllParentChildPaths(`node_modules/${dep}/package.json`, pkgPath).first();
|
|
8
|
-
if (depNpmConfFilePath === undefined)
|
|
9
|
-
continue;
|
|
10
|
-
const depNpmConf = FsUtil.readJson(depNpmConfFilePath);
|
|
11
|
-
if (depNpmConf.dependencies && Object.keys(depNpmConf.dependencies).includes("react"))
|
|
12
|
-
continue;
|
|
13
|
-
result.push(dep);
|
|
14
|
-
}
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=getElectronReactExternals.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getElectronReactExternals.js","sourceRoot":"","sources":["../../src/utils/getElectronReactExternals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAG9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,OAAe,EAAE,IAAc,EAAY,EAAE;IACrF,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,IAAI,GAAG,KAAK,UAAU;YAAE,SAAS;QAEjC,MAAM,kBAAkB,GAAG,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,GAAG,eAAe,EAAE,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC;QAC/G,IAAI,kBAAkB,KAAK,SAAS;YAAE,SAAS;QAE/C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAe,CAAC;QACrE,IAAI,UAAU,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAS;QAEhG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAClB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
export function sdCliTsDefineTransformer(_, args) {
|
|
3
|
-
return (context) => {
|
|
4
|
-
return (sourceFile) => {
|
|
5
|
-
const visitor = (node) => {
|
|
6
|
-
if (ts.isCallExpression(node) ||
|
|
7
|
-
ts.isIdentifier(node) ||
|
|
8
|
-
ts.isExpressionStatement(node) ||
|
|
9
|
-
ts.isPropertyAccessExpression(node) ||
|
|
10
|
-
ts.isTypeOfExpression(node) ||
|
|
11
|
-
ts.isElementAccessExpression(node)) {
|
|
12
|
-
const regex = /\[["'`](.*)["'`]]/;
|
|
13
|
-
const replaceKey = node.getText().replace(new RegExp(regex, "g"), (str) => `.${str.match(regex)[1]}`);
|
|
14
|
-
const replaceValue = args.replace[replaceKey];
|
|
15
|
-
if (replaceValue !== undefined) {
|
|
16
|
-
return ts.factory.createIdentifier(replaceValue);
|
|
17
|
-
}
|
|
18
|
-
return node;
|
|
19
|
-
}
|
|
20
|
-
return ts.visitEachChild(node, visitor, context);
|
|
21
|
-
};
|
|
22
|
-
return ts.visitNode(sourceFile, visitor);
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=sdCliTsDefineTransformer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdCliTsDefineTransformer.js","sourceRoot":"","sources":["../../src/utils/sdCliTsDefineTransformer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,wBAAwB,CAAC,CAAa,EAAE,IAEvD;IACC,OAAO,CAAC,OAAiC,EAAE,EAAE;QAC3C,OAAO,CAAC,UAAyB,EAAiB,EAAE;YAClD,MAAM,OAAO,GAAG,CAAC,IAAa,EAAW,EAAE;gBACzC,IACE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC;oBACzB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;oBACrB,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC;oBAC9B,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC;oBACnC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC;oBAC3B,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAClC;oBACA,MAAM,KAAK,GAAG,mBAAmB,CAAC;oBAClC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;oBACvG,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;oBAC9C,IAAI,YAAY,KAAK,SAAS,EAAE;wBAC9B,OAAO,EAAE,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;qBAClD;oBAED,OAAO,IAAI,CAAC;iBACb;gBAED,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACnD,CAAC,CAAC;YAEF,OAAO,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAkB,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,125 +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
|
-
import {ISdCliPackageBuildResult} from "../commons";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface IOptTransform<T> {
|
|
9
|
-
fn: (_: ts.Program, arg: T) => ts.TransformerFactory<ts.SourceFile>,
|
|
10
|
-
args: T
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class SdTsIncrementalBuilder {
|
|
14
|
-
public builderProgram?: ts.SemanticDiagnosticsBuilderProgram;
|
|
15
|
-
private readonly _writeFileCache = new Map<string, string>();
|
|
16
|
-
|
|
17
|
-
public constructor(private readonly _pkgPath: string,
|
|
18
|
-
private readonly _compilerOptions: ts.CompilerOptions,
|
|
19
|
-
private readonly _host: ts.CompilerHost,
|
|
20
|
-
private readonly _opt: {
|
|
21
|
-
emitJs: boolean | string[],
|
|
22
|
-
compilerOptions?: ts.CompilerOptions,
|
|
23
|
-
transforms?: IOptTransform<any>[]
|
|
24
|
-
}) {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public static async createAsync(pkgPath: string, optFn: (compilerOptions: ts.CompilerOptions) => {
|
|
28
|
-
emitJs: boolean | string[],
|
|
29
|
-
compilerOptions?: ts.CompilerOptions,
|
|
30
|
-
transforms?: IOptTransform<any>[]
|
|
31
|
-
}): Promise<SdTsIncrementalBuilder> {
|
|
32
|
-
const tsConfigFilePath = path.resolve(pkgPath, "tsconfig.json");
|
|
33
|
-
const parsedTsConfig = ts.parseJsonConfigFileContent(await FsUtil.readJsonAsync(tsConfigFilePath), ts.sys, pkgPath);
|
|
34
|
-
const opt = optFn(parsedTsConfig.options);
|
|
35
|
-
const compilerOptions = {
|
|
36
|
-
...parsedTsConfig.options,
|
|
37
|
-
...opt?.compilerOptions
|
|
38
|
-
};
|
|
39
|
-
const host = ts.createIncrementalCompilerHost(compilerOptions);
|
|
40
|
-
return new SdTsIncrementalBuilder(
|
|
41
|
-
pkgPath,
|
|
42
|
-
compilerOptions,
|
|
43
|
-
host,
|
|
44
|
-
opt
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
public async buildAsync(): Promise<{
|
|
49
|
-
affectedFilePaths: string[];
|
|
50
|
-
results: ISdCliPackageBuildResult[];
|
|
51
|
-
}> {
|
|
52
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdTsIncrementalBuilder", "buildAsync"]);
|
|
53
|
-
|
|
54
|
-
const distPath = this._compilerOptions.outDir ?? path.resolve(this._pkgPath, "dist");
|
|
55
|
-
const srcGlobPath = path.resolve(this._pkgPath, "src/**/*.{ts,tsx}");
|
|
56
|
-
const srcFilePaths = await FsUtil.globAsync(srcGlobPath);
|
|
57
|
-
this.builderProgram = ts.createSemanticDiagnosticsBuilderProgram(
|
|
58
|
-
srcFilePaths,
|
|
59
|
-
this._compilerOptions,
|
|
60
|
-
this._host,
|
|
61
|
-
this.builderProgram
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const diagnostics: ts.Diagnostic[] = [];
|
|
65
|
-
const affectedFilePaths: string[] = [];
|
|
66
|
-
|
|
67
|
-
diagnostics.push(
|
|
68
|
-
...this.builderProgram.getOptionsDiagnostics(),
|
|
69
|
-
...this.builderProgram.getGlobalDiagnostics(),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const program = this.builderProgram.getProgram();
|
|
73
|
-
|
|
74
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리중...`);
|
|
75
|
-
const srcFilePathSet = new Set<string>(srcFilePaths);
|
|
76
|
-
while (true) {
|
|
77
|
-
const semanticResult = this.builderProgram.getSemanticDiagnosticsOfNextAffectedFile(undefined, (sourceFile) => {
|
|
78
|
-
return !srcFilePathSet.has(path.resolve(sourceFile.fileName));
|
|
79
|
-
});
|
|
80
|
-
if (!semanticResult) break;
|
|
81
|
-
diagnostics.push(...semanticResult.result);
|
|
82
|
-
|
|
83
|
-
if ("fileName" in semanticResult.affected) {
|
|
84
|
-
const emitResult = this.builderProgram.emit
|
|
85
|
-
(semanticResult.affected,
|
|
86
|
-
(filePath, data, writeByteOrderMark) => {
|
|
87
|
-
let realFilePath = filePath;
|
|
88
|
-
let realData = data;
|
|
89
|
-
if (PathUtil.isChildPath(realFilePath, path.resolve(distPath, path.basename(this._pkgPath), "src"))) {
|
|
90
|
-
realFilePath = path.resolve(distPath, path.relative(path.resolve(distPath, path.basename(this._pkgPath), "src"), realFilePath));
|
|
91
|
-
|
|
92
|
-
if (filePath.endsWith(".js.map")) {
|
|
93
|
-
const sourceMapContents = JSON.parse(realData);
|
|
94
|
-
sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
|
|
95
|
-
realData = JSON.stringify(sourceMapContents);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (this._writeFileCache.get(realFilePath) !== realData) {
|
|
100
|
-
this._host.writeFile(realFilePath, realData, writeByteOrderMark);
|
|
101
|
-
}
|
|
102
|
-
this._writeFileCache.set(realFilePath, realData);
|
|
103
|
-
},
|
|
104
|
-
undefined,
|
|
105
|
-
Array.isArray(this._opt.emitJs) ? !this._opt.emitJs.includes(path.resolve(semanticResult.affected.fileName)) : !this._opt.emitJs,
|
|
106
|
-
this._opt.transforms ? {
|
|
107
|
-
before: this._opt.transforms.map((item) => typeof item.fn === "function" ? item.fn(program, item.args) : (item.fn["default"] as any)(program, item.args))
|
|
108
|
-
} : undefined
|
|
109
|
-
);
|
|
110
|
-
diagnostics.push(...emitResult.diagnostics);
|
|
111
|
-
|
|
112
|
-
diagnostics.push(...this.builderProgram.getSyntacticDiagnostics(semanticResult.affected));
|
|
113
|
-
affectedFilePaths.push(path.resolve(semanticResult.affected.fileName));
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
logger.debug(`[${path.basename(this._pkgPath)}] 영향받는 파일 확인 및 처리 완료`, affectedFilePaths);
|
|
117
|
-
|
|
118
|
-
const buildResults = diagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item));
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
affectedFilePaths,
|
|
122
|
-
results: buildResults
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultPngCompressionOptions,
|
|
3
|
-
generatePWAAssets,
|
|
4
|
-
ResolvedAssets,
|
|
5
|
-
toResolvedAsset,
|
|
6
|
-
} from "@vite-pwa/assets-generator";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import {PathUtil} from "@simplysm/sd-core-node";
|
|
9
|
-
|
|
10
|
-
export abstract class SdCliPwaAssets {
|
|
11
|
-
public static async genAsync(opt: { pkgName: string, relFilePath: string }): Promise<void> {
|
|
12
|
-
const pkgSrcPath = PathUtil.posix(path.resolve(), "packages", opt.pkgName, "src");
|
|
13
|
-
|
|
14
|
-
const assets: ResolvedAssets = {
|
|
15
|
-
assets: {
|
|
16
|
-
transparent: toResolvedAsset('transparent', {
|
|
17
|
-
sizes: [64, 192, 512],
|
|
18
|
-
favicons: [[64, PathUtil.posix(pkgSrcPath, "favicon.ico")]]
|
|
19
|
-
}),
|
|
20
|
-
maskable: toResolvedAsset('maskable', {
|
|
21
|
-
sizes: [512]
|
|
22
|
-
}),
|
|
23
|
-
apple: toResolvedAsset('apple', {
|
|
24
|
-
sizes: [180]
|
|
25
|
-
}),
|
|
26
|
-
},
|
|
27
|
-
png: defaultPngCompressionOptions,
|
|
28
|
-
assetName: (type, size) => {
|
|
29
|
-
switch (type) {
|
|
30
|
-
case 'transparent':
|
|
31
|
-
return PathUtil.posix(pkgSrcPath, `public/icons/icon-${size.width}x${size.height}.png`);
|
|
32
|
-
case 'maskable':
|
|
33
|
-
return PathUtil.posix(pkgSrcPath, `assets/icons/maskable-icon-${size.width}x${size.height}.png`);
|
|
34
|
-
case 'apple':
|
|
35
|
-
return PathUtil.posix(pkgSrcPath, `assets/icons/apple-touch-icon-${size.width}x${size.height}.png`);
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
await generatePWAAssets(
|
|
41
|
-
[opt.relFilePath],
|
|
42
|
-
assets,
|
|
43
|
-
{
|
|
44
|
-
root: process.cwd(),
|
|
45
|
-
logLevel: "info",
|
|
46
|
-
overrideAssets: true
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import {build, defineConfig, PluginOption, UserConfig} 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
|
-
|
|
7
|
-
export const SdCliViteElectronMainPlugin = (opt: {
|
|
8
|
-
entry: string;
|
|
9
|
-
distPath: string;
|
|
10
|
-
cachePath: string;
|
|
11
|
-
}): PluginOption[] => {
|
|
12
|
-
const logger = Logger.get(["simplysm", "sd-cli", "SdCliViteElectronMainPlugin"]);
|
|
13
|
-
|
|
14
|
-
let mainConfig: UserConfig;
|
|
15
|
-
|
|
16
|
-
return [
|
|
17
|
-
{
|
|
18
|
-
name: "sd-cli:vite:electron-main",
|
|
19
|
-
apply: "serve",
|
|
20
|
-
configureServer: (server) => {
|
|
21
|
-
server.httpServer?.on("listening", async () => {
|
|
22
|
-
mainConfig = defineConfig({
|
|
23
|
-
mode: server.config.mode,
|
|
24
|
-
define: server.config.define,
|
|
25
|
-
root: server.config.root,
|
|
26
|
-
optimizeDeps: {
|
|
27
|
-
force: server.config.optimizeDeps?.force
|
|
28
|
-
},
|
|
29
|
-
build: {
|
|
30
|
-
sourcemap: true,
|
|
31
|
-
minify: false,
|
|
32
|
-
outDir: opt.distPath,
|
|
33
|
-
lib: {
|
|
34
|
-
entry: opt.entry,
|
|
35
|
-
formats: ["cjs"],
|
|
36
|
-
fileName: () => "[name].js"
|
|
37
|
-
},
|
|
38
|
-
emptyOutDir: false
|
|
39
|
-
},
|
|
40
|
-
plugins: [
|
|
41
|
-
SdCliViteLoggerPlugin({
|
|
42
|
-
logger,
|
|
43
|
-
name: path.basename(opt.entry)
|
|
44
|
-
}),
|
|
45
|
-
SdCliViteExternalPlugin({
|
|
46
|
-
target: "node",
|
|
47
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
48
|
-
includes: ["electron"]
|
|
49
|
-
}),
|
|
50
|
-
{
|
|
51
|
-
name: ":startup",
|
|
52
|
-
closeBundle: () => {
|
|
53
|
-
server.ws.send({type: "full-reload"});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
});
|
|
58
|
-
await build(mainConfig);
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "sd-cli:vite:electron-main",
|
|
64
|
-
apply: "build",
|
|
65
|
-
config: (config) => {
|
|
66
|
-
mainConfig = defineConfig({
|
|
67
|
-
mode: config.mode,
|
|
68
|
-
define: config.define,
|
|
69
|
-
root: config.root,
|
|
70
|
-
optimizeDeps: {
|
|
71
|
-
force: config.optimizeDeps?.force
|
|
72
|
-
},
|
|
73
|
-
build: {
|
|
74
|
-
sourcemap: false,
|
|
75
|
-
minify: true,
|
|
76
|
-
outDir: opt.distPath,
|
|
77
|
-
lib: {
|
|
78
|
-
entry: opt.entry,
|
|
79
|
-
formats: ["cjs"],
|
|
80
|
-
fileName: () => "[name].js"
|
|
81
|
-
},
|
|
82
|
-
emptyOutDir: false
|
|
83
|
-
},
|
|
84
|
-
plugins: [
|
|
85
|
-
SdCliViteLoggerPlugin({
|
|
86
|
-
logger,
|
|
87
|
-
name: path.basename(opt.entry)
|
|
88
|
-
}),
|
|
89
|
-
SdCliViteExternalPlugin({
|
|
90
|
-
target: "node",
|
|
91
|
-
cachePath: path.resolve(opt.cachePath, "externals"),
|
|
92
|
-
includes: ["electron"]
|
|
93
|
-
}),
|
|
94
|
-
]
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
closeBundle: async () => {
|
|
98
|
-
await build(mainConfig);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
|
-
};
|