@simplysm/sd-cli 12.5.21 → 12.5.23
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 → entry}/SdCliCordova.d.ts +5 -6
- package/dist/{build-tools → entry}/SdCliCordova.js +117 -99
- package/dist/entry/SdCliCordova.js.map +1 -0
- package/dist/entry/SdCliElectron.d.ts +2 -2
- package/dist/entry/SdCliElectron.js +50 -40
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliLocalUpdate.d.ts +1 -2
- package/dist/entry/SdCliLocalUpdate.js +26 -27
- package/dist/entry/SdCliLocalUpdate.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +1 -5
- package/dist/entry/SdCliProject.js +62 -288
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +23 -20
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/pkg-builders/SdMultiBuildRunner.d.ts +21 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js +174 -0
- package/dist/pkg-builders/SdMultiBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.js +7 -7
- package/dist/pkg-builders/client/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.d.ts +20 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js +135 -0
- package/dist/pkg-builders/client/SdClientBuildRunner.js.map +1 -0
- package/dist/pkg-builders/client/SdNgBundler.d.ts +29 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundler.js +107 -151
- package/dist/pkg-builders/client/SdNgBundler.js.map +1 -0
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.d.ts +1 -2
- package/dist/{build-tools → pkg-builders/client}/SdNgBundlerContext.js +19 -45
- package/dist/pkg-builders/client/SdNgBundlerContext.js.map +1 -0
- package/dist/pkg-builders/client/createSdNgPlugin.d.ts +10 -0
- package/dist/{bundle-plugins/sdNgPlugin.js → pkg-builders/client/createSdNgPlugin.js} +32 -33
- package/dist/pkg-builders/client/createSdNgPlugin.js.map +1 -0
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.d.ts +5 -0
- package/dist/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.js +11 -11
- package/dist/pkg-builders/lib/SdCliIndexFileGenerator.js.map +1 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.d.ts +16 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js +81 -0
- package/dist/pkg-builders/lib/SdJsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.d.ts +13 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js +89 -0
- package/dist/pkg-builders/lib/SdTsLibBuildRunner.js.map +1 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.d.ts +14 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js +54 -0
- package/dist/pkg-builders/lib/SdTsLibBuilder.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBuildRunner.d.ts +17 -0
- package/dist/{builders/SdCliServerBuilder.js → pkg-builders/server/SdServerBuildRunner.js} +48 -53
- package/dist/pkg-builders/server/SdServerBuildRunner.js.map +1 -0
- package/dist/pkg-builders/server/SdServerBundler.d.ts +19 -0
- package/dist/{build-tools → pkg-builders/server}/SdServerBundler.js +25 -30
- package/dist/pkg-builders/server/SdServerBundler.js.map +1 -0
- package/dist/pkg-builders/server/createSdServerPlugin.d.ts +10 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js +53 -0
- package/dist/pkg-builders/server/createSdServerPlugin.js.map +1 -0
- package/dist/sd-cli.js +61 -54
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-builder/SdTsCompileWorker.d.ts +9 -0
- package/dist/ts-builder/SdTsCompileWorker.js +16 -0
- package/dist/ts-builder/SdTsCompileWorker.js.map +1 -0
- package/dist/ts-builder/SdTsCompiler.d.ts +7 -0
- package/dist/ts-builder/SdTsCompiler.js +557 -0
- package/dist/ts-builder/SdTsCompiler.js.map +1 -0
- package/dist/types/build-plugin.type.d.ts +14 -0
- package/dist/types/build-plugin.type.js +2 -0
- package/dist/types/build-plugin.type.js.map +1 -0
- package/dist/types/build.type.d.ts +15 -0
- package/dist/types/build.type.js +2 -0
- package/dist/types/build.type.js.map +1 -0
- package/dist/types/common-configs.type.d.ts +22 -0
- package/dist/types/common-configs.type.js +2 -0
- package/dist/types/common-configs.type.js.map +1 -0
- package/dist/types/sd-configs.type.d.ts +99 -0
- package/dist/types/sd-configs.type.js +2 -0
- package/dist/types/sd-configs.type.js.map +1 -0
- package/dist/types/ts-compiler.type.d.ts +29 -0
- package/dist/types/ts-compiler.type.js +2 -0
- package/dist/types/ts-compiler.type.js.map +1 -0
- package/dist/types/workers.type.d.ts +49 -0
- package/dist/types/workers.type.js +2 -0
- package/dist/types/workers.type.js.map +1 -0
- package/dist/utils/SdCliConvertMessageUtil.d.ts +21 -0
- package/dist/utils/SdCliConvertMessageUtil.js +137 -0
- package/dist/utils/SdCliConvertMessageUtil.js.map +1 -0
- package/dist/workers/compile-worker.js +27 -0
- package/dist/workers/compile-worker.js.map +1 -0
- package/dist/workers/lint-worker.js +36 -0
- package/dist/workers/lint-worker.js.map +1 -0
- package/dist/workers/server-worker.d.ts +1 -0
- package/dist/workers/server-worker.js +49 -0
- package/dist/workers/server-worker.js.map +1 -0
- package/package.json +8 -11
- package/src/entry/SdCliCordova.ts +363 -0
- package/src/entry/SdCliElectron.ts +96 -69
- package/src/entry/SdCliLocalUpdate.ts +43 -44
- package/src/entry/SdCliProject.ts +72 -417
- package/src/index.ts +23 -20
- package/src/pkg-builders/SdMultiBuildRunner.ts +250 -0
- package/src/{build-tools → pkg-builders/client}/SdCliNgRoutesFileGenerator.ts +7 -7
- package/src/pkg-builders/client/SdClientBuildRunner.ts +191 -0
- package/src/{build-tools → pkg-builders/client}/SdNgBundler.ts +135 -190
- package/src/pkg-builders/client/SdNgBundlerContext.ts +111 -0
- package/src/{bundle-plugins/sdNgPlugin.ts → pkg-builders/client/createSdNgPlugin.ts} +43 -46
- package/src/{build-tools → pkg-builders/lib}/SdCliIndexFileGenerator.ts +11 -11
- package/src/pkg-builders/lib/SdJsLibBuildRunner.ts +105 -0
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +128 -0
- package/src/pkg-builders/lib/SdTsLibBuilder.ts +69 -0
- package/src/{builders/SdCliServerBuilder.ts → pkg-builders/server/SdServerBuildRunner.ts} +66 -78
- package/src/{build-tools → pkg-builders/server}/SdServerBundler.ts +40 -41
- package/src/pkg-builders/server/createSdServerPlugin.ts +77 -0
- package/src/sd-cli.ts +197 -211
- package/src/ts-builder/SdTsCompileWorker.ts +21 -0
- package/src/ts-builder/SdTsCompiler.ts +775 -0
- package/src/types/build-plugin.type.ts +16 -0
- package/src/types/build.type.ts +17 -0
- package/src/types/common-configs.type.ts +27 -0
- package/src/types/sd-configs.type.ts +114 -0
- package/src/types/ts-compiler.type.ts +29 -0
- package/src/types/workers.type.ts +27 -0
- package/src/utils/SdCliConvertMessageUtil.ts +177 -0
- package/src/workers/compile-worker.ts +31 -0
- package/src/workers/lint-worker.ts +44 -0
- package/src/workers/server-worker.ts +52 -0
- package/tsconfig.json +7 -1
- package/dist/build-cluster.js +0 -201
- package/dist/build-cluster.js.map +0 -1
- package/dist/build-tools/SdCliCordova.js.map +0 -1
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +0 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js.map +0 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +0 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +0 -1
- package/dist/build-tools/SdLinter.d.ts +0 -5
- package/dist/build-tools/SdLinter.js +0 -49
- package/dist/build-tools/SdLinter.js.map +0 -1
- package/dist/build-tools/SdNgBundler.d.ts +0 -29
- package/dist/build-tools/SdNgBundler.js.map +0 -1
- package/dist/build-tools/SdNgBundlerContext.js.map +0 -1
- package/dist/build-tools/SdReactBundler.d.ts +0 -25
- package/dist/build-tools/SdReactBundler.js +0 -295
- package/dist/build-tools/SdReactBundler.js.map +0 -1
- package/dist/build-tools/SdReactBundlerContext.d.ts +0 -14
- package/dist/build-tools/SdReactBundlerContext.js +0 -59
- package/dist/build-tools/SdReactBundlerContext.js.map +0 -1
- package/dist/build-tools/SdServerBundler.d.ts +0 -20
- package/dist/build-tools/SdServerBundler.js.map +0 -1
- package/dist/build-tools/SdTsCompiler.d.ts +0 -34
- package/dist/build-tools/SdTsCompiler.js +0 -534
- package/dist/build-tools/SdTsCompiler.js.map +0 -1
- package/dist/build-tools/SdTsLibBundler.d.ts +0 -13
- package/dist/build-tools/SdTsLibBundler.js +0 -58
- package/dist/build-tools/SdTsLibBundler.js.map +0 -1
- package/dist/builders/SdCliClientBuilder.d.ts +0 -18
- package/dist/builders/SdCliClientBuilder.js +0 -172
- package/dist/builders/SdCliClientBuilder.js.map +0 -1
- package/dist/builders/SdCliJsLibLinter.d.ts +0 -13
- package/dist/builders/SdCliJsLibLinter.js +0 -60
- package/dist/builders/SdCliJsLibLinter.js.map +0 -1
- package/dist/builders/SdCliServerBuilder.d.ts +0 -15
- package/dist/builders/SdCliServerBuilder.js.map +0 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +0 -12
- package/dist/builders/SdCliTsLibBuilder.js +0 -90
- package/dist/builders/SdCliTsLibBuilder.js.map +0 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdNgPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdReactPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdReactPlugin.js +0 -117
- package/dist/bundle-plugins/sdReactPlugin.js.map +0 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +0 -16
- package/dist/bundle-plugins/sdServerPlugin.js +0 -63
- package/dist/bundle-plugins/sdServerPlugin.js.map +0 -1
- package/dist/commons.d.ts +0 -145
- package/dist/commons.js +0 -2
- package/dist/commons.js.map +0 -1
- package/dist/server-worker.js +0 -57
- package/dist/server-worker.js.map +0 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +0 -16
- package/dist/utils/SdCliBuildResultUtil.js +0 -54
- package/dist/utils/SdCliBuildResultUtil.js.map +0 -1
- package/src/build-cluster.ts +0 -212
- package/src/build-tools/SdCliCordova.ts +0 -340
- package/src/build-tools/SdLinter.ts +0 -65
- package/src/build-tools/SdNgBundlerContext.ts +0 -137
- package/src/build-tools/SdReactBundler.ts +0 -372
- package/src/build-tools/SdReactBundlerContext.ts +0 -71
- package/src/build-tools/SdTsCompiler.ts +0 -754
- package/src/build-tools/SdTsLibBundler.ts +0 -72
- package/src/builders/SdCliClientBuilder.ts +0 -233
- package/src/builders/SdCliJsLibLinter.ts +0 -72
- package/src/builders/SdCliTsLibBuilder.ts +0 -126
- package/src/bundle-plugins/sdReactPlugin.ts +0 -164
- package/src/bundle-plugins/sdServerPlugin.ts +0 -94
- package/src/commons.ts +0 -171
- package/src/server-worker.ts +0 -65
- package/src/utils/SdCliBuildResultUtil.ts +0 -63
- /package/dist/{build-cluster.d.ts → workers/compile-worker.d.ts} +0 -0
- /package/dist/{server-worker.d.ts → workers/lint-worker.d.ts} +0 -0
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import esbuild, { Metafile } from "esbuild";
|
|
3
|
-
import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
|
|
3
|
+
import { FsUtil, Logger, PathUtil, TNormPath } from "@simplysm/sd-core-node";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import nodeStdLibBrowser from "node-stdlib-browser";
|
|
6
6
|
import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
|
|
7
|
-
import { INpmConfig, ISdCliClientBuilderCordovaConfig, ISdCliPackageBuildResult } from "../commons";
|
|
8
7
|
import browserslist from "browserslist";
|
|
9
8
|
import { SdNgBundlerContext } from "./SdNgBundlerContext";
|
|
10
|
-
import { INgPluginResultCache, sdNgPlugin } from "../bundle-plugins/sdNgPlugin";
|
|
11
|
-
import ts from "typescript";
|
|
12
9
|
import { MemoryLoadResultCache } from "@angular/build/src/tools/esbuild/load-result-cache";
|
|
13
10
|
import {
|
|
14
11
|
convertOutputFile,
|
|
@@ -21,14 +18,9 @@ import {
|
|
|
21
18
|
InitialFileRecord,
|
|
22
19
|
} from "@angular/build/src/tools/esbuild/bundler-context";
|
|
23
20
|
import { extractLicenses } from "@angular/build/src/tools/esbuild/license-extractor";
|
|
24
|
-
import {
|
|
25
|
-
HintMode,
|
|
26
|
-
IndexHtmlGenerator,
|
|
27
|
-
IndexHtmlProcessResult,
|
|
28
|
-
} from "@angular/build/src/utils/index-file/index-html-generator";
|
|
21
|
+
import { IndexHtmlGenerator, IndexHtmlProcessResult } from "@angular/build/src/utils/index-file/index-html-generator";
|
|
29
22
|
import { Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
|
|
30
23
|
import { CrossOrigin } from "@angular/build/src/builders/application/schema";
|
|
31
|
-
import { InlineCriticalCssProcessor } from "@angular/build/src/utils/index-file/inline-critical-css";
|
|
32
24
|
import { augmentAppWithServiceWorkerEsbuild } from "@angular/build/src/utils/service-worker";
|
|
33
25
|
import { createSourcemapIgnorelistPlugin } from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
34
26
|
import { StylesheetPluginFactory } from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
@@ -36,27 +28,26 @@ import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesh
|
|
|
36
28
|
import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
|
|
37
29
|
import { createCssResourcePlugin } from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
38
30
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
39
|
-
import {
|
|
31
|
+
import { createSdNgPlugin } from "./createSdNgPlugin";
|
|
32
|
+
import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTime";
|
|
33
|
+
import { INpmConfig } from "../../types/common-configs.type";
|
|
34
|
+
import { ISdClientBuilderCordovaConfig } from "../../types/sd-configs.type";
|
|
35
|
+
import { ISdCliNgPluginResultCache } from "../../types/build-plugin.type";
|
|
36
|
+
import { ISdBuildMessage } from "../../types/build.type";
|
|
40
37
|
|
|
41
38
|
export class SdNgBundler {
|
|
42
39
|
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler"]);
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
readonly #modifiedFileSet = new Set<string>();
|
|
49
|
-
readonly #ngResultCache: INgPluginResultCache = {
|
|
50
|
-
affectedFileSet: new Set<string>(),
|
|
51
|
-
watchFileSet: new Set<string>(),
|
|
41
|
+
readonly #modifiedFileSet = new Set<TNormPath>();
|
|
42
|
+
readonly #ngResultCache: ISdCliNgPluginResultCache = {
|
|
43
|
+
affectedFileSet: new Set<TNormPath>(),
|
|
44
|
+
watchFileSet: new Set<TNormPath>(),
|
|
52
45
|
};
|
|
53
46
|
readonly #styleLoadResultCache = new MemoryLoadResultCache();
|
|
54
47
|
|
|
55
48
|
#contexts: SdNgBundlerContext[] | undefined;
|
|
56
49
|
|
|
57
|
-
readonly #outputCache = new Map<
|
|
58
|
-
|
|
59
|
-
readonly #opt: IOptions;
|
|
50
|
+
readonly #outputCache = new Map<TNormPath, string | number>();
|
|
60
51
|
|
|
61
52
|
readonly #pkgNpmConf: INpmConfig;
|
|
62
53
|
readonly #mainFilePath: string;
|
|
@@ -67,34 +58,45 @@ export class SdNgBundler {
|
|
|
67
58
|
readonly #pkgName: string;
|
|
68
59
|
readonly #baseHref: string;
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
public constructor(
|
|
62
|
+
private _opt: {
|
|
63
|
+
dev: boolean;
|
|
64
|
+
outputPath: TNormPath;
|
|
65
|
+
pkgPath: TNormPath;
|
|
66
|
+
builderType: string;
|
|
67
|
+
env: Record<string, string> | undefined;
|
|
68
|
+
cordovaConfig: ISdClientBuilderCordovaConfig | undefined;
|
|
69
|
+
watchScopePaths: TNormPath[];
|
|
70
|
+
},
|
|
71
|
+
) {
|
|
72
|
+
this.#pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
|
|
73
|
+
this.#mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
|
|
74
|
+
this.#tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
|
|
75
|
+
this.#swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
|
|
78
76
|
this.#browserTarget = transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"]));
|
|
79
|
-
this.#indexHtmlFilePath = path.resolve(
|
|
80
|
-
this.#pkgName = path.basename(
|
|
77
|
+
this.#indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
|
|
78
|
+
this.#pkgName = path.basename(this._opt.pkgPath);
|
|
81
79
|
this.#baseHref =
|
|
82
|
-
|
|
80
|
+
this._opt.builderType === "web"
|
|
81
|
+
? `/${this.#pkgName}/`
|
|
82
|
+
: this._opt.dev
|
|
83
|
+
? `/${this.#pkgName}/${this._opt.builderType}/`
|
|
84
|
+
: ``;
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
public markForChanges(filePaths: string[]): void {
|
|
86
88
|
for (const filePath of filePaths) {
|
|
87
|
-
this.#modifiedFileSet.add(
|
|
88
|
-
this.#styleLoadResultCache.invalidate(
|
|
89
|
+
this.#modifiedFileSet.add(PathUtil.norm(filePath));
|
|
90
|
+
this.#styleLoadResultCache.invalidate(PathUtil.norm(filePath));
|
|
89
91
|
}
|
|
90
92
|
// this._sourceFileCache.invalidate(filePaths);
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
public async bundleAsync(): Promise<{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
watchFileSet: Set<TNormPath>;
|
|
97
|
+
affectedFileSet: Set<TNormPath>;
|
|
98
|
+
results: ISdBuildMessage[];
|
|
99
|
+
emitFileSet: Set<TNormPath>;
|
|
98
100
|
}> {
|
|
99
101
|
const perf = new SdCliPerformanceTimer("ng bundle");
|
|
100
102
|
|
|
@@ -104,14 +106,14 @@ export class SdNgBundler {
|
|
|
104
106
|
this.#contexts = perf.run("get contexts", () => [
|
|
105
107
|
this._getAppContext(),
|
|
106
108
|
this._getStyleContext(),
|
|
107
|
-
...(this
|
|
109
|
+
...(this._opt.builderType === "electron" ? [this._getElectronMainContext()] : []),
|
|
108
110
|
]);
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
this.#debug(`build...`);
|
|
112
114
|
|
|
113
115
|
const bundlingResults = await perf.run("build", async () => {
|
|
114
|
-
return await this.#contexts!.mapAsync(async (ctx
|
|
116
|
+
return await this.#contexts!.mapAsync(async (ctx) => await ctx.bundleAsync());
|
|
115
117
|
});
|
|
116
118
|
|
|
117
119
|
//-- results
|
|
@@ -138,13 +140,13 @@ export class SdNgBundler {
|
|
|
138
140
|
const assetFiles: { source: string; destination: string }[] = [];
|
|
139
141
|
|
|
140
142
|
//-- cordova empty
|
|
141
|
-
if (this
|
|
143
|
+
if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
142
144
|
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
this.#debug(`create index.html...`);
|
|
146
148
|
await perf.run("create index.html", async () => {
|
|
147
|
-
const genIndexHtmlResult = await this._genIndexHtmlAsync(
|
|
149
|
+
const genIndexHtmlResult = await this._genIndexHtmlAsync(initialFiles);
|
|
148
150
|
for (const warning of genIndexHtmlResult.warnings) {
|
|
149
151
|
results.push({
|
|
150
152
|
filePath: undefined,
|
|
@@ -152,8 +154,8 @@ export class SdNgBundler {
|
|
|
152
154
|
char: undefined,
|
|
153
155
|
code: undefined,
|
|
154
156
|
severity: "warning",
|
|
155
|
-
message:
|
|
156
|
-
type: "
|
|
157
|
+
message: `${warning}`,
|
|
158
|
+
type: "gen-index",
|
|
157
159
|
});
|
|
158
160
|
}
|
|
159
161
|
for (const error of genIndexHtmlResult.errors) {
|
|
@@ -163,8 +165,8 @@ export class SdNgBundler {
|
|
|
163
165
|
char: undefined,
|
|
164
166
|
code: undefined,
|
|
165
167
|
severity: "error",
|
|
166
|
-
message:
|
|
167
|
-
type: "
|
|
168
|
+
message: `${error}`,
|
|
169
|
+
type: "gen-index",
|
|
168
170
|
});
|
|
169
171
|
}
|
|
170
172
|
outputFiles.push(createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root));
|
|
@@ -175,11 +177,11 @@ export class SdNgBundler {
|
|
|
175
177
|
assetFiles.push(...(await this._copyAssetsAsync()));
|
|
176
178
|
|
|
177
179
|
//-- extract 3rdpartylicenses
|
|
178
|
-
if (!this
|
|
180
|
+
if (!this._opt.dev) {
|
|
179
181
|
outputFiles.push(
|
|
180
182
|
createOutputFile(
|
|
181
183
|
"3rdpartylicenses.txt",
|
|
182
|
-
await extractLicenses(metafile, this
|
|
184
|
+
await extractLicenses(metafile, this._opt.pkgPath),
|
|
183
185
|
BuildOutputFileType.Root,
|
|
184
186
|
),
|
|
185
187
|
);
|
|
@@ -202,8 +204,8 @@ export class SdNgBundler {
|
|
|
202
204
|
char: undefined,
|
|
203
205
|
code: undefined,
|
|
204
206
|
severity: "error",
|
|
205
|
-
message:
|
|
206
|
-
type: "
|
|
207
|
+
message: `${err.toString()}`,
|
|
208
|
+
type: "gen-sw",
|
|
207
209
|
});
|
|
208
210
|
}
|
|
209
211
|
});
|
|
@@ -212,21 +214,24 @@ export class SdNgBundler {
|
|
|
212
214
|
//-- write
|
|
213
215
|
this.#debug(`write output files...(${outputFiles.length})`);
|
|
214
216
|
|
|
215
|
-
|
|
217
|
+
const emitFileSet = new Set<TNormPath>();
|
|
218
|
+
perf.run("write output file", () => {
|
|
216
219
|
for (const outputFile of outputFiles) {
|
|
217
|
-
const distFilePath =
|
|
220
|
+
const distFilePath = PathUtil.norm(this._opt.outputPath, outputFile.path);
|
|
218
221
|
const prev = this.#outputCache.get(distFilePath);
|
|
219
222
|
if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
|
|
220
|
-
|
|
223
|
+
FsUtil.writeFile(distFilePath, outputFile.contents);
|
|
221
224
|
this.#outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
|
|
225
|
+
emitFileSet.add(PathUtil.norm(outputFile.path));
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
for (const assetFile of assetFiles) {
|
|
225
|
-
const prev = this.#outputCache.get(assetFile.source);
|
|
229
|
+
const prev = this.#outputCache.get(PathUtil.norm(assetFile.source));
|
|
226
230
|
const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
|
|
227
231
|
if (prev !== curr) {
|
|
228
|
-
|
|
229
|
-
this.#outputCache.set(assetFile.source, curr);
|
|
232
|
+
FsUtil.copy(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
|
|
233
|
+
this.#outputCache.set(PathUtil.norm(assetFile.source), curr);
|
|
234
|
+
emitFileSet.add(PathUtil.norm(assetFile.destination));
|
|
230
235
|
}
|
|
231
236
|
}
|
|
232
237
|
});
|
|
@@ -234,71 +239,41 @@ export class SdNgBundler {
|
|
|
234
239
|
this.#debug(perf.toString());
|
|
235
240
|
|
|
236
241
|
return {
|
|
237
|
-
program: this.#ngResultCache.program,
|
|
238
242
|
watchFileSet: new Set([
|
|
239
243
|
...this.#ngResultCache.watchFileSet!,
|
|
240
|
-
...this.#styleLoadResultCache.watchFiles,
|
|
241
|
-
this.#indexHtmlFilePath,
|
|
244
|
+
...this.#styleLoadResultCache.watchFiles.map((item) => PathUtil.norm(item)),
|
|
245
|
+
PathUtil.norm(this.#indexHtmlFilePath),
|
|
242
246
|
]),
|
|
243
247
|
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
244
248
|
results,
|
|
249
|
+
emitFileSet: emitFileSet,
|
|
245
250
|
};
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
private async _genIndexHtmlAsync(
|
|
249
|
-
outputFiles: esbuild.OutputFile[],
|
|
250
|
-
initialFiles: Map<string, InitialFileRecord>,
|
|
251
|
-
): Promise<IndexHtmlProcessResult> {
|
|
252
|
-
const readAsset = (filePath: string): Promise<string> => {
|
|
253
|
-
const relFilePath = path.relative("/", filePath);
|
|
254
|
-
const currFile = outputFiles.find((outputFile) => outputFile.path === relFilePath);
|
|
255
|
-
if (currFile) {
|
|
256
|
-
return Promise.resolve(currFile.text);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
throw new Error(`Output file does not exist: ${relFilePath}`);
|
|
260
|
-
};
|
|
261
|
-
|
|
253
|
+
private async _genIndexHtmlAsync(initialFiles: Map<string, InitialFileRecord>): Promise<IndexHtmlProcessResult> {
|
|
262
254
|
const indexHtmlGenerator = new IndexHtmlGenerator({
|
|
263
255
|
indexPath: this.#indexHtmlFilePath,
|
|
264
256
|
entrypoints: [
|
|
265
|
-
["runtime", true],
|
|
266
257
|
["polyfills", true],
|
|
267
258
|
["styles", false],
|
|
268
|
-
["vendor", true],
|
|
269
259
|
["main", true],
|
|
270
|
-
...(this
|
|
260
|
+
...(this._opt.builderType === "cordova" ? [["cordova-entry", true] as Entrypoint] : []),
|
|
271
261
|
],
|
|
262
|
+
sri: false,
|
|
272
263
|
optimization: {
|
|
273
|
-
scripts: !this
|
|
274
|
-
fonts: { inline: !this.#opt.dev },
|
|
264
|
+
scripts: !this._opt.dev,
|
|
275
265
|
styles: {
|
|
276
|
-
minify: !this
|
|
277
|
-
inlineCritical:
|
|
266
|
+
minify: !this._opt.dev,
|
|
267
|
+
inlineCritical: !this._opt.dev,
|
|
268
|
+
removeSpecialComments: !this._opt.dev,
|
|
278
269
|
},
|
|
270
|
+
fonts: { inline: !this._opt.dev },
|
|
279
271
|
},
|
|
280
272
|
crossOrigin: CrossOrigin.None,
|
|
273
|
+
generateDedicatedSSRContent: false,
|
|
281
274
|
});
|
|
282
|
-
indexHtmlGenerator.readAsset = readAsset;
|
|
283
|
-
|
|
284
|
-
const hints: { url: string; mode: HintMode; as?: string }[] = [];
|
|
285
|
-
if (!this.#opt.dev) {
|
|
286
|
-
for (const [key, value] of initialFiles) {
|
|
287
|
-
if (value.entrypoint) {
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (value.type === "script") {
|
|
292
|
-
hints.push({ url: key, mode: "modulepreload" as const });
|
|
293
|
-
}
|
|
294
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
295
|
-
else if (value.type === "style") {
|
|
296
|
-
hints.push({ url: key, mode: "preload" as const, as: "style" });
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
275
|
|
|
301
|
-
|
|
276
|
+
return await indexHtmlGenerator.process({
|
|
302
277
|
baseHref: this.#baseHref,
|
|
303
278
|
lang: undefined,
|
|
304
279
|
outputPath: "/",
|
|
@@ -307,29 +282,9 @@ export class SdNgBundler {
|
|
|
307
282
|
file,
|
|
308
283
|
extension: path.extname(file),
|
|
309
284
|
})),
|
|
310
|
-
hints,
|
|
311
285
|
});
|
|
312
|
-
|
|
313
|
-
if (this.#opt.dev) {
|
|
314
|
-
return transformResult;
|
|
315
|
-
} else {
|
|
316
|
-
const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
|
|
317
|
-
minify: false,
|
|
318
|
-
readAsset,
|
|
319
|
-
});
|
|
320
|
-
const { content, errors, warnings } = await inlineCriticalCssProcessor.process(transformResult.csrContent, {
|
|
321
|
-
outputPath: "/",
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
return {
|
|
325
|
-
warnings: [...transformResult.warnings, ...warnings],
|
|
326
|
-
errors: [...transformResult.errors, ...errors],
|
|
327
|
-
csrContent: content,
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
286
|
}
|
|
331
287
|
|
|
332
|
-
//TODO: index.html 파일에 manifest.json 정보 추가? manifest.webmanifest ? PWA?
|
|
333
288
|
private async _copyAssetsAsync(): Promise<
|
|
334
289
|
{
|
|
335
290
|
source: string;
|
|
@@ -338,13 +293,10 @@ export class SdNgBundler {
|
|
|
338
293
|
> {
|
|
339
294
|
return await resolveAssets(
|
|
340
295
|
[
|
|
341
|
-
{ input: "
|
|
342
|
-
{ input: "
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
...(this.#opt.dev ? [{ input: "src/assets-dev", glob: "**/*", output: "assets-dev" }] : []),
|
|
346
|
-
...(this.#opt.dev && this.#opt.builderType === "cordova"
|
|
347
|
-
? Object.keys(this.#opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
|
|
296
|
+
{ input: "public", glob: "**/*", output: "." },
|
|
297
|
+
...(this._opt.dev ? [{ input: "public-dev", glob: "**/*", output: "." }] : []),
|
|
298
|
+
...(this._opt.dev && this._opt.builderType === "cordova"
|
|
299
|
+
? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
|
|
348
300
|
{
|
|
349
301
|
input: `.cordova/platforms/${platform}/platform_www/plugins`,
|
|
350
302
|
glob: "**/*",
|
|
@@ -368,7 +320,7 @@ export class SdNgBundler {
|
|
|
368
320
|
])
|
|
369
321
|
: []),
|
|
370
322
|
],
|
|
371
|
-
this
|
|
323
|
+
this._opt.pkgPath,
|
|
372
324
|
);
|
|
373
325
|
}
|
|
374
326
|
|
|
@@ -386,7 +338,7 @@ export class SdNgBundler {
|
|
|
386
338
|
}[];
|
|
387
339
|
}> {
|
|
388
340
|
return await augmentAppWithServiceWorkerEsbuild(
|
|
389
|
-
this
|
|
341
|
+
this._opt.pkgPath,
|
|
390
342
|
this.#swConfFilePath,
|
|
391
343
|
this.#baseHref,
|
|
392
344
|
"index.html",
|
|
@@ -396,12 +348,12 @@ export class SdNgBundler {
|
|
|
396
348
|
}
|
|
397
349
|
|
|
398
350
|
private _getAppContext() {
|
|
399
|
-
const workerEntries = FsUtil.glob(path.resolve(this
|
|
351
|
+
const workerEntries = FsUtil.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")).toObject(
|
|
400
352
|
(p) => "worker/" + path.basename(p, path.extname(p)),
|
|
401
353
|
);
|
|
402
354
|
|
|
403
|
-
return new SdNgBundlerContext(this
|
|
404
|
-
absWorkingDir: this
|
|
355
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
356
|
+
absWorkingDir: this._opt.pkgPath,
|
|
405
357
|
bundle: true,
|
|
406
358
|
keepNames: true,
|
|
407
359
|
format: "esm",
|
|
@@ -409,32 +361,32 @@ export class SdNgBundler {
|
|
|
409
361
|
conditions: ["es2020", "es2015", "module"],
|
|
410
362
|
resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
|
|
411
363
|
metafile: true,
|
|
412
|
-
legalComments: this
|
|
364
|
+
legalComments: this._opt.dev ? "eof" : "none",
|
|
413
365
|
logLevel: "silent",
|
|
414
|
-
minifyIdentifiers: !this
|
|
415
|
-
minifySyntax: !this
|
|
416
|
-
minifyWhitespace: !this
|
|
366
|
+
minifyIdentifiers: !this._opt.dev,
|
|
367
|
+
minifySyntax: !this._opt.dev,
|
|
368
|
+
minifyWhitespace: !this._opt.dev,
|
|
417
369
|
pure: ["forwardRef"],
|
|
418
|
-
outdir: this
|
|
370
|
+
outdir: this._opt.pkgPath,
|
|
419
371
|
outExtension: undefined,
|
|
420
|
-
sourcemap: true, //this
|
|
372
|
+
sourcemap: true, //this._opt.dev,
|
|
421
373
|
splitting: true,
|
|
422
374
|
chunkNames: "[name]-[hash]",
|
|
423
375
|
tsconfig: this.#tsConfigFilePath,
|
|
424
376
|
write: false,
|
|
425
377
|
preserveSymlinks: false,
|
|
426
378
|
define: {
|
|
427
|
-
...(!this
|
|
379
|
+
...(!this._opt.dev ? { ngDevMode: "false" } : {}),
|
|
428
380
|
"ngJitMode": "false",
|
|
429
381
|
"global": "global",
|
|
430
382
|
"process": "process",
|
|
431
383
|
"Buffer": "Buffer",
|
|
432
384
|
"process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
|
|
433
|
-
"process.env.NODE_ENV": JSON.stringify(this
|
|
434
|
-
...(this
|
|
435
|
-
? Object.keys(this
|
|
385
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
386
|
+
...(this._opt.env
|
|
387
|
+
? Object.keys(this._opt.env).toObject(
|
|
436
388
|
(key) => `process.env.${key}`,
|
|
437
|
-
(key) => JSON.stringify(this
|
|
389
|
+
(key) => JSON.stringify(this._opt.env![key]),
|
|
438
390
|
)
|
|
439
391
|
: {}),
|
|
440
392
|
},
|
|
@@ -444,10 +396,13 @@ export class SdNgBundler {
|
|
|
444
396
|
entryPoints: {
|
|
445
397
|
main: this.#mainFilePath,
|
|
446
398
|
// polyfills: 'angular:polyfills',
|
|
447
|
-
polyfills: path.resolve(this
|
|
448
|
-
...(this
|
|
399
|
+
polyfills: path.resolve(this._opt.pkgPath, "src/polyfills.ts"),
|
|
400
|
+
...(this._opt.builderType === "cordova"
|
|
449
401
|
? {
|
|
450
|
-
"cordova-entry": path.resolve(
|
|
402
|
+
"cordova-entry": path.resolve(
|
|
403
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
404
|
+
`../../../lib/cordova-entry.js`,
|
|
405
|
+
),
|
|
451
406
|
}
|
|
452
407
|
: {}),
|
|
453
408
|
...workerEntries,
|
|
@@ -484,12 +439,12 @@ export class SdNgBundler {
|
|
|
484
439
|
},
|
|
485
440
|
inject: [PathUtil.posix(fileURLToPath(import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim")))],
|
|
486
441
|
plugins: [
|
|
487
|
-
...(this
|
|
442
|
+
...(this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins
|
|
488
443
|
? [
|
|
489
444
|
{
|
|
490
445
|
name: "cordova:plugin-empty",
|
|
491
446
|
setup: ({ onResolve }) => {
|
|
492
|
-
onResolve({ filter: new RegExp("(" + this
|
|
447
|
+
onResolve({ filter: new RegExp("(" + this._opt.cordovaConfig!.plugins!.join("|") + ")") }, () => {
|
|
493
448
|
return {
|
|
494
449
|
path: `./cordova-empty.js`,
|
|
495
450
|
external: true,
|
|
@@ -504,19 +459,19 @@ export class SdNgBundler {
|
|
|
504
459
|
// loadContent: () => ({
|
|
505
460
|
// contents: `import "./src/polyfills.ts";`,
|
|
506
461
|
// loader: 'js',
|
|
507
|
-
// resolveDir: this
|
|
462
|
+
// resolveDir: this._opt.pkgPath
|
|
508
463
|
// })
|
|
509
464
|
// }) as esbuild.Plugin,
|
|
510
465
|
createSourcemapIgnorelistPlugin(),
|
|
511
|
-
|
|
466
|
+
createSdNgPlugin({
|
|
512
467
|
modifiedFileSet: this.#modifiedFileSet,
|
|
513
|
-
dev: this
|
|
514
|
-
pkgPath: this
|
|
468
|
+
dev: this._opt.dev,
|
|
469
|
+
pkgPath: this._opt.pkgPath,
|
|
515
470
|
result: this.#ngResultCache,
|
|
516
|
-
watchScopePaths: this
|
|
471
|
+
watchScopePaths: this._opt.watchScopePaths,
|
|
517
472
|
}),
|
|
518
473
|
// createCompilerPlugin({
|
|
519
|
-
// sourcemap: this
|
|
474
|
+
// sourcemap: this._opt.dev,
|
|
520
475
|
// tsconfig: this._tsConfigFilePath,
|
|
521
476
|
// jit: false,
|
|
522
477
|
// advancedOptimizations: true,
|
|
@@ -524,11 +479,11 @@ export class SdNgBundler {
|
|
|
524
479
|
// fileReplacements: undefined,
|
|
525
480
|
// sourceFileCache: this._sourceFileCache,
|
|
526
481
|
// loadResultCache: this._sourceFileCache.loadResultCache,
|
|
527
|
-
// incremental: this
|
|
482
|
+
// incremental: this._opt.dev
|
|
528
483
|
// }, {
|
|
529
|
-
// workspaceRoot: this
|
|
530
|
-
// optimization: !this
|
|
531
|
-
// sourcemap: this
|
|
484
|
+
// workspaceRoot: this._opt.pkgPath,
|
|
485
|
+
// optimization: !this._opt.dev,
|
|
486
|
+
// sourcemap: this._opt.dev ? 'inline' : false,
|
|
532
487
|
// outputNames: {bundles: '[name]', media: 'media/[name]'},
|
|
533
488
|
// includePaths: [],
|
|
534
489
|
// externalDependencies: [],
|
|
@@ -554,22 +509,22 @@ export class SdNgBundler {
|
|
|
554
509
|
private _getStyleContext(): SdNgBundlerContext {
|
|
555
510
|
const pluginFactory = new StylesheetPluginFactory(
|
|
556
511
|
{
|
|
557
|
-
sourcemap: true, //this
|
|
512
|
+
sourcemap: true, //this._opt.dev,
|
|
558
513
|
includePaths: [],
|
|
559
514
|
},
|
|
560
515
|
this.#styleLoadResultCache,
|
|
561
516
|
);
|
|
562
517
|
|
|
563
|
-
return new SdNgBundlerContext(this
|
|
564
|
-
absWorkingDir: this
|
|
518
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
519
|
+
absWorkingDir: this._opt.pkgPath,
|
|
565
520
|
bundle: true,
|
|
566
521
|
entryNames: "[name]",
|
|
567
522
|
assetNames: "media/[name]",
|
|
568
523
|
logLevel: "silent",
|
|
569
|
-
minify: !this
|
|
524
|
+
minify: !this._opt.dev,
|
|
570
525
|
metafile: true,
|
|
571
|
-
sourcemap: true, //this
|
|
572
|
-
outdir: this
|
|
526
|
+
sourcemap: true, //this._opt.dev,
|
|
527
|
+
outdir: this._opt.pkgPath,
|
|
573
528
|
write: false,
|
|
574
529
|
platform: "browser",
|
|
575
530
|
target: this.#browserTarget,
|
|
@@ -577,10 +532,10 @@ export class SdNgBundler {
|
|
|
577
532
|
external: [],
|
|
578
533
|
conditions: ["style", "sass"],
|
|
579
534
|
mainFields: ["style", "sass"],
|
|
580
|
-
legalComments: !this
|
|
535
|
+
legalComments: !this._opt.dev ? "none" : "eof",
|
|
581
536
|
entryPoints: {
|
|
582
537
|
// styles: 'angular:styles/global;styles'
|
|
583
|
-
styles: path.resolve(this
|
|
538
|
+
styles: path.resolve(this._opt.pkgPath, "src/styles.scss"),
|
|
584
539
|
},
|
|
585
540
|
plugins: [
|
|
586
541
|
// createVirtualModulePlugin({
|
|
@@ -589,7 +544,7 @@ export class SdNgBundler {
|
|
|
589
544
|
// loadContent: () => ({
|
|
590
545
|
// contents: `@import 'src/styles.scss';`,
|
|
591
546
|
// loader: 'css',
|
|
592
|
-
// resolveDir: this
|
|
547
|
+
// resolveDir: this._opt.pkgPath
|
|
593
548
|
// }),
|
|
594
549
|
// }) as esbuild.Plugin,
|
|
595
550
|
pluginFactory.create(SassStylesheetLanguage) as esbuild.Plugin,
|
|
@@ -600,52 +555,42 @@ export class SdNgBundler {
|
|
|
600
555
|
}
|
|
601
556
|
|
|
602
557
|
private _getElectronMainContext() {
|
|
603
|
-
return new SdNgBundlerContext(this
|
|
604
|
-
absWorkingDir: this
|
|
558
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
559
|
+
absWorkingDir: this._opt.pkgPath,
|
|
605
560
|
bundle: true,
|
|
606
561
|
entryNames: "[name]",
|
|
607
562
|
assetNames: "media/[name]",
|
|
608
563
|
conditions: ["es2020", "es2015", "module"],
|
|
609
564
|
resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
|
|
610
565
|
metafile: true,
|
|
611
|
-
legalComments: this
|
|
566
|
+
legalComments: this._opt.dev ? "eof" : "none",
|
|
612
567
|
logLevel: "silent",
|
|
613
|
-
minify: !this
|
|
614
|
-
outdir: this
|
|
615
|
-
sourcemap: true, //this
|
|
568
|
+
minify: !this._opt.dev,
|
|
569
|
+
outdir: this._opt.pkgPath,
|
|
570
|
+
sourcemap: true, //this._opt.dev,
|
|
616
571
|
tsconfig: this.#tsConfigFilePath,
|
|
617
572
|
write: false,
|
|
618
573
|
preserveSymlinks: false,
|
|
619
574
|
external: ["electron"],
|
|
620
575
|
define: {
|
|
621
|
-
...(!this
|
|
576
|
+
...(!this._opt.dev ? { ngDevMode: "false" } : {}),
|
|
622
577
|
"process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
|
|
623
|
-
"process.env.NODE_ENV": JSON.stringify(this
|
|
624
|
-
...(this
|
|
625
|
-
? Object.keys(this
|
|
578
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
579
|
+
...(this._opt.env
|
|
580
|
+
? Object.keys(this._opt.env).toObject(
|
|
626
581
|
(key) => `process.env.${key}`,
|
|
627
|
-
(key) => JSON.stringify(this
|
|
582
|
+
(key) => JSON.stringify(this._opt.env![key]),
|
|
628
583
|
)
|
|
629
584
|
: {}),
|
|
630
585
|
},
|
|
631
586
|
platform: "node",
|
|
632
587
|
entryPoints: {
|
|
633
|
-
"electron-main": path.resolve(this
|
|
588
|
+
"electron-main": path.resolve(this._opt.pkgPath, "src/electron-main.ts"),
|
|
634
589
|
},
|
|
635
590
|
});
|
|
636
591
|
}
|
|
637
592
|
|
|
638
593
|
#debug(...msg: any[]): void {
|
|
639
|
-
this.#logger.debug(`[${path.basename(this
|
|
594
|
+
this.#logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
|
|
640
595
|
}
|
|
641
596
|
}
|
|
642
|
-
|
|
643
|
-
interface IOptions {
|
|
644
|
-
dev: boolean;
|
|
645
|
-
outputPath: string;
|
|
646
|
-
pkgPath: string;
|
|
647
|
-
builderType: string;
|
|
648
|
-
env: Record<string, string> | undefined;
|
|
649
|
-
cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
|
|
650
|
-
watchScopePaths: string[];
|
|
651
|
-
}
|