@simplysm/sd-cli 12.5.21 → 12.5.22
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 +100 -95
- 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/{build-tools → ts-builder}/SdTsCompiler.js +226 -212
- 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/lib/dev-worker.cjs +5 -0
- package/package.json +7 -10
- 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 +125 -121
- 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 +758 -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.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,
|
|
@@ -36,27 +33,30 @@ import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesh
|
|
|
36
33
|
import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
|
|
37
34
|
import { createCssResourcePlugin } from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
38
35
|
import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
|
|
39
|
-
import {
|
|
36
|
+
import { createSdNgPlugin } from "./createSdNgPlugin";
|
|
37
|
+
import { SdCliPerformanceTimer } from "../../utils/SdCliPerformanceTime";
|
|
38
|
+
import { INpmConfig } from "../../types/common-configs.type";
|
|
39
|
+
import { ISdClientBuilderCordovaConfig } from "../../types/sd-configs.type";
|
|
40
|
+
import { ISdCliNgPluginResultCache } from "../../types/build-plugin.type";
|
|
41
|
+
import { ISdBuildMessage } from "../../types/build.type";
|
|
40
42
|
|
|
41
43
|
export class SdNgBundler {
|
|
42
44
|
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler"]);
|
|
43
45
|
|
|
44
46
|
// private readonly _sourceFileCache = new SourceFileCache(
|
|
45
|
-
// path.resolve(this
|
|
47
|
+
// path.resolve(this._opt.pkgPath, ".cache")
|
|
46
48
|
// );
|
|
47
49
|
|
|
48
|
-
readonly #modifiedFileSet = new Set<
|
|
49
|
-
readonly #ngResultCache:
|
|
50
|
-
affectedFileSet: new Set<
|
|
51
|
-
watchFileSet: new Set<
|
|
50
|
+
readonly #modifiedFileSet = new Set<TNormPath>();
|
|
51
|
+
readonly #ngResultCache: ISdCliNgPluginResultCache = {
|
|
52
|
+
affectedFileSet: new Set<TNormPath>(),
|
|
53
|
+
watchFileSet: new Set<TNormPath>(),
|
|
52
54
|
};
|
|
53
55
|
readonly #styleLoadResultCache = new MemoryLoadResultCache();
|
|
54
56
|
|
|
55
57
|
#contexts: SdNgBundlerContext[] | undefined;
|
|
56
58
|
|
|
57
|
-
readonly #outputCache = new Map<
|
|
58
|
-
|
|
59
|
-
readonly #opt: IOptions;
|
|
59
|
+
readonly #outputCache = new Map<TNormPath, string | number>();
|
|
60
60
|
|
|
61
61
|
readonly #pkgNpmConf: INpmConfig;
|
|
62
62
|
readonly #mainFilePath: string;
|
|
@@ -67,34 +67,45 @@ export class SdNgBundler {
|
|
|
67
67
|
readonly #pkgName: string;
|
|
68
68
|
readonly #baseHref: string;
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
public constructor(
|
|
71
|
+
private _opt: {
|
|
72
|
+
dev: boolean;
|
|
73
|
+
outputPath: TNormPath;
|
|
74
|
+
pkgPath: TNormPath;
|
|
75
|
+
builderType: string;
|
|
76
|
+
env: Record<string, string> | undefined;
|
|
77
|
+
cordovaConfig: ISdClientBuilderCordovaConfig | undefined;
|
|
78
|
+
watchScopePaths: TNormPath[];
|
|
79
|
+
},
|
|
80
|
+
) {
|
|
81
|
+
this.#pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
|
|
82
|
+
this.#mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
|
|
83
|
+
this.#tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
|
|
84
|
+
this.#swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
|
|
78
85
|
this.#browserTarget = transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"]));
|
|
79
|
-
this.#indexHtmlFilePath = path.resolve(
|
|
80
|
-
this.#pkgName = path.basename(
|
|
86
|
+
this.#indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
|
|
87
|
+
this.#pkgName = path.basename(this._opt.pkgPath);
|
|
81
88
|
this.#baseHref =
|
|
82
|
-
|
|
89
|
+
this._opt.builderType === "web"
|
|
90
|
+
? `/${this.#pkgName}/`
|
|
91
|
+
: this._opt.dev
|
|
92
|
+
? `/${this.#pkgName}/${this._opt.builderType}/`
|
|
93
|
+
: ``;
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
public markForChanges(filePaths: string[]): void {
|
|
86
97
|
for (const filePath of filePaths) {
|
|
87
|
-
this.#modifiedFileSet.add(
|
|
88
|
-
this.#styleLoadResultCache.invalidate(
|
|
98
|
+
this.#modifiedFileSet.add(PathUtil.norm(filePath));
|
|
99
|
+
this.#styleLoadResultCache.invalidate(PathUtil.norm(filePath));
|
|
89
100
|
}
|
|
90
101
|
// this._sourceFileCache.invalidate(filePaths);
|
|
91
102
|
}
|
|
92
103
|
|
|
93
104
|
public async bundleAsync(): Promise<{
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
watchFileSet: Set<TNormPath>;
|
|
106
|
+
affectedFileSet: Set<TNormPath>;
|
|
107
|
+
results: ISdBuildMessage[];
|
|
108
|
+
emitFileSet: Set<TNormPath>;
|
|
98
109
|
}> {
|
|
99
110
|
const perf = new SdCliPerformanceTimer("ng bundle");
|
|
100
111
|
|
|
@@ -104,14 +115,14 @@ export class SdNgBundler {
|
|
|
104
115
|
this.#contexts = perf.run("get contexts", () => [
|
|
105
116
|
this._getAppContext(),
|
|
106
117
|
this._getStyleContext(),
|
|
107
|
-
...(this
|
|
118
|
+
...(this._opt.builderType === "electron" ? [this._getElectronMainContext()] : []),
|
|
108
119
|
]);
|
|
109
120
|
}
|
|
110
121
|
|
|
111
122
|
this.#debug(`build...`);
|
|
112
123
|
|
|
113
124
|
const bundlingResults = await perf.run("build", async () => {
|
|
114
|
-
return await this.#contexts!.mapAsync(async (ctx
|
|
125
|
+
return await this.#contexts!.mapAsync(async (ctx) => await ctx.bundleAsync());
|
|
115
126
|
});
|
|
116
127
|
|
|
117
128
|
//-- results
|
|
@@ -138,7 +149,7 @@ export class SdNgBundler {
|
|
|
138
149
|
const assetFiles: { source: string; destination: string }[] = [];
|
|
139
150
|
|
|
140
151
|
//-- cordova empty
|
|
141
|
-
if (this
|
|
152
|
+
if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
|
|
142
153
|
outputFiles.push(createOutputFile("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
143
154
|
}
|
|
144
155
|
|
|
@@ -152,8 +163,8 @@ export class SdNgBundler {
|
|
|
152
163
|
char: undefined,
|
|
153
164
|
code: undefined,
|
|
154
165
|
severity: "warning",
|
|
155
|
-
message:
|
|
156
|
-
type: "
|
|
166
|
+
message: `${warning}`,
|
|
167
|
+
type: "gen-index",
|
|
157
168
|
});
|
|
158
169
|
}
|
|
159
170
|
for (const error of genIndexHtmlResult.errors) {
|
|
@@ -163,8 +174,8 @@ export class SdNgBundler {
|
|
|
163
174
|
char: undefined,
|
|
164
175
|
code: undefined,
|
|
165
176
|
severity: "error",
|
|
166
|
-
message:
|
|
167
|
-
type: "
|
|
177
|
+
message: `${error}`,
|
|
178
|
+
type: "gen-index",
|
|
168
179
|
});
|
|
169
180
|
}
|
|
170
181
|
outputFiles.push(createOutputFile("index.html", genIndexHtmlResult.csrContent, BuildOutputFileType.Root));
|
|
@@ -175,11 +186,11 @@ export class SdNgBundler {
|
|
|
175
186
|
assetFiles.push(...(await this._copyAssetsAsync()));
|
|
176
187
|
|
|
177
188
|
//-- extract 3rdpartylicenses
|
|
178
|
-
if (!this
|
|
189
|
+
if (!this._opt.dev) {
|
|
179
190
|
outputFiles.push(
|
|
180
191
|
createOutputFile(
|
|
181
192
|
"3rdpartylicenses.txt",
|
|
182
|
-
await extractLicenses(metafile, this
|
|
193
|
+
await extractLicenses(metafile, this._opt.pkgPath),
|
|
183
194
|
BuildOutputFileType.Root,
|
|
184
195
|
),
|
|
185
196
|
);
|
|
@@ -202,8 +213,8 @@ export class SdNgBundler {
|
|
|
202
213
|
char: undefined,
|
|
203
214
|
code: undefined,
|
|
204
215
|
severity: "error",
|
|
205
|
-
message:
|
|
206
|
-
type: "
|
|
216
|
+
message: `${err.toString()}`,
|
|
217
|
+
type: "gen-sw",
|
|
207
218
|
});
|
|
208
219
|
}
|
|
209
220
|
});
|
|
@@ -212,21 +223,24 @@ export class SdNgBundler {
|
|
|
212
223
|
//-- write
|
|
213
224
|
this.#debug(`write output files...(${outputFiles.length})`);
|
|
214
225
|
|
|
215
|
-
|
|
226
|
+
const emitFileSet = new Set<TNormPath>();
|
|
227
|
+
perf.run("write output file", () => {
|
|
216
228
|
for (const outputFile of outputFiles) {
|
|
217
|
-
const distFilePath =
|
|
229
|
+
const distFilePath = PathUtil.norm(this._opt.outputPath, outputFile.path);
|
|
218
230
|
const prev = this.#outputCache.get(distFilePath);
|
|
219
231
|
if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
|
|
220
|
-
|
|
232
|
+
FsUtil.writeFile(distFilePath, outputFile.contents);
|
|
221
233
|
this.#outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
|
|
234
|
+
emitFileSet.add(PathUtil.norm(outputFile.path));
|
|
222
235
|
}
|
|
223
236
|
}
|
|
224
237
|
for (const assetFile of assetFiles) {
|
|
225
|
-
const prev = this.#outputCache.get(assetFile.source);
|
|
238
|
+
const prev = this.#outputCache.get(PathUtil.norm(assetFile.source));
|
|
226
239
|
const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
|
|
227
240
|
if (prev !== curr) {
|
|
228
|
-
|
|
229
|
-
this.#outputCache.set(assetFile.source, curr);
|
|
241
|
+
FsUtil.copy(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
|
|
242
|
+
this.#outputCache.set(PathUtil.norm(assetFile.source), curr);
|
|
243
|
+
emitFileSet.add(PathUtil.norm(assetFile.destination));
|
|
230
244
|
}
|
|
231
245
|
}
|
|
232
246
|
});
|
|
@@ -234,14 +248,14 @@ export class SdNgBundler {
|
|
|
234
248
|
this.#debug(perf.toString());
|
|
235
249
|
|
|
236
250
|
return {
|
|
237
|
-
program: this.#ngResultCache.program,
|
|
238
251
|
watchFileSet: new Set([
|
|
239
252
|
...this.#ngResultCache.watchFileSet!,
|
|
240
|
-
...this.#styleLoadResultCache.watchFiles,
|
|
241
|
-
this.#indexHtmlFilePath,
|
|
253
|
+
...this.#styleLoadResultCache.watchFiles.map((item) => PathUtil.norm(item)),
|
|
254
|
+
PathUtil.norm(this.#indexHtmlFilePath),
|
|
242
255
|
]),
|
|
243
256
|
affectedFileSet: this.#ngResultCache.affectedFileSet!,
|
|
244
257
|
results,
|
|
258
|
+
emitFileSet: emitFileSet,
|
|
245
259
|
};
|
|
246
260
|
}
|
|
247
261
|
|
|
@@ -267,13 +281,13 @@ export class SdNgBundler {
|
|
|
267
281
|
["styles", false],
|
|
268
282
|
["vendor", true],
|
|
269
283
|
["main", true],
|
|
270
|
-
...(this
|
|
284
|
+
...(this._opt.builderType === "cordova" ? [["cordova-entry", true] as Entrypoint] : []),
|
|
271
285
|
],
|
|
272
286
|
optimization: {
|
|
273
|
-
scripts: !this
|
|
274
|
-
fonts: { inline: !this
|
|
287
|
+
scripts: !this._opt.dev,
|
|
288
|
+
fonts: { inline: !this._opt.dev },
|
|
275
289
|
styles: {
|
|
276
|
-
minify: !this
|
|
290
|
+
minify: !this._opt.dev,
|
|
277
291
|
inlineCritical: false,
|
|
278
292
|
},
|
|
279
293
|
},
|
|
@@ -282,7 +296,7 @@ export class SdNgBundler {
|
|
|
282
296
|
indexHtmlGenerator.readAsset = readAsset;
|
|
283
297
|
|
|
284
298
|
const hints: { url: string; mode: HintMode; as?: string }[] = [];
|
|
285
|
-
if (!this
|
|
299
|
+
if (!this._opt.dev) {
|
|
286
300
|
for (const [key, value] of initialFiles) {
|
|
287
301
|
if (value.entrypoint) {
|
|
288
302
|
continue;
|
|
@@ -310,7 +324,7 @@ export class SdNgBundler {
|
|
|
310
324
|
hints,
|
|
311
325
|
});
|
|
312
326
|
|
|
313
|
-
if (this
|
|
327
|
+
if (this._opt.dev) {
|
|
314
328
|
return transformResult;
|
|
315
329
|
} else {
|
|
316
330
|
const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
|
|
@@ -342,9 +356,9 @@ export class SdNgBundler {
|
|
|
342
356
|
{ input: "src", glob: "manifest.webmanifest", output: "" },
|
|
343
357
|
{ input: "src", glob: "manifest.json", output: "" },
|
|
344
358
|
{ input: "src/assets", glob: "**/*", output: "assets" },
|
|
345
|
-
...(this
|
|
346
|
-
...(this
|
|
347
|
-
? Object.keys(this
|
|
359
|
+
...(this._opt.dev ? [{ input: "src/assets-dev", glob: "**/*", output: "assets-dev" }] : []),
|
|
360
|
+
...(this._opt.dev && this._opt.builderType === "cordova"
|
|
361
|
+
? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
|
|
348
362
|
{
|
|
349
363
|
input: `.cordova/platforms/${platform}/platform_www/plugins`,
|
|
350
364
|
glob: "**/*",
|
|
@@ -368,7 +382,7 @@ export class SdNgBundler {
|
|
|
368
382
|
])
|
|
369
383
|
: []),
|
|
370
384
|
],
|
|
371
|
-
this
|
|
385
|
+
this._opt.pkgPath,
|
|
372
386
|
);
|
|
373
387
|
}
|
|
374
388
|
|
|
@@ -386,7 +400,7 @@ export class SdNgBundler {
|
|
|
386
400
|
}[];
|
|
387
401
|
}> {
|
|
388
402
|
return await augmentAppWithServiceWorkerEsbuild(
|
|
389
|
-
this
|
|
403
|
+
this._opt.pkgPath,
|
|
390
404
|
this.#swConfFilePath,
|
|
391
405
|
this.#baseHref,
|
|
392
406
|
"index.html",
|
|
@@ -396,12 +410,12 @@ export class SdNgBundler {
|
|
|
396
410
|
}
|
|
397
411
|
|
|
398
412
|
private _getAppContext() {
|
|
399
|
-
const workerEntries = FsUtil.glob(path.resolve(this
|
|
413
|
+
const workerEntries = FsUtil.glob(path.resolve(this._opt.pkgPath, "src/workers/*.ts")).toObject(
|
|
400
414
|
(p) => "worker/" + path.basename(p, path.extname(p)),
|
|
401
415
|
);
|
|
402
416
|
|
|
403
|
-
return new SdNgBundlerContext(this
|
|
404
|
-
absWorkingDir: this
|
|
417
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
418
|
+
absWorkingDir: this._opt.pkgPath,
|
|
405
419
|
bundle: true,
|
|
406
420
|
keepNames: true,
|
|
407
421
|
format: "esm",
|
|
@@ -409,32 +423,32 @@ export class SdNgBundler {
|
|
|
409
423
|
conditions: ["es2020", "es2015", "module"],
|
|
410
424
|
resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
|
|
411
425
|
metafile: true,
|
|
412
|
-
legalComments: this
|
|
426
|
+
legalComments: this._opt.dev ? "eof" : "none",
|
|
413
427
|
logLevel: "silent",
|
|
414
|
-
minifyIdentifiers: !this
|
|
415
|
-
minifySyntax: !this
|
|
416
|
-
minifyWhitespace: !this
|
|
428
|
+
minifyIdentifiers: !this._opt.dev,
|
|
429
|
+
minifySyntax: !this._opt.dev,
|
|
430
|
+
minifyWhitespace: !this._opt.dev,
|
|
417
431
|
pure: ["forwardRef"],
|
|
418
|
-
outdir: this
|
|
432
|
+
outdir: this._opt.pkgPath,
|
|
419
433
|
outExtension: undefined,
|
|
420
|
-
sourcemap: true, //this
|
|
434
|
+
sourcemap: true, //this._opt.dev,
|
|
421
435
|
splitting: true,
|
|
422
436
|
chunkNames: "[name]-[hash]",
|
|
423
437
|
tsconfig: this.#tsConfigFilePath,
|
|
424
438
|
write: false,
|
|
425
439
|
preserveSymlinks: false,
|
|
426
440
|
define: {
|
|
427
|
-
...(!this
|
|
441
|
+
...(!this._opt.dev ? { ngDevMode: "false" } : {}),
|
|
428
442
|
"ngJitMode": "false",
|
|
429
443
|
"global": "global",
|
|
430
444
|
"process": "process",
|
|
431
445
|
"Buffer": "Buffer",
|
|
432
446
|
"process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
|
|
433
|
-
"process.env.NODE_ENV": JSON.stringify(this
|
|
434
|
-
...(this
|
|
435
|
-
? Object.keys(this
|
|
447
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
448
|
+
...(this._opt.env
|
|
449
|
+
? Object.keys(this._opt.env).toObject(
|
|
436
450
|
(key) => `process.env.${key}`,
|
|
437
|
-
(key) => JSON.stringify(this
|
|
451
|
+
(key) => JSON.stringify(this._opt.env![key]),
|
|
438
452
|
)
|
|
439
453
|
: {}),
|
|
440
454
|
},
|
|
@@ -444,8 +458,8 @@ export class SdNgBundler {
|
|
|
444
458
|
entryPoints: {
|
|
445
459
|
main: this.#mainFilePath,
|
|
446
460
|
// polyfills: 'angular:polyfills',
|
|
447
|
-
polyfills: path.resolve(this
|
|
448
|
-
...(this
|
|
461
|
+
polyfills: path.resolve(this._opt.pkgPath, "src/polyfills.ts"),
|
|
462
|
+
...(this._opt.builderType === "cordova"
|
|
449
463
|
? {
|
|
450
464
|
"cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`),
|
|
451
465
|
}
|
|
@@ -484,12 +498,12 @@ export class SdNgBundler {
|
|
|
484
498
|
},
|
|
485
499
|
inject: [PathUtil.posix(fileURLToPath(import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim")))],
|
|
486
500
|
plugins: [
|
|
487
|
-
...(this
|
|
501
|
+
...(this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins
|
|
488
502
|
? [
|
|
489
503
|
{
|
|
490
504
|
name: "cordova:plugin-empty",
|
|
491
505
|
setup: ({ onResolve }) => {
|
|
492
|
-
onResolve({ filter: new RegExp("(" + this
|
|
506
|
+
onResolve({ filter: new RegExp("(" + this._opt.cordovaConfig!.plugins!.join("|") + ")") }, () => {
|
|
493
507
|
return {
|
|
494
508
|
path: `./cordova-empty.js`,
|
|
495
509
|
external: true,
|
|
@@ -504,19 +518,19 @@ export class SdNgBundler {
|
|
|
504
518
|
// loadContent: () => ({
|
|
505
519
|
// contents: `import "./src/polyfills.ts";`,
|
|
506
520
|
// loader: 'js',
|
|
507
|
-
// resolveDir: this
|
|
521
|
+
// resolveDir: this._opt.pkgPath
|
|
508
522
|
// })
|
|
509
523
|
// }) as esbuild.Plugin,
|
|
510
524
|
createSourcemapIgnorelistPlugin(),
|
|
511
|
-
|
|
525
|
+
createSdNgPlugin({
|
|
512
526
|
modifiedFileSet: this.#modifiedFileSet,
|
|
513
|
-
dev: this
|
|
514
|
-
pkgPath: this
|
|
527
|
+
dev: this._opt.dev,
|
|
528
|
+
pkgPath: this._opt.pkgPath,
|
|
515
529
|
result: this.#ngResultCache,
|
|
516
|
-
watchScopePaths: this
|
|
530
|
+
watchScopePaths: this._opt.watchScopePaths,
|
|
517
531
|
}),
|
|
518
532
|
// createCompilerPlugin({
|
|
519
|
-
// sourcemap: this
|
|
533
|
+
// sourcemap: this._opt.dev,
|
|
520
534
|
// tsconfig: this._tsConfigFilePath,
|
|
521
535
|
// jit: false,
|
|
522
536
|
// advancedOptimizations: true,
|
|
@@ -524,11 +538,11 @@ export class SdNgBundler {
|
|
|
524
538
|
// fileReplacements: undefined,
|
|
525
539
|
// sourceFileCache: this._sourceFileCache,
|
|
526
540
|
// loadResultCache: this._sourceFileCache.loadResultCache,
|
|
527
|
-
// incremental: this
|
|
541
|
+
// incremental: this._opt.dev
|
|
528
542
|
// }, {
|
|
529
|
-
// workspaceRoot: this
|
|
530
|
-
// optimization: !this
|
|
531
|
-
// sourcemap: this
|
|
543
|
+
// workspaceRoot: this._opt.pkgPath,
|
|
544
|
+
// optimization: !this._opt.dev,
|
|
545
|
+
// sourcemap: this._opt.dev ? 'inline' : false,
|
|
532
546
|
// outputNames: {bundles: '[name]', media: 'media/[name]'},
|
|
533
547
|
// includePaths: [],
|
|
534
548
|
// externalDependencies: [],
|
|
@@ -554,22 +568,22 @@ export class SdNgBundler {
|
|
|
554
568
|
private _getStyleContext(): SdNgBundlerContext {
|
|
555
569
|
const pluginFactory = new StylesheetPluginFactory(
|
|
556
570
|
{
|
|
557
|
-
sourcemap: true, //this
|
|
571
|
+
sourcemap: true, //this._opt.dev,
|
|
558
572
|
includePaths: [],
|
|
559
573
|
},
|
|
560
574
|
this.#styleLoadResultCache,
|
|
561
575
|
);
|
|
562
576
|
|
|
563
|
-
return new SdNgBundlerContext(this
|
|
564
|
-
absWorkingDir: this
|
|
577
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
578
|
+
absWorkingDir: this._opt.pkgPath,
|
|
565
579
|
bundle: true,
|
|
566
580
|
entryNames: "[name]",
|
|
567
581
|
assetNames: "media/[name]",
|
|
568
582
|
logLevel: "silent",
|
|
569
|
-
minify: !this
|
|
583
|
+
minify: !this._opt.dev,
|
|
570
584
|
metafile: true,
|
|
571
|
-
sourcemap: true, //this
|
|
572
|
-
outdir: this
|
|
585
|
+
sourcemap: true, //this._opt.dev,
|
|
586
|
+
outdir: this._opt.pkgPath,
|
|
573
587
|
write: false,
|
|
574
588
|
platform: "browser",
|
|
575
589
|
target: this.#browserTarget,
|
|
@@ -577,10 +591,10 @@ export class SdNgBundler {
|
|
|
577
591
|
external: [],
|
|
578
592
|
conditions: ["style", "sass"],
|
|
579
593
|
mainFields: ["style", "sass"],
|
|
580
|
-
legalComments: !this
|
|
594
|
+
legalComments: !this._opt.dev ? "none" : "eof",
|
|
581
595
|
entryPoints: {
|
|
582
596
|
// styles: 'angular:styles/global;styles'
|
|
583
|
-
styles: path.resolve(this
|
|
597
|
+
styles: path.resolve(this._opt.pkgPath, "src/styles.scss"),
|
|
584
598
|
},
|
|
585
599
|
plugins: [
|
|
586
600
|
// createVirtualModulePlugin({
|
|
@@ -589,7 +603,7 @@ export class SdNgBundler {
|
|
|
589
603
|
// loadContent: () => ({
|
|
590
604
|
// contents: `@import 'src/styles.scss';`,
|
|
591
605
|
// loader: 'css',
|
|
592
|
-
// resolveDir: this
|
|
606
|
+
// resolveDir: this._opt.pkgPath
|
|
593
607
|
// }),
|
|
594
608
|
// }) as esbuild.Plugin,
|
|
595
609
|
pluginFactory.create(SassStylesheetLanguage) as esbuild.Plugin,
|
|
@@ -600,52 +614,42 @@ export class SdNgBundler {
|
|
|
600
614
|
}
|
|
601
615
|
|
|
602
616
|
private _getElectronMainContext() {
|
|
603
|
-
return new SdNgBundlerContext(this
|
|
604
|
-
absWorkingDir: this
|
|
617
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
618
|
+
absWorkingDir: this._opt.pkgPath,
|
|
605
619
|
bundle: true,
|
|
606
620
|
entryNames: "[name]",
|
|
607
621
|
assetNames: "media/[name]",
|
|
608
622
|
conditions: ["es2020", "es2015", "module"],
|
|
609
623
|
resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
|
|
610
624
|
metafile: true,
|
|
611
|
-
legalComments: this
|
|
625
|
+
legalComments: this._opt.dev ? "eof" : "none",
|
|
612
626
|
logLevel: "silent",
|
|
613
|
-
minify: !this
|
|
614
|
-
outdir: this
|
|
615
|
-
sourcemap: true, //this
|
|
627
|
+
minify: !this._opt.dev,
|
|
628
|
+
outdir: this._opt.pkgPath,
|
|
629
|
+
sourcemap: true, //this._opt.dev,
|
|
616
630
|
tsconfig: this.#tsConfigFilePath,
|
|
617
631
|
write: false,
|
|
618
632
|
preserveSymlinks: false,
|
|
619
633
|
external: ["electron"],
|
|
620
634
|
define: {
|
|
621
|
-
...(!this
|
|
635
|
+
...(!this._opt.dev ? { ngDevMode: "false" } : {}),
|
|
622
636
|
"process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
|
|
623
|
-
"process.env.NODE_ENV": JSON.stringify(this
|
|
624
|
-
...(this
|
|
625
|
-
? Object.keys(this
|
|
637
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
638
|
+
...(this._opt.env
|
|
639
|
+
? Object.keys(this._opt.env).toObject(
|
|
626
640
|
(key) => `process.env.${key}`,
|
|
627
|
-
(key) => JSON.stringify(this
|
|
641
|
+
(key) => JSON.stringify(this._opt.env![key]),
|
|
628
642
|
)
|
|
629
643
|
: {}),
|
|
630
644
|
},
|
|
631
645
|
platform: "node",
|
|
632
646
|
entryPoints: {
|
|
633
|
-
"electron-main": path.resolve(this
|
|
647
|
+
"electron-main": path.resolve(this._opt.pkgPath, "src/electron-main.ts"),
|
|
634
648
|
},
|
|
635
649
|
});
|
|
636
650
|
}
|
|
637
651
|
|
|
638
652
|
#debug(...msg: any[]): void {
|
|
639
|
-
this.#logger.debug(`[${path.basename(this
|
|
653
|
+
this.#logger.debug(`[${path.basename(this._opt.pkgPath)}]`, ...msg);
|
|
640
654
|
}
|
|
641
655
|
}
|
|
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
|
-
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import esbuild from "esbuild";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { Logger } from "@simplysm/sd-core-node";
|
|
4
|
+
import { InitialFileRecord } from "@angular/build/src/tools/esbuild/bundler-context";
|
|
5
|
+
import { SdCliConvertMessageUtil } from "../../utils/SdCliConvertMessageUtil";
|
|
6
|
+
|
|
7
|
+
export class SdNgBundlerContext {
|
|
8
|
+
readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundlerContext"]);
|
|
9
|
+
|
|
10
|
+
private _context?: esbuild.BuildContext;
|
|
11
|
+
|
|
12
|
+
public constructor(
|
|
13
|
+
private readonly _pkgPath: string,
|
|
14
|
+
private readonly _esbuildOptions: esbuild.BuildOptions,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
public async bundleAsync() {
|
|
18
|
+
if (this._context == null) {
|
|
19
|
+
this._context = await esbuild.context(this._esbuildOptions);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let esbuildResult: esbuild.BuildResult;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
this.#debug(`rebuild...`);
|
|
26
|
+
esbuildResult = await this._context.rebuild();
|
|
27
|
+
this.#debug(`rebuild completed`);
|
|
28
|
+
} catch (err) {
|
|
29
|
+
if ("warnings" in err || "errors" in err) {
|
|
30
|
+
esbuildResult = err;
|
|
31
|
+
} else {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this.#debug(`convert results...`);
|
|
37
|
+
|
|
38
|
+
const results = SdCliConvertMessageUtil.convertToBuildMessagesFromEsbuild(esbuildResult, this._pkgPath);
|
|
39
|
+
|
|
40
|
+
const initialFiles = new Map<string, InitialFileRecord>();
|
|
41
|
+
|
|
42
|
+
for (const outputFile of esbuildResult.outputFiles ?? []) {
|
|
43
|
+
const relativeFilePath = path.isAbsolute(outputFile.path)
|
|
44
|
+
? path.relative(this._pkgPath, outputFile.path)
|
|
45
|
+
: outputFile.path;
|
|
46
|
+
const entryPoint = esbuildResult.metafile?.outputs[relativeFilePath]?.entryPoint;
|
|
47
|
+
|
|
48
|
+
outputFile.path = relativeFilePath;
|
|
49
|
+
|
|
50
|
+
if (entryPoint != null) {
|
|
51
|
+
const name = path.basename(relativeFilePath).split(".", 1)[0];
|
|
52
|
+
const type = path.extname(relativeFilePath) === ".css" ? "style" : "script";
|
|
53
|
+
|
|
54
|
+
if (this._esbuildOptions.entryPoints?.[name] != null) {
|
|
55
|
+
initialFiles.set(relativeFilePath, {
|
|
56
|
+
name,
|
|
57
|
+
type,
|
|
58
|
+
entrypoint: true,
|
|
59
|
+
serverFile: false,
|
|
60
|
+
depth: 0,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const files = [...initialFiles.keys()];
|
|
67
|
+
for (const file of files) {
|
|
68
|
+
const entryRecord = initialFiles.get(file)!;
|
|
69
|
+
|
|
70
|
+
for (const initialImport of esbuildResult.metafile?.outputs[file]?.imports ?? []) {
|
|
71
|
+
const existingRecord = initialFiles.get(initialImport.path);
|
|
72
|
+
if (existingRecord) {
|
|
73
|
+
if (existingRecord.depth > entryRecord.depth + 1) {
|
|
74
|
+
existingRecord.depth = entryRecord.depth + 1;
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (initialImport.kind === "import-statement" || initialImport.kind === "import-rule") {
|
|
80
|
+
const record: InitialFileRecord = {
|
|
81
|
+
type: initialImport.kind === "import-rule" ? "style" : "script",
|
|
82
|
+
entrypoint: false,
|
|
83
|
+
external: initialImport.external,
|
|
84
|
+
serverFile: false,
|
|
85
|
+
depth: entryRecord.depth + 1,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
initialFiles.set(initialImport.path, record);
|
|
89
|
+
|
|
90
|
+
if (!initialImport.external) {
|
|
91
|
+
files.push(initialImport.path);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
results,
|
|
99
|
+
initialFiles,
|
|
100
|
+
outputFiles: esbuildResult.outputFiles,
|
|
101
|
+
metafile: esbuildResult.metafile,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
#debug(...msg: any[]): void {
|
|
106
|
+
this.#logger.debug(
|
|
107
|
+
`[${path.basename(this._pkgPath)}] (${Object.keys(this._esbuildOptions.entryPoints as Record<string, any>).join(", ")})`,
|
|
108
|
+
...msg,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|