@simplysm/sd-cli 12.5.13 → 12.5.15

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.
@@ -1,41 +1,41 @@
1
1
  import path from "path";
2
- import esbuild, {Metafile} from "esbuild";
3
- import {FsUtil, Logger, PathUtil} from "@simplysm/sd-core-node";
4
- import {fileURLToPath} from "url";
2
+ import esbuild, { Metafile } from "esbuild";
3
+ import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
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";
7
+ import { INpmConfig, ISdCliClientBuilderCordovaConfig, ISdCliPackageBuildResult } from "../commons";
8
8
  import browserslist from "browserslist";
9
- import {SdNgBundlerContext} from "./SdNgBundlerContext";
10
- import {INgPluginResultCache, sdNgPlugin} from "../bundle-plugins/sdNgPlugin";
9
+ import { SdNgBundlerContext } from "./SdNgBundlerContext";
10
+ import { INgPluginResultCache, sdNgPlugin } from "../bundle-plugins/sdNgPlugin";
11
11
  import ts from "typescript";
12
- import {MemoryLoadResultCache} from "@angular/build/src/tools/esbuild/load-result-cache";
12
+ import { MemoryLoadResultCache } from "@angular/build/src/tools/esbuild/load-result-cache";
13
13
  import {
14
14
  convertOutputFile,
15
15
  createOutputFile,
16
- transformSupportedBrowsersToTargets
16
+ transformSupportedBrowsersToTargets,
17
17
  } from "@angular/build/src/tools/esbuild/utils";
18
18
  import {
19
19
  BuildOutputFile,
20
20
  BuildOutputFileType,
21
- InitialFileRecord
21
+ InitialFileRecord,
22
22
  } from "@angular/build/src/tools/esbuild/bundler-context";
23
- import {extractLicenses} from "@angular/build/src/tools/esbuild/license-extractor";
23
+ import { extractLicenses } from "@angular/build/src/tools/esbuild/license-extractor";
24
24
  import {
25
25
  HintMode,
26
26
  IndexHtmlGenerator,
27
- IndexHtmlProcessResult
27
+ IndexHtmlProcessResult,
28
28
  } from "@angular/build/src/utils/index-file/index-html-generator";
