@simplysm/sd-cli 11.0.8 → 11.0.11
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.d.ts +21 -0
- package/dist/build-tools/SdCliCordova.js +182 -0
- package/dist/build-tools/SdCliCordova.js.map +1 -0
- 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 +16 -5
- package/dist/build-tools/SdNgBundler.js +280 -179
- 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.d.ts +1 -0
- package/dist/builders/SdCliClientBuilder.js +62 -27
- 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 +22 -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 +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.js +27 -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/lib/cordova-entry.js +22 -0
- package/package.json +19 -16
- package/src/build-cluster.ts +26 -36
- package/src/build-tools/SdCliCordova.ts +240 -0
- package/src/build-tools/SdCliNgRoutesFileGenerator.ts +80 -0
- package/src/build-tools/SdLinter.ts +12 -1
- package/src/build-tools/SdNgBundler.ts +428 -288
- package/src/build-tools/SdTsBundler.ts +86 -86
- package/src/build-tools/SdTsCompiler.ts +6 -1
- package/src/builders/SdCliClientBuilder.ts +76 -34
- package/src/builders/SdCliServerBuilder.ts +64 -63
- package/src/builders/SdCliTsLibBuilder.ts +58 -50
- package/src/commons.ts +24 -2
- package/src/entry/SdCliElectron.ts +3 -3
- package/src/entry/SdCliProject.ts +12 -41
- package/src/index.ts +4 -0
- package/src/sd-cli.ts +31 -21
- package/src/utils/SdMemoryLoadResultCache.ts +44 -0
- package/src/utils/SdSourceFileCache.ts +6 -0
|
@@ -1,27 +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
25
|
constructor(_opt) {
|
|
20
26
|
this._opt = _opt;
|
|
21
|
-
this.
|
|
22
|
-
this._sourceFileCache = new SourceFileCache();
|
|
27
|
+
this._sourceFileCache = new SdSourceFileCache();
|
|
23
28
|
this._outputCache = new Map();
|
|
24
|
-
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}/` : ``;
|
|
25
37
|
}
|
|
26
38
|
removeCache(filePaths) {
|
|
27
39
|
this._sourceFileCache.invalidate(filePaths);
|
|
@@ -56,26 +68,26 @@ export class SdNgBundler {
|
|
|
56
68
|
];
|
|
57
69
|
const watchFilePaths = [
|
|
58
70
|
...this._sourceFileCache.keys(),
|
|
59
|
-
...this._sourceFileCache.babelFileCache.keys()
|
|
60
|
-
|
|
71
|
+
...this._sourceFileCache.babelFileCache.keys(),
|
|
72
|
+
...this._sourceFileCache.loadResultCache.fileDependencies.keys()
|
|
73
|
+
].map((item) => path.resolve(item)).distinct();
|
|
61
74
|
let affectedSourceFilePaths = watchFilePaths.filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
|
|
62
75
|
if (bundlingResult.errors) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
affectedFilePaths: affectedSourceFilePaths,
|
|
66
|
-
results
|
|
67
|
-
};
|
|
76
|
+
// TODO: 제대로 deps를 적용해야함.. 코드 분석 필요
|
|
77
|
+
this._depsMap = this._depsMap ?? new Map();
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
for (const
|
|
72
|
-
const
|
|
73
|
-
|
|
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
|
+
}
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
88
|
const searchAffectedFiles = (filePath, prev) => {
|
|
77
89
|
const result = new Set(prev);
|
|
78
|
-
const importerPaths =
|
|
90
|
+
const importerPaths = this._depsMap.get(filePath);
|
|
79
91
|
if (!importerPaths)
|
|
80
92
|
return result;
|
|
81
93
|
for (const importerPath of importerPaths) {
|
|
@@ -94,47 +106,83 @@ export class SdNgBundler {
|
|
|
94
106
|
}
|
|
95
107
|
affectedSourceFilePaths = Array.from(affectedFilePathSet.values()).filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
|
|
96
108
|
}
|
|
109
|
+
if (bundlingResult.errors) {
|
|
110
|
+
return {
|
|
111
|
+
filePaths: watchFilePaths,
|
|
112
|
+
affectedFilePaths: affectedSourceFilePaths,
|
|
113
|
+
results
|
|
114
|
+
};
|
|
115
|
+
}
|
|
97
116
|
const executionResult = new ExecutionResult(this._contexts, this._sourceFileCache);
|
|
98
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
|
+
// }
|
|
99
133
|
//-- index
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
});
|
|
109
145
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
+
});
|
|
113
156
|
}
|
|
157
|
+
executionResult.addOutputFile("index.html", genIndexHtmlResult.content);
|
|
158
|
+
//-- copy assets
|
|
159
|
+
executionResult.assetFiles.push(...(await this._copyAssetsAsync()));
|
|
114
160
|
//-- extract 3rdpartylicenses
|
|
115
|
-
if (this.
|
|
116
|
-
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));
|
|
117
163
|
}
|
|
118
164
|
//-- service worker
|
|
119
|
-
if (this.
|
|
165
|
+
if (FsUtil.exists(this._swConfFilePath)) {
|
|
120
166
|
try {
|
|
121
|
-
const serviceWorkerResult = await
|
|
167
|
+
const serviceWorkerResult = await this._genServiceWorkerAsync(executionResult.outputFiles, executionResult.assetFiles);
|
|
122
168
|
executionResult.addOutputFile('ngsw.json', serviceWorkerResult.manifest);
|
|
123
169
|
executionResult.assetFiles.push(...serviceWorkerResult.assetFiles);
|
|
124
170
|
}
|
|
125
|
-
catch (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
+
});
|
|
132
181
|
}
|
|
133
182
|
}
|
|
134
183
|
//-- write
|
|
135
|
-
const distPath = path.resolve(this._options.outputPath, "dist", ...(this._opt.builderType === "web" ? [] : [this._opt.builderType]));
|
|
136
184
|
for (const outputFile of executionResult.outputFiles) {
|
|
137
|
-
const distFilePath = path.resolve(
|
|
185
|
+
const distFilePath = path.resolve(this._opt.outputPath, outputFile.path);
|
|
138
186
|
const prev = this._outputCache.get(distFilePath);
|
|
139
187
|
if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
|
|
140
188
|
await FsUtil.writeFileAsync(distFilePath, outputFile.contents);
|
|
@@ -145,7 +193,7 @@ export class SdNgBundler {
|
|
|
145
193
|
const prev = this._outputCache.get(assetFile.source);
|
|
146
194
|
const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
|
|
147
195
|
if (prev !== curr) {
|
|
148
|
-
await FsUtil.copyAsync(assetFile.source, path.resolve(
|
|
196
|
+
await FsUtil.copyAsync(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
|
|
149
197
|
this._outputCache.set(assetFile.source, curr);
|
|
150
198
|
}
|
|
151
199
|
}
|
|
@@ -155,43 +203,114 @@ export class SdNgBundler {
|
|
|
155
203
|
results
|
|
156
204
|
};
|
|
157
205
|
}
|
|
158
|
-
async
|
|
159
|
-
const
|
|
160
|
-
|
|
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
|
+
}
|
|
161
278
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
'
|
|
165
|
-
'
|
|
166
|
-
'
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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);
|
|
177
307
|
}
|
|
178
|
-
async
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
'ios17.0', 'ios16.6',
|
|
185
|
-
'ios16.5', 'ios16.4',
|
|
186
|
-
'ios16.3', 'ios16.2',
|
|
187
|
-
'ios16.1', 'ios16.0',
|
|
188
|
-
'safari17.0', 'safari16.6',
|
|
189
|
-
'safari16.5', 'safari16.4',
|
|
190
|
-
'safari16.3', 'safari16.2',
|
|
191
|
-
'safari16.1', 'safari16.0'
|
|
192
|
-
], this._sourceFileCache);
|
|
193
|
-
return {
|
|
194
|
-
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,
|
|
195
314
|
bundle: true,
|
|
196
315
|
keepNames: true,
|
|
197
316
|
format: 'esm',
|
|
@@ -199,50 +318,42 @@ export class SdNgBundler {
|
|
|
199
318
|
conditions: ['es2020', 'es2015', 'module'],
|
|
200
319
|
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
201
320
|
metafile: true,
|
|
202
|
-
legalComments: this.
|
|
321
|
+
legalComments: this._opt.dev ? 'eof' : 'none',
|
|
203
322
|
logLevel: 'silent',
|
|
204
|
-
minifyIdentifiers: !this.
|
|
205
|
-
minifySyntax: !this.
|
|
206
|
-
minifyWhitespace: !this.
|
|
323
|
+
minifyIdentifiers: !this._opt.dev,
|
|
324
|
+
minifySyntax: !this._opt.dev,
|
|
325
|
+
minifyWhitespace: !this._opt.dev,
|
|
207
326
|
pure: ['forwardRef'],
|
|
208
|
-
outdir: this.
|
|
327
|
+
outdir: this._opt.pkgPath,
|
|
209
328
|
outExtension: undefined,
|
|
210
|
-
sourcemap: this.
|
|
329
|
+
sourcemap: this._opt.dev,
|
|
211
330
|
splitting: true,
|
|
212
331
|
chunkNames: 'chunk-[hash]',
|
|
213
|
-
tsconfig: this.
|
|
332
|
+
tsconfig: this._tsConfigFilePath,
|
|
214
333
|
external: [],
|
|
215
334
|
write: false,
|
|
216
335
|
preserveSymlinks: false,
|
|
217
336
|
define: {
|
|
218
|
-
...!this.
|
|
337
|
+
...!this._opt.dev ? { ngDevMode: 'false' } : {},
|
|
219
338
|
ngJitMode: 'false',
|
|
220
339
|
global: 'global',
|
|
221
340
|
process: 'process',
|
|
222
341
|
Buffer: 'Buffer',
|
|
223
|
-
'process.env.SD_VERSION': JSON.stringify(
|
|
224
|
-
"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])) : {}
|
|
225
345
|
},
|
|
226
346
|
platform: 'browser',
|
|
227
347
|
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
|
|
228
348
|
entryNames: '[name]',
|
|
229
349
|
entryPoints: {
|
|
230
|
-
|
|
231
|
-
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
|
+
} : {}
|
|
232
355
|
},
|
|
233
|
-
target:
|
|
234
|
-
'chrome117.0', 'chrome116.0',
|
|
235
|
-
'edge117.0', 'edge116.0',
|
|
236
|
-
'firefox118.0', 'firefox115.0',
|
|
237
|
-
'ios17.0', 'ios16.6',
|
|
238
|
-
'ios16.5', 'ios16.4',
|
|
239
|
-
'ios16.3', 'ios16.2',
|
|
240
|
-
'ios16.1', 'ios16.0',
|
|
241
|
-
'safari17.0', 'safari16.6',
|
|
242
|
-
'safari16.5', 'safari16.4',
|
|
243
|
-
'safari16.3', 'safari16.2',
|
|
244
|
-
'safari16.1', 'safari16.0'
|
|
245
|
-
],
|
|
356
|
+
target: this._browserTarget,
|
|
246
357
|
supported: { 'async-await': false, 'object-rest-spread': false },
|
|
247
358
|
loader: {
|
|
248
359
|
".png": "file",
|
|
@@ -275,85 +386,75 @@ export class SdNgBundler {
|
|
|
275
386
|
loadContent: () => ({
|
|
276
387
|
contents: `import "./src/polyfills.ts";`,
|
|
277
388
|
loader: 'js',
|
|
278
|
-
resolveDir: this.
|
|
389
|
+
resolveDir: this._opt.pkgPath
|
|
279
390
|
})
|
|
280
391
|
}),
|
|
281
392
|
createSourcemapIgnorelistPlugin(),
|
|
282
|
-
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
|
+
}),
|
|
283
414
|
nodeStdLibBrowserPlugin(nodeStdLibBrowser)
|
|
284
415
|
]
|
|
285
|
-
};
|
|
416
|
+
});
|
|
286
417
|
}
|
|
287
|
-
|
|
288
|
-
const
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
extractLicenses: !opt.dev,
|
|
307
|
-
inlineStyleLanguage: 'scss',
|
|
308
|
-
jit: false,
|
|
309
|
-
stats: false,
|
|
310
|
-
polyfills: ["./src/polyfills.ts"],
|
|
311
|
-
poll: undefined,
|
|
312
|
-
progress: true,
|
|
313
|
-
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,
|
|
314
437
|
preserveSymlinks: false,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
tsconfig: tsconfigFilePath,
|
|
334
|
-
projectRoot: opt.pkgPath,
|
|
335
|
-
assets: [
|
|
336
|
-
{ glob: 'favicon.ico', input: 'src', output: '' },
|
|
337
|
-
{ glob: '**/*', input: 'src\\assets', output: 'assets' }
|
|
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),
|
|
338
456
|
],
|
|
339
|
-
|
|
340
|
-
fileReplacements: undefined,
|
|
341
|
-
globalStyles: [{ name: 'styles', files: ["src/styles.scss"], initial: true }],
|
|
342
|
-
globalScripts: [],
|
|
343
|
-
serviceWorker: FsUtil.exists(swFilePath) ? swFilePath : undefined,
|
|
344
|
-
indexHtmlOptions: {
|
|
345
|
-
input: indexHtmlFilePath,
|
|
346
|
-
output: 'index.html',
|
|
347
|
-
insertionOrder: [
|
|
348
|
-
['runtime', true],
|
|
349
|
-
['polyfills', true],
|
|
350
|
-
['styles', false],
|
|
351
|
-
['vendor', true],
|
|
352
|
-
['main', true]
|
|
353
|
-
]
|
|
354
|
-
},
|
|
355
|
-
tailwindConfiguration: undefined
|
|
356
|
-
};
|
|
457
|
+
}, () => true);
|
|
357
458
|
}
|
|
358
459
|
}
|
|
359
460
|
//# sourceMappingURL=SdNgBundler.js.map
|