@simplysm/sd-cli 11.0.9 → 11.0.12
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 +25 -36
- package/dist/build-cluster.js.map +1 -1
- package/dist/build-tools/SdCliCordova.js +5 -5
- package/dist/build-tools/SdCliCordova.js.map +1 -1
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +4 -0
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js +64 -0
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -0
- package/dist/build-tools/SdLinter.js +8 -1
- package/dist/build-tools/SdLinter.js.map +1 -1
- package/dist/build-tools/SdNgBundler.d.ts +18 -8
- package/dist/build-tools/SdNgBundler.js +286 -213
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdTsBundler.d.ts +6 -5
- package/dist/build-tools/SdTsBundler.js +78 -80
- package/dist/build-tools/SdTsBundler.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +1 -0
- package/dist/build-tools/SdTsCompiler.js +5 -1
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/builders/SdCliClientBuilder.js +51 -36
- package/dist/builders/SdCliClientBuilder.js.map +1 -1
- package/dist/builders/SdCliServerBuilder.d.ts +6 -2
- package/dist/builders/SdCliServerBuilder.js +107 -141
- package/dist/builders/SdCliServerBuilder.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +6 -3
- package/dist/builders/SdCliTsLibBuilder.js +42 -45
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/commons.d.ts +0 -2
- package/dist/entry/SdCliElectron.js +3 -3
- package/dist/entry/SdCliElectron.js.map +1 -1
- package/dist/entry/SdCliProject.d.ts +0 -3
- package/dist/entry/SdCliProject.js +10 -33
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +3 -21
- package/dist/sd-cli.js.map +1 -1
- package/dist/utils/SdMemoryLoadResultCache.d.ts +9 -0
- package/dist/utils/SdMemoryLoadResultCache.js +39 -0
- package/dist/utils/SdMemoryLoadResultCache.js.map +1 -0
- package/dist/utils/SdSourceFileCache.d.ts +5 -0
- package/dist/utils/SdSourceFileCache.js +9 -0
- package/dist/utils/SdSourceFileCache.js.map +1 -0
- package/package.json +17 -17
- package/src/build-cluster.ts +26 -36
- package/src/build-tools/SdCliCordova.ts +5 -5
- package/src/build-tools/SdCliNgRoutesFileGenerator.ts +80 -0
- package/src/build-tools/SdLinter.ts +12 -1
- package/src/build-tools/SdNgBundler.ts +431 -333
- package/src/build-tools/SdTsBundler.ts +86 -86
- package/src/build-tools/SdTsCompiler.ts +6 -1
- package/src/builders/SdCliClientBuilder.ts +62 -43
- package/src/builders/SdCliServerBuilder.ts +64 -63
- package/src/builders/SdCliTsLibBuilder.ts +58 -50
- package/src/commons.ts +1 -2
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliProject.ts +12 -41
- package/src/index.ts +3 -0
- package/src/sd-cli.ts +3 -21
- package/src/utils/SdMemoryLoadResultCache.ts +44 -0
- package/src/utils/SdSourceFileCache.ts +6 -0
|
@@ -1,26 +1,39 @@
|
|
|
1
|
-
import { createCompilerPlugin
|
|
1
|
+
import { createCompilerPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { CrossOrigin } from "@angular-devkit/build-angular/src/builders/application/schema";
|
|
4
3
|
import { BundlerContext } from "@angular-devkit/build-angular/src/tools/esbuild/bundler-context";
|
|
5
|
-
import {
|
|
6
|
-
import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
|
|
4
|
+
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
7
5
|
import { fileURLToPath } from "url";
|
|
8
6
|
import { createVirtualModulePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/virtual-module-plugin";
|
|
9
7
|
import { createSourcemapIgnorelistPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
10
8
|
import nodeStdLibBrowser from "node-stdlib-browser";
|
|
11
9
|
import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
|
|
12
10
|
import { ExecutionResult } from "@angular-devkit/build-angular/src/tools/esbuild/bundler-execution-result";
|
|
13
|
-
import { generateIndexHtml } from "@angular-devkit/build-angular/src/tools/esbuild/index-html-generator";
|
|
14
11
|
import { copyAssets } from "@angular-devkit/build-angular/src/utils/copy-assets";
|
|
15
12
|
import { extractLicenses } from "@angular-devkit/build-angular/src/tools/esbuild/license-extractor";
|
|
16
13
|
import { augmentAppWithServiceWorkerEsbuild } from "@angular-devkit/build-angular/src/utils/service-worker";
|
|
17
|
-
import
|
|
14
|
+
import browserslist from "browserslist";
|
|
15
|
+
import { transformSupportedBrowsersToTargets } from "@angular-devkit/build-angular/src/tools/esbuild/utils";
|
|
16
|
+
import { createCssResourcePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
17
|
+
import { CssStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-language";
|
|
18
|
+
import { SassStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/sass-language";
|
|
19
|
+
import { StylesheetPluginFactory } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
20
|
+
import { IndexHtmlGenerator } from "@angular-devkit/build-angular/src/utils/index-file/index-html-generator";
|
|
21
|
+
import { CrossOrigin } from "@angular-devkit/build-angular";
|
|
22
|
+
import { InlineCriticalCssProcessor } from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
|
|
23
|
+
import { SdSourceFileCache } from "../utils/SdSourceFileCache";
|
|
18
24
|
export class SdNgBundler {
|
|
19
|
-
constructor(
|
|
20
|
-
this.
|
|
21
|
-
this._sourceFileCache = new
|
|
25
|
+
constructor(_opt) {
|
|
26
|
+
this._opt = _opt;
|
|
27
|
+
this._sourceFileCache = new SdSourceFileCache();
|
|
22
28
|
this._outputCache = new Map();
|
|
23
|
-
this.
|
|
29
|
+
this._pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
|
|
30
|
+
this._mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
|
|
31
|
+
this._tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
|
|
32
|
+
this._swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
|
|
33
|
+
this._browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
|
|
34
|
+
this._indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
|
|
35
|
+
this._pkgName = path.basename(this._opt.pkgPath);
|
|
36
|
+
this._baseHref = this._opt.builderType === "web" ? `/${this._pkgName}/` : this._opt.dev ? `/${this._pkgName}/${this._opt.builderType}/` : ``;
|
|
24
37
|
}
|
|
25
38
|
removeCache(filePaths) {
|
|
26
39
|
this._sourceFileCache.invalidate(filePaths);
|
|
@@ -35,7 +48,7 @@ export class SdNgBundler {
|
|
|
35
48
|
const bundlingResult = await BundlerContext.bundleAll(this._contexts);
|
|
36
49
|
const results = [
|
|
37
50
|
...bundlingResult.warnings.map((warn) => ({
|
|
38
|
-
filePath: warn.location?.file !== undefined ? path.resolve(this.
|
|
51
|
+
filePath: warn.location?.file !== undefined ? path.resolve(this._opt.pkgPath, warn.location.file) : undefined,
|
|
39
52
|
line: warn.location?.line,
|
|
40
53
|
char: warn.location?.column,
|
|
41
54
|
code: undefined,
|
|
@@ -44,7 +57,7 @@ export class SdNgBundler {
|
|
|
44
57
|
type: "build"
|
|
45
58
|
})),
|
|
46
59
|
...bundlingResult.errors?.map((err) => ({
|
|
47
|
-
filePath: err.location?.file !== undefined ? path.resolve(this.
|
|
60
|
+
filePath: err.location?.file !== undefined ? path.resolve(this._opt.pkgPath, err.location.file) : undefined,
|
|
48
61
|
line: err.location?.line,
|
|
49
62
|
char: err.location?.column !== undefined ? err.location.column + 1 : undefined,
|
|
50
63
|
code: undefined,
|
|
@@ -55,26 +68,26 @@ export class SdNgBundler {
|
|
|
55
68
|
];
|
|
56
69
|
const watchFilePaths = [
|
|
57
70
|
...this._sourceFileCache.keys(),
|
|
58
|
-
...this._sourceFileCache.babelFileCache.keys()
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
...this._sourceFileCache.babelFileCache.keys(),
|
|
72
|
+
...this._sourceFileCache.loadResultCache.fileDependencies.keys()
|
|
73
|
+
].map((item) => path.resolve(item)).distinct();
|
|
74
|
+
let affectedSourceFilePaths = watchFilePaths.filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
|
|
61
75
|
if (bundlingResult.errors) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
affectedFilePaths: affectedSourceFilePaths,
|
|
65
|
-
results
|
|
66
|
-
};
|
|
76
|
+
// TODO: 제대로 deps를 적용해야함.. 코드 분석 필요
|
|
77
|
+
this._depsMap = this._depsMap ?? new Map();
|
|
67
78
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
for (const
|
|
71
|
-
const
|
|
72
|
-
|
|
79
|
+
else {
|
|
80
|
+
this._depsMap = new Map();
|
|
81
|
+
for (const entry of Object.entries(bundlingResult.metafile.inputs)) {
|
|
82
|
+
for (const imp of entry[1].imports) {
|
|
83
|
+
const deps = this._depsMap.getOrCreate(path.resolve(this._opt.pkgPath, imp.path), new Set());
|
|
84
|
+
deps.add(path.resolve(this._opt.pkgPath, entry[0]));
|
|
85
|
+
}
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
const searchAffectedFiles = (filePath, prev) => {
|
|
76
89
|
const result = new Set(prev);
|
|
77
|
-
const importerPaths =
|
|
90
|
+
const importerPaths = this._depsMap.get(filePath);
|
|
78
91
|
if (!importerPaths)
|
|
79
92
|
return result;
|
|
80
93
|
for (const importerPath of importerPaths) {
|
|
@@ -91,48 +104,85 @@ export class SdNgBundler {
|
|
|
91
104
|
affectedFilePathSet.add(path.resolve(modFile));
|
|
92
105
|
affectedFilePathSet.adds(...searchAffectedFiles(path.resolve(modFile)));
|
|
93
106
|
}
|
|
94
|
-
affectedSourceFilePaths = Array.from(affectedFilePathSet.values()).filter((item) => PathUtil.isChildPath(item, this.
|
|
107
|
+
affectedSourceFilePaths = Array.from(affectedFilePathSet.values()).filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
|
|
108
|
+
}
|
|
109
|
+
if (bundlingResult.errors) {
|
|
110
|
+
return {
|
|
111
|
+
filePaths: watchFilePaths,
|
|
112
|
+
affectedFilePaths: affectedSourceFilePaths,
|
|
113
|
+
results
|
|
114
|
+
};
|
|
95
115
|
}
|
|
96
116
|
const executionResult = new ExecutionResult(this._contexts, this._sourceFileCache);
|
|
97
117
|
executionResult.outputFiles.push(...bundlingResult.outputFiles);
|
|
118
|
+
//-- Check commonjs
|
|
119
|
+
// if (!this._opt.dev) {
|
|
120
|
+
// const messages = checkCommonJSModules(bundlingResult.metafile, []);
|
|
121
|
+
// for (const msg of messages) {
|
|
122
|
+
// results.push({
|
|
123
|
+
// filePath: msg.location?.file,
|
|
124
|
+
// line: msg.location?.line,
|
|
125
|
+
// char: msg.location?.column,
|
|
126
|
+
// code: msg.pluginName,
|
|
127
|
+
// severity: "warning",
|
|
128
|
+
// message: msg.text ?? "",
|
|
129
|
+
// type: "build"
|
|
130
|
+
// });
|
|
131
|
+
// }
|
|
132
|
+
// }
|
|
98
133
|
//-- index
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
const genIndexHtmlResult = await this._genIndexHtmlAsync(bundlingResult.outputFiles, bundlingResult.initialFiles);
|
|
135
|
+
for (const warning of genIndexHtmlResult.warnings) {
|
|
136
|
+
results.push({
|
|
137
|
+
filePath: undefined,
|
|
138
|
+
line: undefined,
|
|
139
|
+
char: undefined,
|
|
140
|
+
code: undefined,
|
|
141
|
+
severity: "warning",
|
|
142
|
+
message: warning,
|
|
143
|
+
type: "build",
|
|
144
|
+
});
|
|
108
145
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
146
|
+
for (const error of genIndexHtmlResult.errors) {
|
|
147
|
+
results.push({
|
|
148
|
+
filePath: undefined,
|
|
149
|
+
line: undefined,
|
|
150
|
+
char: undefined,
|
|
151
|
+
code: undefined,
|
|
152
|
+
severity: "error",
|
|
153
|
+
message: error,
|
|
154
|
+
type: "build",
|
|
155
|
+
});
|
|
112
156
|
}
|
|
157
|
+
executionResult.addOutputFile("index.html", genIndexHtmlResult.content);
|
|
158
|
+
//-- copy assets
|
|
159
|
+
executionResult.assetFiles.push(...(await this._copyAssetsAsync()));
|
|
113
160
|
//-- extract 3rdpartylicenses
|
|
114
|
-
if (this.
|
|
115
|
-
executionResult.addOutputFile('3rdpartylicenses.txt', await extractLicenses(bundlingResult.metafile, this.
|
|
161
|
+
if (!this._opt.dev) {
|
|
162
|
+
executionResult.addOutputFile('3rdpartylicenses.txt', await extractLicenses(bundlingResult.metafile, this._opt.pkgPath));
|
|
116
163
|
}
|
|
117
164
|
//-- service worker
|
|
118
|
-
if (this.
|
|
165
|
+
if (FsUtil.exists(this._swConfFilePath)) {
|
|
119
166
|
try {
|
|
120
|
-
const serviceWorkerResult = await
|
|
167
|
+
const serviceWorkerResult = await this._genServiceWorkerAsync(executionResult.outputFiles, executionResult.assetFiles);
|
|
121
168
|
executionResult.addOutputFile('ngsw.json', serviceWorkerResult.manifest);
|
|
122
169
|
executionResult.assetFiles.push(...serviceWorkerResult.assetFiles);
|
|
123
170
|
}
|
|
124
|
-
catch (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
171
|
+
catch (err) {
|
|
172
|
+
results.push({
|
|
173
|
+
filePath: undefined,
|
|
174
|
+
line: undefined,
|
|
175
|
+
char: undefined,
|
|
176
|
+
code: undefined,
|
|
177
|
+
severity: "error",
|
|
178
|
+
message: err.toString(),
|
|
179
|
+
type: "build",
|
|
180
|
+
});
|
|
131
181
|
}
|
|
132
182
|
}
|
|
133
183
|
//-- write
|
|
134
184
|
for (const outputFile of executionResult.outputFiles) {
|
|
135
|
-
const distFilePath = path.resolve(this.
|
|
185
|
+
const distFilePath = path.resolve(this._opt.outputPath, outputFile.path);
|
|
136
186
|
const prev = this._outputCache.get(distFilePath);
|
|
137
187
|
if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
|
|
138
188
|
await FsUtil.writeFileAsync(distFilePath, outputFile.contents);
|
|
@@ -143,7 +193,7 @@ export class SdNgBundler {
|
|
|
143
193
|
const prev = this._outputCache.get(assetFile.source);
|
|
144
194
|
const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
|
|
145
195
|
if (prev !== curr) {
|
|
146
|
-
await FsUtil.copyAsync(assetFile.source, path.resolve(this.
|
|
196
|
+
await FsUtil.copyAsync(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
|
|
147
197
|
this._outputCache.set(assetFile.source, curr);
|
|
148
198
|
}
|
|
149
199
|
}
|
|
@@ -153,43 +203,114 @@ export class SdNgBundler {
|
|
|
153
203
|
results
|
|
154
204
|
};
|
|
155
205
|
}
|
|
156
|
-
async
|
|
157
|
-
const
|
|
158
|
-
|
|
206
|
+
async _genIndexHtmlAsync(outputFiles, initialFiles) {
|
|
207
|
+
const readAsset = (filePath) => {
|
|
208
|
+
const relFilePath = path.relative("/", filePath);
|
|
209
|
+
const currFile = outputFiles.find((outputFile) => outputFile.path === relFilePath);
|
|
210
|
+
if (currFile) {
|
|
211
|
+
return Promise.resolve(currFile.text);
|
|
212
|
+
}
|
|
213
|
+
throw new Error(`Output file does not exist: ${relFilePath}`);
|
|
214
|
+
};
|
|
215
|
+
const indexHtmlGenerator = new IndexHtmlGenerator({
|
|
216
|
+
indexPath: this._indexHtmlFilePath,
|
|
217
|
+
entrypoints: [
|
|
218
|
+
['runtime', true],
|
|
219
|
+
['polyfills', true],
|
|
220
|
+
['styles', false],
|
|
221
|
+
['vendor', true],
|
|
222
|
+
['main', true],
|
|
223
|
+
...this._opt.builderType === "cordova" ? [
|
|
224
|
+
["cordova-entry", true]
|
|
225
|
+
] : []
|
|
226
|
+
],
|
|
227
|
+
optimization: {
|
|
228
|
+
scripts: !this._opt.dev,
|
|
229
|
+
fonts: { inline: !this._opt.dev },
|
|
230
|
+
styles: {
|
|
231
|
+
minify: !this._opt.dev,
|
|
232
|
+
inlineCritical: false
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
crossOrigin: CrossOrigin.None,
|
|
236
|
+
});
|
|
237
|
+
indexHtmlGenerator.readAsset = readAsset;
|
|
238
|
+
const hints = [];
|
|
239
|
+
if (!this._opt.dev) {
|
|
240
|
+
for (const [key, value] of initialFiles) {
|
|
241
|
+
if (value.entrypoint) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (value.type === 'script') {
|
|
245
|
+
hints.push({ url: key, mode: 'modulepreload' });
|
|
246
|
+
}
|
|
247
|
+
else if (value.type === 'style') {
|
|
248
|
+
hints.push({ url: key, mode: 'preload', as: 'style' });
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const transformResult = await indexHtmlGenerator.process({
|
|
253
|
+
baseHref: this._baseHref,
|
|
254
|
+
lang: undefined,
|
|
255
|
+
outputPath: "/",
|
|
256
|
+
files: [...initialFiles].map(([file, record]) => ({
|
|
257
|
+
name: record.name ?? '',
|
|
258
|
+
file,
|
|
259
|
+
extension: path.extname(file),
|
|
260
|
+
})),
|
|
261
|
+
hints,
|
|
262
|
+
});
|
|
263
|
+
if (this._opt.dev) {
|
|
264
|
+
return transformResult;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
|
|
268
|
+
minify: false,
|
|
269
|
+
readAsset,
|
|
270
|
+
});
|
|
271
|
+
const { content, errors, warnings } = await inlineCriticalCssProcessor.process(transformResult.content, { outputPath: "/", });
|
|
272
|
+
return {
|
|
273
|
+
warnings: [...transformResult.warnings, ...warnings],
|
|
274
|
+
errors: [...transformResult.errors, ...errors],
|
|
275
|
+
content
|
|
276
|
+
};
|
|
277
|
+
}
|
|
159
278
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
'
|
|
163
|
-
'
|
|
164
|
-
'
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
279
|
+
async _copyAssetsAsync() {
|
|
280
|
+
return await copyAssets([
|
|
281
|
+
{ input: 'src', glob: 'favicon.ico', output: '' },
|
|
282
|
+
{ input: 'src', glob: 'manifest.webmanifest', output: '' },
|
|
283
|
+
{ input: 'src/assets', glob: '**/*', output: 'assets' },
|
|
284
|
+
...this._opt.dev && this._opt.cordovaPlatforms ? this._opt.cordovaPlatforms.mapMany((platform) => [
|
|
285
|
+
{
|
|
286
|
+
input: `.cordova/platforms/${platform}/platform_www/plugins`,
|
|
287
|
+
glob: '**/*',
|
|
288
|
+
output: `cordova-${platform}/plugins`
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
input: `.cordova/platforms/${platform}/platform_www`,
|
|
292
|
+
glob: 'cordova.js',
|
|
293
|
+
output: `cordova-${platform}`
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
input: `.cordova/platforms/${platform}/platform_www`,
|
|
297
|
+
glob: 'cordova_plugins.js',
|
|
298
|
+
output: `cordova-${platform}`
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
input: `.cordova/platforms/${platform}/www`,
|
|
302
|
+
glob: 'config.xml',
|
|
303
|
+
output: `cordova-${platform}`
|
|
304
|
+
},
|
|
305
|
+
]) : []
|
|
306
|
+
], [], this._opt.pkgPath);
|
|
175
307
|
}
|
|
176
|
-
async
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
'ios17.0', 'ios16.6',
|
|
183
|
-
'ios16.5', 'ios16.4',
|
|
184
|
-
'ios16.3', 'ios16.2',
|
|
185
|
-
'ios16.1', 'ios16.0',
|
|
186
|
-
'safari17.0', 'safari16.6',
|
|
187
|
-
'safari16.5', 'safari16.4',
|
|
188
|
-
'safari16.3', 'safari16.2',
|
|
189
|
-
'safari16.1', 'safari16.0'
|
|
190
|
-
], this._sourceFileCache);
|
|
191
|
-
return {
|
|
192
|
-
absWorkingDir: this._options.workspaceRoot,
|
|
308
|
+
async _genServiceWorkerAsync(outputFiles, assetFiles) {
|
|
309
|
+
return await augmentAppWithServiceWorkerEsbuild(this._opt.pkgPath, this._swConfFilePath, this._baseHref, outputFiles, assetFiles);
|
|
310
|
+
}
|
|
311
|
+
async _getAppContextAsync() {
|
|
312
|
+
return new BundlerContext(this._opt.pkgPath, true, {
|
|
313
|
+
absWorkingDir: this._opt.pkgPath,
|
|
193
314
|
bundle: true,
|
|
194
315
|
keepNames: true,
|
|
195
316
|
format: 'esm',
|
|
@@ -197,50 +318,42 @@ export class SdNgBundler {
|
|
|
197
318
|
conditions: ['es2020', 'es2015', 'module'],
|
|
198
319
|
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
199
320
|
metafile: true,
|
|
200
|
-
legalComments: this.
|
|
321
|
+
legalComments: this._opt.dev ? 'eof' : 'none',
|
|
201
322
|
logLevel: 'silent',
|
|
202
|
-
minifyIdentifiers: !this.
|
|
203
|
-
minifySyntax: !this.
|
|
204
|
-
minifyWhitespace: !this.
|
|
323
|
+
minifyIdentifiers: !this._opt.dev,
|
|
324
|
+
minifySyntax: !this._opt.dev,
|
|
325
|
+
minifyWhitespace: !this._opt.dev,
|
|
205
326
|
pure: ['forwardRef'],
|
|
206
|
-
outdir: this.
|
|
327
|
+
outdir: this._opt.pkgPath,
|
|
207
328
|
outExtension: undefined,
|
|
208
|
-
sourcemap: this.
|
|
329
|
+
sourcemap: this._opt.dev,
|
|
209
330
|
splitting: true,
|
|
210
331
|
chunkNames: 'chunk-[hash]',
|
|
211
|
-
tsconfig: this.
|
|
332
|
+
tsconfig: this._tsConfigFilePath,
|
|
212
333
|
external: [],
|
|
213
334
|
write: false,
|
|
214
335
|
preserveSymlinks: false,
|
|
215
336
|
define: {
|
|
216
|
-
...!this.
|
|
337
|
+
...!this._opt.dev ? { ngDevMode: 'false' } : {},
|
|
217
338
|
ngJitMode: 'false',
|
|
218
339
|
global: 'global',
|
|
219
340
|
process: 'process',
|
|
220
341
|
Buffer: 'Buffer',
|
|
221
|
-
'process.env.SD_VERSION': JSON.stringify(
|
|
222
|
-
"process.env.NODE_ENV": JSON.stringify(this.
|
|
342
|
+
'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
|
|
343
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
344
|
+
...this._opt.env ? Object.keys(this._opt.env).toObject(key => `process.env.${key}`, key => JSON.stringify(this._opt.env[key])) : {}
|
|
223
345
|
},
|
|
224
346
|
platform: 'browser',
|
|
225
347
|
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
|
|
226
348
|
entryNames: '[name]',
|
|
227
349
|
entryPoints: {
|
|
228
|
-
|
|
229
|
-
polyfills: 'angular:polyfills'
|
|
350
|
+
main: this._mainFilePath,
|
|
351
|
+
polyfills: 'angular:polyfills',
|
|
352
|
+
...this._opt.builderType === "cordova" ? {
|
|
353
|
+
"cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
|
|
354
|
+
} : {}
|
|
230
355
|
},
|
|
231
|
-
target:
|
|
232
|
-
'chrome117.0', 'chrome116.0',
|
|
233
|
-
'edge117.0', 'edge116.0',
|
|
234
|
-
'firefox118.0', 'firefox115.0',
|
|
235
|
-
'ios17.0', 'ios16.6',
|
|
236
|
-
'ios16.5', 'ios16.4',
|
|
237
|
-
'ios16.3', 'ios16.2',
|
|
238
|
-
'ios16.1', 'ios16.0',
|
|
239
|
-
'safari17.0', 'safari16.6',
|
|
240
|
-
'safari16.5', 'safari16.4',
|
|
241
|
-
'safari16.3', 'safari16.2',
|
|
242
|
-
'safari16.1', 'safari16.0'
|
|
243
|
-
],
|
|
356
|
+
target: this._browserTarget,
|
|
244
357
|
supported: { 'async-await': false, 'object-rest-spread': false },
|
|
245
358
|
loader: {
|
|
246
359
|
".png": "file",
|
|
@@ -273,115 +386,75 @@ export class SdNgBundler {
|
|
|
273
386
|
loadContent: () => ({
|
|
274
387
|
contents: `import "./src/polyfills.ts";`,
|
|
275
388
|
loader: 'js',
|
|
276
|
-
resolveDir: this.
|
|
389
|
+
resolveDir: this._opt.pkgPath
|
|
277
390
|
})
|
|
278
391
|
}),
|
|
279
392
|
createSourcemapIgnorelistPlugin(),
|
|
280
|
-
createCompilerPlugin(
|
|
393
|
+
createCompilerPlugin({
|
|
394
|
+
sourcemap: this._opt.dev,
|
|
395
|
+
thirdPartySourcemaps: false,
|
|
396
|
+
tsconfig: this._tsConfigFilePath,
|
|
397
|
+
jit: false,
|
|
398
|
+
advancedOptimizations: true,
|
|
399
|
+
fileReplacements: undefined,
|
|
400
|
+
sourceFileCache: this._sourceFileCache,
|
|
401
|
+
loadResultCache: this._sourceFileCache.loadResultCache
|
|
402
|
+
}, {
|
|
403
|
+
workspaceRoot: this._opt.pkgPath,
|
|
404
|
+
optimization: !this._opt.dev,
|
|
405
|
+
sourcemap: this._opt.dev ? 'inline' : false,
|
|
406
|
+
outputNames: { bundles: '[name]', media: 'media/[name]' },
|
|
407
|
+
includePaths: [],
|
|
408
|
+
externalDependencies: [],
|
|
409
|
+
target: this._browserTarget,
|
|
410
|
+
inlineStyleLanguage: 'scss',
|
|
411
|
+
preserveSymlinks: false,
|
|
412
|
+
tailwindConfiguration: undefined
|
|
413
|
+
}),
|
|
281
414
|
nodeStdLibBrowserPlugin(nodeStdLibBrowser)
|
|
282
415
|
]
|
|
283
|
-
};
|
|
416
|
+
});
|
|
284
417
|
}
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
extractLicenses: !opt.dev,
|
|
305
|
-
inlineStyleLanguage: 'scss',
|
|
306
|
-
jit: false,
|
|
307
|
-
stats: false,
|
|
308
|
-
polyfills: ["./src/polyfills.ts"],
|
|
309
|
-
poll: undefined,
|
|
310
|
-
progress: true,
|
|
311
|
-
externalPackages: opt.dev ? true : undefined,
|
|
418
|
+
_getStyleContext() {
|
|
419
|
+
const browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
|
|
420
|
+
const pluginFactory = new StylesheetPluginFactory({
|
|
421
|
+
sourcemap: this._opt.dev,
|
|
422
|
+
includePaths: []
|
|
423
|
+
}, this._sourceFileCache.loadResultCache);
|
|
424
|
+
return new BundlerContext(this._opt.pkgPath, true, {
|
|
425
|
+
absWorkingDir: this._opt.pkgPath,
|
|
426
|
+
bundle: true,
|
|
427
|
+
entryNames: '[name]',
|
|
428
|
+
assetNames: 'media/[name]',
|
|
429
|
+
logLevel: 'silent',
|
|
430
|
+
minify: !this._opt.dev,
|
|
431
|
+
metafile: true,
|
|
432
|
+
sourcemap: this._opt.dev,
|
|
433
|
+
outdir: this._opt.pkgPath,
|
|
434
|
+
write: false,
|
|
435
|
+
platform: 'browser',
|
|
436
|
+
target: browserTarget,
|
|
312
437
|
preserveSymlinks: false,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
fonts: { inline: !opt.dev }
|
|
332
|
-
},
|
|
333
|
-
outputPath: opt.outputPath,
|
|
334
|
-
outExtension: undefined,
|
|
335
|
-
sourcemapOptions: { vendor: false, hidden: false, scripts: opt.dev, styles: opt.dev },
|
|
336
|
-
tsconfig: tsconfigFilePath,
|
|
337
|
-
projectRoot: opt.pkgPath,
|
|
338
|
-
assets: [
|
|
339
|
-
{ input: 'src', glob: 'favicon.ico', output: '' },
|
|
340
|
-
{ input: 'src\\assets', glob: '**/*', output: 'assets' },
|
|
341
|
-
...opt.dev && opt.cordovaPlatforms ? opt.cordovaPlatforms.mapMany((platform) => [
|
|
342
|
-
{
|
|
343
|
-
input: `.cache\\cordova\\platforms\\${platform}\\platform_www\\plugins`,
|
|
344
|
-
glob: '**/*',
|
|
345
|
-
output: `cordova-${platform}/plugins`
|
|
346
|
-
},
|
|
347
|
-
{
|
|
348
|
-
input: `.cache\\cordova\\platforms\\${platform}\\platform_www`,
|
|
349
|
-
glob: 'cordova.js',
|
|
350
|
-
output: `cordova-${platform}`
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
input: `.cache\\cordova\\platforms\\${platform}\\platform_www`,
|
|
354
|
-
glob: 'cordova_plugins.js',
|
|
355
|
-
output: `cordova-${platform}`
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
input: `.cache\\cordova\\platforms\\${platform}\\www`,
|
|
359
|
-
glob: 'config.xml',
|
|
360
|
-
output: `cordova-${platform}`
|
|
361
|
-
},
|
|
362
|
-
]) : []
|
|
438
|
+
external: [],
|
|
439
|
+
conditions: ['style', 'sass'],
|
|
440
|
+
mainFields: ['style', 'sass'],
|
|
441
|
+
legalComments: !this._opt.dev ? "none" : "eof",
|
|
442
|
+
entryPoints: { styles: 'angular:styles/global;styles' },
|
|
443
|
+
plugins: [
|
|
444
|
+
createVirtualModulePlugin({
|
|
445
|
+
namespace: "angular:styles/global",
|
|
446
|
+
transformPath: (currPath) => currPath.split(';', 2)[1],
|
|
447
|
+
loadContent: () => ({
|
|
448
|
+
contents: `@import 'src/styles.scss';`,
|
|
449
|
+
loader: 'css',
|
|
450
|
+
resolveDir: this._opt.pkgPath
|
|
451
|
+
}),
|
|
452
|
+
}),
|
|
453
|
+
pluginFactory.create(SassStylesheetLanguage),
|
|
454
|
+
pluginFactory.create(CssStylesheetLanguage),
|
|
455
|
+
createCssResourcePlugin(this._sourceFileCache.loadResultCache),
|
|
363
456
|
],
|
|
364
|
-
|
|
365
|
-
fileReplacements: undefined,
|
|
366
|
-
globalStyles: [{ name: 'styles', files: ["src/styles.scss"], initial: true }],
|
|
367
|
-
globalScripts: [],
|
|
368
|
-
serviceWorker: FsUtil.exists(swFilePath) ? swFilePath : undefined,
|
|
369
|
-
indexHtmlOptions: {
|
|
370
|
-
input: indexHtmlFilePath,
|
|
371
|
-
output: 'index.html',
|
|
372
|
-
insertionOrder: [
|
|
373
|
-
['runtime', true],
|
|
374
|
-
['polyfills', true],
|
|
375
|
-
['styles', false],
|
|
376
|
-
['vendor', true],
|
|
377
|
-
['main', true],
|
|
378
|
-
...opt.builderType === "cordova" ? [
|
|
379
|
-
["cordova-entry", true]
|
|
380
|
-
] : []
|
|
381
|
-
]
|
|
382
|
-
},
|
|
383
|
-
tailwindConfiguration: undefined
|
|
384
|
-
};
|
|
457
|
+
}, () => true);
|
|
385
458
|
}
|
|
386
459
|
}
|
|
387
460
|
//# sourceMappingURL=SdNgBundler.js.map
|