29
- import {Entrypoint} from "@angular/build/src/utils/index-file/augment-index-html";
30
- import {CrossOrigin} from "@angular/build/src/builders/application/schema";
31
- import {InlineCriticalCssProcessor} from "@angular/build/src/utils/index-file/inline-critical-css";
32
- import {augmentAppWithServiceWorkerEsbuild} from "@angular/build/src/utils/service-worker";
33
- import {createSourcemapIgnorelistPlugin} from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
34
- import {StylesheetPluginFactory} from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
35
- import {SassStylesheetLanguage} from "@angular/build/src/tools/esbuild/stylesheets/sass-language";
36
- import {CssStylesheetLanguage} from "@angular/build/src/tools/esbuild/stylesheets/css-language";
37
- import {createCssResourcePlugin} from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
38
- import {resolveAssets} from "@angular/build/src/utils/resolve-assets";
29
+ import { Entrypoint } from "@angular/build/src/utils/index-file/augment-index-html";
30
+ import { CrossOrigin } from "@angular/build/src/builders/application/schema";
31
+ import { InlineCriticalCssProcessor } from "@angular/build/src/utils/index-file/inline-critical-css";
32
+ import { augmentAppWithServiceWorkerEsbuild } from "@angular/build/src/utils/service-worker";
33
+ import { createSourcemapIgnorelistPlugin } from "@angular/build/src/tools/esbuild/sourcemap-ignorelist-plugin";
34
+ import { StylesheetPluginFactory } from "@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
35
+ import { SassStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/sass-language";
36
+ import { CssStylesheetLanguage } from "@angular/build/src/tools/esbuild/stylesheets/css-language";
37
+ import { createCssResourcePlugin } from "@angular/build/src/tools/esbuild/stylesheets/css-resource-plugin";
38
+ import { resolveAssets } from "@angular/build/src/utils/resolve-assets";
39
39
 
40
40
  export class SdNgBundler {
41
41
  readonly #logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler"]);
@@ -47,7 +47,7 @@ export class SdNgBundler {
47
47
  readonly #modifiedFileSet = new Set<string>();
48
48
  readonly #ngResultCache: INgPluginResultCache = {
49
49
  affectedFileSet: new Set<string>(),
50
- watchFileSet: new Set<string>()
50
+ watchFileSet: new Set<string>(),
51
51
  };
52
52
  readonly #styleLoadResultCache = new MemoryLoadResultCache();
53
53
 
@@ -77,7 +77,8 @@ export class SdNgBundler {
77
77
  this.#browserTarget = transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"]));
78
78
  this.#indexHtmlFilePath = path.resolve(opt.pkgPath, "src/index.html");
79
79
  this.#pkgName = path.basename(opt.pkgPath);
80
- this.#baseHref = opt.builderType === "web" ? `/${this.#pkgName}/` : opt.dev ? `/${this.#pkgName}/${opt.builderType}/` : ``;
80
+ this.#baseHref =
81
+ opt.builderType === "web" ? `/${this.#pkgName}/` : opt.dev ? `/${this.#pkgName}/${opt.builderType}/` : ``;
81
82
  }
82
83
 
83
84
  public markForChanges(filePaths: string[]): void {
@@ -90,9 +91,9 @@ export class SdNgBundler {
90
91
 
91
92
  public async bundleAsync(): Promise<{
92
93
  program?: ts.Program;
93
- watchFileSet: Set<string>,
94
- affectedFileSet: Set<string>,
95
- results: ISdCliPackageBuildResult[]
94
+ watchFileSet: Set<string>;
95
+ affectedFileSet: Set<string>;
96
+ results: ISdCliPackageBuildResult[];
96
97
  }> {
97
98
  this.#debug(`get contexts...`);
98
99
 
@@ -100,9 +101,7 @@ export class SdNgBundler {
100
101
  this.#contexts = [
101
102
  this._getAppContext(),
102
103
  this._getStyleContext(),
103
- ...this.#opt.builderType === "electron" ? [
104
- this._getElectronMainContext()
105
- ] : []
104
+ ...(this.#opt.builderType === "electron" ? [this._getElectronMainContext()] : []),
106
105
  ];
107
106
  }
108
107
 
@@ -111,23 +110,25 @@ export class SdNgBundler {
111
110
  const bundlingResults = await this.#contexts.mapAsync(async (ctx, i) => await ctx.bundleAsync());
112
111
 
113
112
  //-- results
114
- const results = bundlingResults.mapMany(bundlingResult => bundlingResult.results);
113
+ const results = bundlingResults.mapMany((bundlingResult) => bundlingResult.results);
115
114
 
116
115
  this.#debug(`convert result...`);
117
116
 
118
- const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(item => item.outputFiles?.map(file => convertOutputFile(file, BuildOutputFileType.Root)) ?? []);
117
+ const outputFiles: BuildOutputFile[] = bundlingResults.mapMany(
118
+ (item) => item.outputFiles?.map((file) => convertOutputFile(file, BuildOutputFileType.Root)) ?? [],
119
+ );
119
120
  const initialFiles = new Map<string, InitialFileRecord>();
120
121
  const metafile: {
121
- inputs: Metafile["inputs"],
122
- outputs: Metafile["outputs"]
122
+ inputs: Metafile["inputs"];
123
+ outputs: Metafile["outputs"];
123
124
  } = {
124
125
  inputs: {},
125
- outputs: {}
126
+ outputs: {},
126
127
  };
127
128
  for (const bundlingResult of bundlingResults) {
128
129
  bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
129
- metafile.inputs = {...metafile.inputs, ...bundlingResult.metafile?.inputs};
130
- metafile.outputs = {...metafile.outputs, ...bundlingResult.metafile?.outputs};
130
+ metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
131
+ metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
131
132
  }
132
133
  const assetFiles: { source: string; destination: string }[] = [];
133
134
 
@@ -168,7 +169,13 @@ export class SdNgBundler {
168
169
 
169
170
  //-- extract 3rdpartylicenses
170
171
  if (!this.#opt.dev) {
171
- outputFiles.push(createOutputFile('3rdpartylicenses.txt', await extractLicenses(metafile, this.#opt.pkgPath), BuildOutputFileType.Root));
172
+ outputFiles.push(
173
+ createOutputFile(
174
+ "3rdpartylicenses.txt",
175
+ await extractLicenses(metafile, this.#opt.pkgPath),
176
+ BuildOutputFileType.Root,
177
+ ),
178
+ );
172
179
  }
173
180
 
174
181
  //-- service worker
@@ -177,10 +184,9 @@ export class SdNgBundler {
177
184
 
178
185
  try {
179
186
  const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
180
- outputFiles.push(createOutputFile('ngsw.json', serviceWorkerResult.manifest, BuildOutputFileType.Root));
187
+ outputFiles.push(createOutputFile("ngsw.json", serviceWorkerResult.manifest, BuildOutputFileType.Root));
181
188
  assetFiles.push(...serviceWorkerResult.assetFiles);
182
- }
183
- catch (err) {
189
+ } catch (err) {
184
190
  results.push({
185
191
  filePath: undefined,
186
192
  line: undefined,
@@ -220,10 +226,10 @@ export class SdNgBundler {
220
226
  watchFileSet: new Set([
221
227
  ...this.#ngResultCache.watchFileSet!,
222
228
  ...this.#styleLoadResultCache.watchFiles,
223
- this.#indexHtmlFilePath
229
+ this.#indexHtmlFilePath,
224
230
  ]),
225
231
  affectedFileSet: this.#ngResultCache.affectedFileSet!,
226
- results
232
+ results,
227
233
  };
228
234
  }
229
235
 
@@ -244,40 +250,38 @@ export class SdNgBundler {
244
250
  const indexHtmlGenerator = new IndexHtmlGenerator({
245
251
  indexPath: this.#indexHtmlFilePath,
246
252
  entrypoints: [
247
- ['runtime', true],
248
- ['polyfills', true],
249
- ['styles', false],
250
- ['vendor', true],
251
- ['main', true],
252
- ...this.#opt.builderType === "cordova" ? [
253
- ["cordova-entry", true] as Entrypoint
254
- ] : []
253
+ ["runtime", true],
254
+ ["polyfills", true],
255
+ ["styles", false],
256
+ ["vendor", true],
257
+ ["main", true],
258
+ ...(this.#opt.builderType === "cordova" ? [["cordova-entry", true] as Entrypoint] : []),
255
259
  ],
256
260
  optimization: {
257
261
  scripts: !this.#opt.dev,
258
- fonts: {inline: !this.#opt.dev},
262
+ fonts: { inline: !this.#opt.dev },
259
263
  styles: {
260
264
  minify: !this.#opt.dev,
261
- inlineCritical: false
265
+ inlineCritical: false,
262
266
  },
263
267
  },
264
268
  crossOrigin: CrossOrigin.None,
265
269
  });
266
270
  indexHtmlGenerator.readAsset = readAsset;
267
271
 
268
- const hints: { url: string; mode: HintMode; as?: string; }[] = [];
272
+ const hints: { url: string; mode: HintMode; as?: string }[] = [];
269
273
  if (!this.#opt.dev) {
270
274
  for (const [key, value] of initialFiles) {
271
275
  if (value.entrypoint) {
272
276
  continue;
273
277
  }
274
278
 
275
- if (value.type === 'script') {
276
- hints.push({url: key, mode: 'modulepreload' as const});
279
+ if (value.type === "script") {
280
+ hints.push({ url: key, mode: "modulepreload" as const });
277
281
  }
278
282
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
279
- else if (value.type === 'style') {
280
- hints.push({url: key, mode: 'preload' as const, as: 'style'});
283
+ else if (value.type === "style") {
284
+ hints.push({ url: key, mode: "preload" as const, as: "style" });
281
285
  }
282
286
  }
283
287
  }
@@ -287,7 +291,7 @@ export class SdNgBundler {
287
291
  lang: undefined,
288
292
  outputPath: "/",
289
293
  files: [...initialFiles].map(([file, record]) => ({
290
- name: record.name ?? '',
294
+ name: record.name ?? "",
291
295
  file,
292
296
  extension: path.extname(file),
293
297
  })),
@@ -296,58 +300,64 @@ export class SdNgBundler {
296
300
 
297
301
  if (this.#opt.dev) {
298
302
  return transformResult;
299
- }
300
- else {
303
+ } else {
301
304
  const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
302
305
  minify: false,
303
306
  readAsset,
304
307
  });
305
- const {content, errors, warnings} = await inlineCriticalCssProcessor.process(
306
- transformResult.csrContent,
307
- {outputPath: "/",},
308
- );
308
+ const { content, errors, warnings } = await inlineCriticalCssProcessor.process(transformResult.csrContent, {
309
+ outputPath: "/",
310
+ });
309
311
 
310
312
  return {
311
313
  warnings: [...transformResult.warnings, ...warnings],
312
314
  errors: [...transformResult.errors, ...errors],
313
- csrContent: content
315
+ csrContent: content,
314
316
  };
315
317
  }
316
318
  }
317
319
 
318
320
  //TODO: index.html 파일에 manifest.json 정보 추가? manifest.webmanifest ? PWA?
319
- private async _copyAssetsAsync(): Promise<{
320
- source: string;
321
- destination: string;
322
- }[]> {
323
- return await resolveAssets([
324
- {input: 'src', glob: 'favicon.ico', output: ''},
325
- {input: 'src', glob: 'manifest.webmanifest', output: ''},
326
- {input: 'src', glob: 'manifest.json', output: ''},
327
- {input: 'src/assets', glob: '**/*', output: 'assets'},
328
- ...this.#opt.dev && this.#opt.builderType === "cordova" ? Object.keys(this.#opt.cordovaConfig?.platform ?? {browser: {}}).mapMany((platform) => [
329
- {
330
- input: `.cordova/platforms/${platform}/platform_www/plugins`,
331
- glob: '**/*',
332
- output: `cordova-${platform}/plugins`
333
- },
334
- {
335
- input: `.cordova/platforms/${platform}/platform_www`,
336
- glob: 'cordova.js',
337
- output: `cordova-${platform}`
338
- },
339
- {
340
- input: `.cordova/platforms/${platform}/platform_www`,
341
- glob: 'cordova_plugins.js',
342
- output: `cordova-${platform}`
343
- },
344
- {
345
- input: `.cordova/platforms/${platform}/www`,
346
- glob: 'config.xml',
347
- output: `cordova-${platform}`
348
- },
349
- ]) : []
350
- ], this.#opt.pkgPath);
321
+ private async _copyAssetsAsync(): Promise<
322
+ {
323
+ source: string;
324
+ destination: string;
325
+ }[]
326
+ > {
327
+ return await resolveAssets(
328
+ [
329
+ { input: "src", glob: "favicon.ico", output: "" },
330
+ { input: "src", glob: "manifest.webmanifest", output: "" },
331
+ { input: "src", glob: "manifest.json", output: "" },
332
+ { input: "src/assets", glob: "**/*", output: "assets" },
333
+ ...(this.#opt.dev ? [{ input: "src/assets-dev", glob: "**/*", output: "assets-dev" }] : []),
334
+ ...(this.#opt.dev && this.#opt.builderType === "cordova"
335
+ ? Object.keys(this.#opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
336
+ {
337
+ input: `.cordova/platforms/${platform}/platform_www/plugins`,
338
+ glob: "**/*",
339
+ output: `cordova-${platform}/plugins`,
340
+ },
341
+ {
342
+ input: `.cordova/platforms/${platform}/platform_www`,
343
+ glob: "cordova.js",
344
+ output: `cordova-${platform}`,
345
+ },
346
+ {
347
+ input: `.cordova/platforms/${platform}/platform_www`,
348
+ glob: "cordova_plugins.js",
349
+ output: `cordova-${platform}`,
350
+ },
351
+ {
352
+ input: `.cordova/platforms/${platform}/www`,
353
+ glob: "config.xml",
354
+ output: `cordova-${platform}`,
355
+ },
356
+ ])
357
+ : []),
358
+ ],
359
+ this.#opt.pkgPath,
360
+ );
351
361
  }
352
362
 
353
363
  private async _genServiceWorkerAsync(
@@ -355,7 +365,7 @@ export class SdNgBundler {
355
365
  assetFiles: {
356
366
  source: string;
357
367
  destination: string;
358
- }[]
368
+ }[],
359
369
  ): Promise<{
360
370
  manifest: string;
361
371
  assetFiles: {
@@ -369,61 +379,70 @@ export class SdNgBundler {
369
379
  this.#baseHref,
370
380
  "index.html",
371
381
  outputFiles,
372
- assetFiles
382
+ assetFiles,
373
383
  );
374
384
  }
375
385
 
376
386
  private _getAppContext() {
387
+ const workerEntries = FsUtil.glob(path.resolve(this.#opt.pkgPath, "src/workers/*.ts")).toObject(
388
+ (p) => "worker/" + path.basename(p, path.extname(p)),
389
+ );
390
+
377
391
  return new SdNgBundlerContext(this.#opt.pkgPath, {
378
392
  absWorkingDir: this.#opt.pkgPath,
379
393
  bundle: true,
380
394
  keepNames: true,
381
- format: 'esm',
382
- assetNames: 'media/[name]',
383
- conditions: ['es2020', 'es2015', 'module'],
395
+ format: "esm",
396
+ assetNames: "media/[name]",
397
+ conditions: ["es2020", "es2015", "module"],
384
398
  resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
385
399
  metafile: true,
386
- legalComments: this.#opt.dev ? 'eof' : 'none',
387
- logLevel: 'silent',
400
+ legalComments: this.#opt.dev ? "eof" : "none",
401
+ logLevel: "silent",
388
402
  minifyIdentifiers: !this.#opt.dev,
389
403
  minifySyntax: !this.#opt.dev,
390
404
  minifyWhitespace: !this.#opt.dev,
391
- pure: ['forwardRef'],
405
+ pure: ["forwardRef"],
392
406
  outdir: this.#opt.pkgPath,
393
407
  outExtension: undefined,
394
408
  sourcemap: true, //this.#opt.dev,
395
409
  splitting: true,
396
- chunkNames: '[name]-[hash]',
410
+ chunkNames: "[name]-[hash]",
397
411
  tsconfig: this.#tsConfigFilePath,
398
412
  write: false,
399
413
  preserveSymlinks: false,
400
414
  define: {
401
- ...!this.#opt.dev ? {ngDevMode: "false"} : {},
402
- ngJitMode: 'false',
403
- global: 'global',
404
- process: 'process',
405
- Buffer: 'Buffer',
406
- 'process.env.SD_VERSION': JSON.stringify(this.#pkgNpmConf.version),
415
+ ...(!this.#opt.dev ? { ngDevMode: "false" } : {}),
416
+ "ngJitMode": "false",
417
+ "global": "global",
418
+ "process": "process",
419
+ "Buffer": "Buffer",
420
+ "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
407
421
  "process.env.NODE_ENV": JSON.stringify(this.#opt.dev ? "development" : "production"),
408
- ...this.#opt.env ? Object.keys(this.#opt.env).toObject(
409
- key => `process.env.${key}`,
410
- key => JSON.stringify(this.#opt.env![key])
411
- ) : {}
422
+ ...(this.#opt.env
423
+ ? Object.keys(this.#opt.env).toObject(
424
+ (key) => `process.env.${key}`,
425
+ (key) => JSON.stringify(this.#opt.env![key]),
426
+ )
427
+ : {}),
412
428
  },
413
- platform: 'browser',
414
- mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
415
- entryNames: '[name]',
429
+ platform: "browser",
430
+ mainFields: ["es2020", "es2015", "browser", "module", "main"],
431
+ entryNames: "[name]",
416
432
  entryPoints: {
417
433
  main: this.#mainFilePath,
418
434
  // polyfills: 'angular:polyfills',
419
435
  polyfills: path.resolve(this.#opt.pkgPath, "src/polyfills.ts"),
420
- ...this.#opt.builderType === "cordova" ? {
421
- "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
422
- } : {}
436
+ ...(this.#opt.builderType === "cordova"
437
+ ? {
438
+ "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`),
439
+ }
440
+ : {}),
441
+ ...workerEntries,
423
442
  },
424
443
  external: ["electron"],
425
444
  target: this.#browserTarget,
426
- supported: {'async-await': false, 'object-rest-spread': false},
445
+ supported: { "async-await": false, "object-rest-spread": false },
427
446
  loader: {
428
447
  ".png": "file",
429
448
  ".jpeg": "file",
@@ -449,21 +468,25 @@ export class SdNgBundler {
449
468
  ".pfx": "file",
450
469
  ".pkl": "file",
451
470
  ".mp3": "file",
452
- ".ogg": "file"
471
+ ".ogg": "file",
453
472
  },
454
473
  inject: [PathUtil.posix(fileURLToPath(import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim")))],
455
474
  plugins: [
456
- ...this.#opt.builderType === "cordova" && this.#opt.cordovaConfig?.plugins ? [{
457
- name: "cordova:plugin-empty",
458
- setup: ({onResolve}) => {
459
- onResolve({filter: new RegExp("(" + this.#opt.cordovaConfig!.plugins!.join("|") + ")")}, () => {
460
- return {
461
- path: `./cordova-empty.js`,
462
- external: true
463
- };
464
- });
465
- }
466
- }] : [],
475
+ ...(this.#opt.builderType === "cordova" && this.#opt.cordovaConfig?.plugins
476
+ ? [
477
+ {
478
+ name: "cordova:plugin-empty",
479
+ setup: ({ onResolve }) => {
480
+ onResolve({ filter: new RegExp("(" + this.#opt.cordovaConfig!.plugins!.join("|") + ")") }, () => {
481
+ return {
482
+ path: `./cordova-empty.js`,
483
+ external: true,
484
+ };
485
+ });
486
+ },
487
+ },
488
+ ]
489
+ : []),
467
490
  // createVirtualModulePlugin({
468
491
  // namespace: "angular:polyfills",
469
492
  // loadContent: () => ({
@@ -477,7 +500,7 @@ export class SdNgBundler {
477
500
  modifiedFileSet: this.#modifiedFileSet,
478
501
  dev: this.#opt.dev,
479
502
  pkgPath: this.#opt.pkgPath,
480
- result: this.#ngResultCache
503
+ result: this.#ngResultCache,
481
504
  }),
482
505
  // createCompilerPlugin({
483
506
  // sourcemap: this.#opt.dev,
@@ -501,7 +524,7 @@ export class SdNgBundler {
501
524
  // preserveSymlinks: false,
502
525
  // tailwindConfiguration: undefined
503
526
  // }) as esbuild.Plugin,
504
- nodeStdLibBrowserPlugin(nodeStdLibBrowser)
527
+ nodeStdLibBrowserPlugin(nodeStdLibBrowser),
505
528
  // {
506
529
  // name: "sd-load-file",
507
530
  // setup: ({onLoad}) => {
@@ -511,7 +534,7 @@ export class SdNgBundler {
511
534
  // });
512
535
  // }
513
536
  // }
514
- ]
537
+ ],
515
538
  });
516
539
  }
517
540
 
@@ -519,7 +542,7 @@ export class SdNgBundler {
519
542
  const pluginFactory = new StylesheetPluginFactory(
520
543
  {
521
544
  sourcemap: true, //this.#opt.dev,
522
- includePaths: []
545
+ includePaths: [],
523
546
  },
524
547
  this.#styleLoadResultCache,
525
548
  );
@@ -527,24 +550,24 @@ export class SdNgBundler {
527
550
  return new SdNgBundlerContext(this.#opt.pkgPath, {
528
551
  absWorkingDir: this.#opt.pkgPath,
529
552
  bundle: true,
530
- entryNames: '[name]',
531
- assetNames: 'media/[name]',
532
- logLevel: 'silent',
553
+ entryNames: "[name]",
554
+ assetNames: "media/[name]",
555
+ logLevel: "silent",
533
556
  minify: !this.#opt.dev,
534
557
  metafile: true,
535
558
  sourcemap: true, //this.#opt.dev,
536
559
  outdir: this.#opt.pkgPath,
537
560
  write: false,
538
- platform: 'browser',
561
+ platform: "browser",
539
562
  target: this.#browserTarget,
540
563
  preserveSymlinks: false,
541
564
  external: [],
542
- conditions: ['style', 'sass'],
543
- mainFields: ['style', 'sass'],
565
+ conditions: ["style", "sass"],
566
+ mainFields: ["style", "sass"],
544
567
  legalComments: !this.#opt.dev ? "none" : "eof",
545
568
  entryPoints: {
546
569
  // styles: 'angular:styles/global;styles'
547
- styles: path.resolve(this.#opt.pkgPath, "src/styles.scss")
570
+ styles: path.resolve(this.#opt.pkgPath, "src/styles.scss"),
548
571
  },
549
572
  plugins: [
550
573
  // createVirtualModulePlugin({
@@ -567,13 +590,13 @@ export class SdNgBundler {
567
590
  return new SdNgBundlerContext(this.#opt.pkgPath, {
568
591
  absWorkingDir: this.#opt.pkgPath,
569
592
  bundle: true,
570
- entryNames: '[name]',
571
- assetNames: 'media/[name]',
572
- conditions: ['es2020', 'es2015', 'module'],
593
+ entryNames: "[name]",
594
+ assetNames: "media/[name]",
595
+ conditions: ["es2020", "es2015", "module"],
573
596
  resolveExtensions: [".js", ".mjs", ".cjs", ".ts"],
574
597
  metafile: true,
575
- legalComments: this.#opt.dev ? 'eof' : 'none',
576
- logLevel: 'silent',
598
+ legalComments: this.#opt.dev ? "eof" : "none",
599
+ logLevel: "silent",
577
600
  minify: !this.#opt.dev,
578
601
  outdir: this.#opt.pkgPath,
579
602
  sourcemap: true, //this.#opt.dev,
@@ -582,22 +605,23 @@ export class SdNgBundler {
582
605
  preserveSymlinks: false,
583
606
  external: ["electron"],
584
607
  define: {
585
- ...!this.#opt.dev ? {ngDevMode: 'false'} : {},
586
- 'process.env.SD_VERSION': JSON.stringify(this.#pkgNpmConf.version),
608
+ ...(!this.#opt.dev ? { ngDevMode: "false" } : {}),
609
+ "process.env.SD_VERSION": JSON.stringify(this.#pkgNpmConf.version),
587
610
  "process.env.NODE_ENV": JSON.stringify(this.#opt.dev ? "development" : "production"),
588
- ...this.#opt.env ? Object.keys(this.#opt.env).toObject(
589
- key => `process.env.${key}`,
590
- key => JSON.stringify(this.#opt.env![key])
591
- ) : {}
611
+ ...(this.#opt.env
612
+ ? Object.keys(this.#opt.env).toObject(
613
+ (key) => `process.env.${key}`,
614
+ (key) => JSON.stringify(this.#opt.env![key]),
615
+ )
616
+ : {}),
592
617
  },
593
- platform: 'node',
618
+ platform: "node",
594
619
  entryPoints: {
595
620
  "electron-main": path.resolve(this.#opt.pkgPath, "src/electron-main.ts"),
596
- }
621
+ },
597
622
  });
598
623
  }
599
624
 
600
-
601
625
  #debug(...msg: any[]): void {
602
626
  this.#logger.debug(`[${path.basename(this.#opt.pkgPath)}]`, ...msg);
603
627
  }
@@ -610,4 +634,4 @@ interface IOptions {
610
634
  builderType: string;
611
635
  env: Record<string, string> | undefined;
612
636
  cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
613
- }
637
+ }