@simplysm/sd-cli 11.1.45 → 11.1.51

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.
Files changed (53) hide show
  1. package/dist/build-cluster.js +16 -3
  2. package/dist/build-cluster.js.map +1 -1
  3. package/dist/build-tools/SdLibBundler.d.ts +13 -0
  4. package/dist/build-tools/SdLibBundler.js +51 -0
  5. package/dist/build-tools/SdLibBundler.js.map +1 -0
  6. package/dist/build-tools/SdLinter.js +4 -4
  7. package/dist/build-tools/SdLinter.js.map +1 -1
  8. package/dist/build-tools/SdNgBundler.d.ts +11 -20
  9. package/dist/build-tools/SdNgBundler.js +103 -96
  10. package/dist/build-tools/SdNgBundler.js.map +1 -1
  11. package/dist/build-tools/SdServerBundler.js.map +1 -1
  12. package/dist/build-tools/SdTsCompiler.d.ts +24 -27
  13. package/dist/build-tools/SdTsCompiler.js +237 -184
  14. package/dist/build-tools/SdTsCompiler.js.map +1 -1
  15. package/dist/builders/SdCliTsLibBuilder.d.ts +2 -6
  16. package/dist/builders/SdCliTsLibBuilder.js +30 -30
  17. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  18. package/dist/bundle-plugins/sdNgPlugin.d.ts +3 -3
  19. package/dist/bundle-plugins/sdNgPlugin.js +22 -212
  20. package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
  21. package/dist/bundle-plugins/sdServerPlugin.d.ts +2 -2
  22. package/dist/bundle-plugins/sdServerPlugin.js +17 -110
  23. package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
  24. package/dist/commons.d.ts +1 -0
  25. package/dist/entry/SdCliProject.d.ts +1 -0
  26. package/dist/entry/SdCliProject.js +14 -30
  27. package/dist/entry/SdCliProject.js.map +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/sd-cli.d.ts +1 -1
  32. package/dist/sd-cli.js +8 -2
  33. package/dist/sd-cli.js.map +1 -1
  34. package/dist/server-worker.js.map +1 -1
  35. package/dist/utils/SdCliBuildResultUtil.d.ts +10 -0
  36. package/dist/utils/SdCliBuildResultUtil.js +17 -1
  37. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  38. package/package.json +15 -15
  39. package/src/build-cluster.ts +18 -4
  40. package/src/build-tools/SdLibBundler.ts +70 -0
  41. package/src/build-tools/SdLinter.ts +4 -4
  42. package/src/build-tools/SdNgBundler.ts +120 -112
  43. package/src/build-tools/SdServerBundler.ts +2 -2
  44. package/src/build-tools/SdTsCompiler.ts +352 -241
  45. package/src/builders/SdCliTsLibBuilder.ts +33 -31
  46. package/src/bundle-plugins/sdNgPlugin.ts +26 -320
  47. package/src/bundle-plugins/sdServerPlugin.ts +20 -168
  48. package/src/commons.ts +1 -0
  49. package/src/entry/SdCliProject.ts +15 -31
  50. package/src/index.ts +1 -0
  51. package/src/sd-cli.ts +8 -2
  52. package/src/server-worker.ts +3 -3
  53. package/src/utils/SdCliBuildResultUtil.ts +22 -3
@@ -37,50 +37,49 @@ import {Entrypoint} from "@angular-devkit/build-angular/src/utils/index-file/aug
37
37
  import {CrossOrigin} from "@angular-devkit/build-angular";
38
38
  import {InlineCriticalCssProcessor} from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
39
39
  import {SdNgBundlerContext} from "./SdNgBundlerContext";
40
- import {INgResultCache, sdNgPlugin} from "../bundle-plugins/sdNgPlugin";
40
+ import {INgPluginResultCache, sdNgPlugin} from "../bundle-plugins/sdNgPlugin";
41
41
  import {MemoryLoadResultCache} from "@angular-devkit/build-angular/src/tools/esbuild/load-result-cache";
42
42
  import ts from "typescript";
43
43
 
44
44
  export class SdNgBundler {
45
45
  // private readonly _sourceFileCache = new SourceFileCache(
46
- // path.resolve(this._opt.pkgPath, ".cache")
46
+ // path.resolve(this.#opt.pkgPath, ".cache")
47
47
  // );
48
48
 
49
- #modifiedFileSet = new Set<string>();
50
- #ngResultCache: Partial<INgResultCache> = {};
51
- #styleLoadResultCache = new MemoryLoadResultCache();
49
+ readonly #modifiedFileSet = new Set<string>();
50
+ readonly #ngResultCache: INgPluginResultCache = {
51
+ affectedFileSet: new Set<string>(),
52
+ watchFileSet: new Set<string>()
53
+ };
54
+ readonly #styleLoadResultCache = new MemoryLoadResultCache();
52
55
 
53
- private _contexts: SdNgBundlerContext[] | undefined;
56
+ #contexts: SdNgBundlerContext[] | undefined;
54
57
 
55
- private readonly _outputCache = new Map<string, string | number>();
58
+ readonly #outputCache = new Map<string, string | number>();
56
59
 
57
- private readonly _pkgNpmConf: INpmConfig;
58
- private readonly _mainFilePath: string;
59
- private readonly _tsConfigFilePath: string;
60
- private readonly _swConfFilePath: string;
61
- private readonly _browserTarget: string[];
62
- private readonly _indexHtmlFilePath: string;
63
- private readonly _pkgName: string;
64
- private readonly _baseHref: string;
60
+ readonly #opt: IOptions;
61
+
62
+ readonly #pkgNpmConf: INpmConfig;
63
+ readonly #mainFilePath: string;
64
+ readonly #tsConfigFilePath: string;
65
+ readonly #swConfFilePath: string;
66
+ readonly #browserTarget: string[];
67
+ readonly #indexHtmlFilePath: string;
68
+ readonly #pkgName: string;
69
+ readonly #baseHref: string;
65
70
 
66
71
  // #loadFilePathSet = new Set<string>();
67
72
 
68
- public constructor(private readonly _opt: {
69
- dev: boolean;
70
- outputPath: string;
71
- pkgPath: string;
72
- builderType: string;
73
- env: Record<string, string> | undefined;
74
- cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
75
- }) {
76
- this._pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
77
- this._mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
78
- this._tsConfigFilePath = path.resolve(this._opt.pkgPath, "tsconfig.json");
79
- this._swConfFilePath = path.resolve(this._opt.pkgPath, "ngsw-config.json");
80
- this._browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
81
- this._indexHtmlFilePath = path.resolve(this._opt.pkgPath, "src/index.html");
82
- this._pkgName = path.basename(this._opt.pkgPath);
83
- this._baseHref = this._opt.builderType === "web" ? `/${this._pkgName}/` : this._opt.dev ? `/${this._pkgName}/${this._opt.builderType}/` : ``;
73
+ public constructor(opt: IOptions) {
74
+ this.#opt = opt;
75
+ this.#pkgNpmConf = FsUtil.readJson(path.resolve(opt.pkgPath, "package.json"));
76
+ this.#mainFilePath = path.resolve(opt.pkgPath, "src/main.ts");
77
+ this.#tsConfigFilePath = path.resolve(opt.pkgPath, "tsconfig.json");
78
+ this.#swConfFilePath = path.resolve(opt.pkgPath, "ngsw-config.json");
79
+ this.#browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
80
+ this.#indexHtmlFilePath = path.resolve(opt.pkgPath, "src/index.html");
81
+ this.#pkgName = path.basename(opt.pkgPath);
82
+ this.#baseHref = opt.builderType === "web" ? `/${this.#pkgName}/` : opt.dev ? `/${this.#pkgName}/${opt.builderType}/` : ``;
84
83
  }
85
84
 
86
85
  public markForChanges(filePaths: string[]): void {
@@ -92,25 +91,25 @@ export class SdNgBundler {
92
91
  }
93
92
 
94
93
  public async bundleAsync(): Promise<{
95
- program: ts.Program;
94
+ program?: ts.Program;
96
95
  watchFileSet: Set<string>,
97
96
  affectedFileSet: Set<string>,
98
97
  results: ISdCliPackageBuildResult[]
99
98
  }> {
100
99
  const logger = Logger.get(["simplysm", "sd-cli", "SdNgBundler", "bundleAsync"]);
101
100
 
102
- if (!this._contexts) {
103
- this._contexts = [
101
+ if (!this.#contexts) {
102
+ this.#contexts = [
104
103
  await this._getAppContextAsync(),
105
104
  this._getStyleContext(),
106
- ...this._opt.builderType === "electron" ? [
105
+ ...this.#opt.builderType === "electron" ? [
107
106
  this._getElectronMainContext()
108
107
  ] : []
109
108
  ];
110
109
  }
111
110
 
112
111
  //-- build
113
- const bundlingResults = await this._contexts.mapAsync(async ctx => await ctx.bundleAsync());
112
+ const bundlingResults = await this.#contexts.mapAsync(async ctx => await ctx.bundleAsync());
114
113
 
115
114
  //-- results
116
115
  const results = bundlingResults.mapMany(bundlingResult => bundlingResult.results);
@@ -133,7 +132,7 @@ export class SdNgBundler {
133
132
  const assetFiles: { source: string; destination: string }[] = [];
134
133
 
135
134
  //-- cordova empty
136
- if (this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins) {
135
+ if (this.#opt.builderType === "cordova" && this.#opt.cordovaConfig?.plugins) {
137
136
  outputFiles.push(createOutputFileFromText("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
138
137
  }
139
138
 
@@ -168,12 +167,12 @@ export class SdNgBundler {
168
167
  assetFiles.push(...(await this._copyAssetsAsync()));
169
168
 
170
169
  //-- extract 3rdpartylicenses
171
- if (!this._opt.dev) {
172
- outputFiles.push(createOutputFileFromText('3rdpartylicenses.txt', await extractLicenses(metafile, this._opt.pkgPath), BuildOutputFileType.Root));
170
+ if (!this.#opt.dev) {
171
+ outputFiles.push(createOutputFileFromText('3rdpartylicenses.txt', await extractLicenses(metafile, this.#opt.pkgPath), BuildOutputFileType.Root));
173
172
  }
174
173
 
175
174
  //-- service worker
176
- if (FsUtil.exists(this._swConfFilePath)) {
175
+ if (FsUtil.exists(this.#swConfFilePath)) {
177
176
  try {
178
177
  const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
179
178
  outputFiles.push(createOutputFileFromText('ngsw.json', serviceWorkerResult.manifest, BuildOutputFileType.Root));
@@ -194,26 +193,26 @@ export class SdNgBundler {
194
193
 
195
194
  //-- write
196
195
  for (const outputFile of outputFiles) {
197
- const distFilePath = path.resolve(this._opt.outputPath, outputFile.path);
198
- const prev = this._outputCache.get(distFilePath);
196
+ const distFilePath = path.resolve(this.#opt.outputPath, outputFile.path);
197
+ const prev = this.#outputCache.get(distFilePath);
199
198
  if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
200
199
  await FsUtil.writeFileAsync(distFilePath, outputFile.contents);
201
- this._outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
200
+ this.#outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
202
201
  }
203
202
  }
204
203
  for (const assetFile of assetFiles) {
205
- const prev = this._outputCache.get(assetFile.source);
204
+ const prev = this.#outputCache.get(assetFile.source);
206
205
  const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
207
206
  if (prev !== curr) {
208
- await FsUtil.copyAsync(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
209
- this._outputCache.set(assetFile.source, curr);
207
+ await FsUtil.copyAsync(assetFile.source, path.resolve(this.#opt.outputPath, assetFile.destination));
208
+ this.#outputCache.set(assetFile.source, curr);
210
209
  }
211
210
  }
212
211
 
213
- logger.debug(`[${path.basename(this._opt.pkgPath)}] 번들링중 영향받은 파일`, Array.from(this.#ngResultCache.affectedFileSet!));
212
+ logger.debug(`[${path.basename(this.#opt.pkgPath)}] 번들링중 영향받은 파일`, Array.from(this.#ngResultCache.affectedFileSet!));
214
213
 
215
214
  return {
216
- program: this.#ngResultCache.program!,
215
+ program: this.#ngResultCache.program,
217
216
  watchFileSet: new Set([
218
217
  ...this.#ngResultCache.watchFileSet!,
219
218
  ...this.#styleLoadResultCache.watchFiles
@@ -238,22 +237,22 @@ export class SdNgBundler {
238
237
  };
239
238
 
240
239
  const indexHtmlGenerator = new IndexHtmlGenerator({
241
- indexPath: this._indexHtmlFilePath,
240
+ indexPath: this.#indexHtmlFilePath,
242
241
  entrypoints: [
243
242
  ['runtime', true],
244
243
  ['polyfills', true],
245
244
  ['styles', false],
246
245
  ['vendor', true],
247
246
  ['main', true],
248
- ...this._opt.builderType === "cordova" ? [
247
+ ...this.#opt.builderType === "cordova" ? [
249
248
  ["cordova-entry", true] as Entrypoint
250
249
  ] : []
251
250
  ],
252
251
  optimization: {
253
- scripts: !this._opt.dev,
254
- fonts: {inline: !this._opt.dev},
252
+ scripts: !this.#opt.dev,
253
+ fonts: {inline: !this.#opt.dev},
255
254
  styles: {
256
- minify: !this._opt.dev,
255
+ minify: !this.#opt.dev,
257
256
  inlineCritical: false
258
257
  },
259
258
  },
@@ -262,7 +261,7 @@ export class SdNgBundler {
262
261
  indexHtmlGenerator.readAsset = readAsset;
263
262
 
264
263
  const hints: { url: string; mode: HintMode; as?: string; }[] = [];
265
- if (!this._opt.dev) {
264
+ if (!this.#opt.dev) {
266
265
  for (const [key, value] of initialFiles) {
267
266
  if (value.entrypoint) {
268
267
  continue;
@@ -278,7 +277,7 @@ export class SdNgBundler {
278
277
  }
279
278
 
280
279
  const transformResult = await indexHtmlGenerator.process({
281
- baseHref: this._baseHref,
280
+ baseHref: this.#baseHref,
282
281
  lang: undefined,
283
282
  outputPath: "/",
284
283
  files: [...initialFiles].map(([file, record]) => ({
@@ -289,7 +288,7 @@ export class SdNgBundler {
289
288
  hints,
290
289
  });
291
290
 
292
- if (this._opt.dev) {
291
+ if (this.#opt.dev) {
293
292
  return transformResult;
294
293
  }
295
294
  else {
@@ -318,7 +317,7 @@ export class SdNgBundler {
318
317
  {input: 'src', glob: 'favicon.ico', output: ''},
319
318
  {input: 'src', glob: 'manifest.webmanifest', output: ''},
320
319
  {input: 'src/assets', glob: '**/*', output: 'assets'},
321
- ...this._opt.dev && this._opt.builderType === "cordova" ? Object.keys(this._opt.cordovaConfig?.platform ?? {browser: {}}).mapMany((platform) => [
320
+ ...this.#opt.dev && this.#opt.builderType === "cordova" ? Object.keys(this.#opt.cordovaConfig?.platform ?? {browser: {}}).mapMany((platform) => [
322
321
  {
323
322
  input: `.cordova/platforms/${platform}/platform_www/plugins`,
324
323
  glob: '**/*',
@@ -340,7 +339,7 @@ export class SdNgBundler {
340
339
  output: `cordova-${platform}`
341
340
  },
342
341
  ]) : []
343
- ], [], this._opt.pkgPath);
342
+ ], [], this.#opt.pkgPath);
344
343
  }
345
344
 
346
345
  private async _genServiceWorkerAsync(
@@ -357,9 +356,9 @@ export class SdNgBundler {
357
356
  }[];
358
357
  }> {
359
358
  return await augmentAppWithServiceWorkerEsbuild(
360
- this._opt.pkgPath,
361
- this._swConfFilePath,
362
- this._baseHref,
359
+ this.#opt.pkgPath,
360
+ this.#swConfFilePath,
361
+ this.#baseHref,
363
362
  "index.html",
364
363
  outputFiles,
365
364
  assetFiles
@@ -367,8 +366,8 @@ export class SdNgBundler {
367
366
  }
368
367
 
369
368
  private async _getAppContextAsync(): Promise<SdNgBundlerContext> {
370
- return new SdNgBundlerContext(this._opt.pkgPath, {
371
- absWorkingDir: this._opt.pkgPath,
369
+ return new SdNgBundlerContext(this.#opt.pkgPath, {
370
+ absWorkingDir: this.#opt.pkgPath,
372
371
  bundle: true,
373
372
  keepNames: true,
374
373
  format: 'esm',
@@ -376,45 +375,45 @@ export class SdNgBundler {
376
375
  conditions: ['es2020', 'es2015', 'module'],
377
376
  resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
378
377
  metafile: true,
379
- legalComments: this._opt.dev ? 'eof' : 'none',
378
+ legalComments: this.#opt.dev ? 'eof' : 'none',
380
379
  logLevel: 'silent',
381
- minifyIdentifiers: !this._opt.dev,
382
- minifySyntax: !this._opt.dev,
383
- minifyWhitespace: !this._opt.dev,
380
+ minifyIdentifiers: !this.#opt.dev,
381
+ minifySyntax: !this.#opt.dev,
382
+ minifyWhitespace: !this.#opt.dev,
384
383
  pure: ['forwardRef'],
385
- outdir: this._opt.pkgPath,
384
+ outdir: this.#opt.pkgPath,
386
385
  outExtension: undefined,
387
- sourcemap: true, //this._opt.dev,
386
+ sourcemap: true, //this.#opt.dev,
388
387
  splitting: true,
389
388
  chunkNames: 'chunk-[hash]',
390
- tsconfig: this._tsConfigFilePath,
389
+ tsconfig: this.#tsConfigFilePath,
391
390
  write: false,
392
391
  preserveSymlinks: false,
393
392
  define: {
394
- ...!this._opt.dev ? {ngDevMode: 'false'} : {},
393
+ ...!this.#opt.dev ? {ngDevMode: 'false'} : {},
395
394
  ngJitMode: 'false',
396
395
  global: 'global',
397
396
  process: 'process',
398
397
  Buffer: 'Buffer',
399
- 'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
400
- "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
401
- ...this._opt.env ? Object.keys(this._opt.env).toObject(
398
+ 'process.env.SD_VERSION': JSON.stringify(this.#pkgNpmConf.version),
399
+ "process.env.NODE_ENV": JSON.stringify(this.#opt.dev ? "development" : "production"),
400
+ ...this.#opt.env ? Object.keys(this.#opt.env).toObject(
402
401
  key => `process.env.${key}`,
403
- key => JSON.stringify(this._opt.env![key])
402
+ key => JSON.stringify(this.#opt.env![key])
404
403
  ) : {}
405
404
  },
406
405
  platform: 'browser',
407
406
  mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
408
407
  entryNames: '[name]',
409
408
  entryPoints: {
410
- main: this._mainFilePath,
409
+ main: this.#mainFilePath,
411
410
  // polyfills: 'angular:polyfills',
412
- polyfills: path.resolve(this._opt.pkgPath, "src/polyfills.ts"),
413
- ...this._opt.builderType === "cordova" ? {
411
+ polyfills: path.resolve(this.#opt.pkgPath, "src/polyfills.ts"),
412
+ ...this.#opt.builderType === "cordova" ? {
414
413
  "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
415
414
  } : {}
416
415
  },
417
- target: this._browserTarget,
416
+ target: this.#browserTarget,
418
417
  supported: {'async-await': false, 'object-rest-spread': false},
419
418
  loader: {
420
419
  ".png": "file",
@@ -442,10 +441,10 @@ export class SdNgBundler {
442
441
  },
443
442
  inject: [PathUtil.posix(fileURLToPath(await import.meta.resolve!("node-stdlib-browser/helpers/esbuild/shim")))],
444
443
  plugins: [
445
- ...this._opt.builderType === "cordova" && this._opt.cordovaConfig?.plugins ? [{
444
+ ...this.#opt.builderType === "cordova" && this.#opt.cordovaConfig?.plugins ? [{
446
445
  name: "cordova:plugin-empty",
447
446
  setup: ({onResolve}) => {
448
- onResolve({filter: new RegExp("(" + this._opt.cordovaConfig!.plugins!.join("|") + ")")}, () => {
447
+ onResolve({filter: new RegExp("(" + this.#opt.cordovaConfig!.plugins!.join("|") + ")")}, () => {
449
448
  return {
450
449
  path: `./cordova-empty.js`,
451
450
  external: true
@@ -458,18 +457,18 @@ export class SdNgBundler {
458
457
  // loadContent: () => ({
459
458
  // contents: `import "./src/polyfills.ts";`,
460
459
  // loader: 'js',
461
- // resolveDir: this._opt.pkgPath
460
+ // resolveDir: this.#opt.pkgPath
462
461
  // })
463
462
  // }) as esbuild.Plugin,
464
463
  createSourcemapIgnorelistPlugin(),
465
464
  sdNgPlugin({
466
465
  modifiedFileSet: this.#modifiedFileSet,
467
- dev: this._opt.dev,
468
- pkgPath: this._opt.pkgPath,
466
+ dev: this.#opt.dev,
467
+ pkgPath: this.#opt.pkgPath,
469
468
  result: this.#ngResultCache
470
469
  }),
471
470
  // createCompilerPlugin({
472
- // sourcemap: this._opt.dev,
471
+ // sourcemap: this.#opt.dev,
473
472
  // tsconfig: this._tsConfigFilePath,
474
473
  // jit: false,
475
474
  // advancedOptimizations: true,
@@ -477,11 +476,11 @@ export class SdNgBundler {
477
476
  // fileReplacements: undefined,
478
477
  // sourceFileCache: this._sourceFileCache,
479
478
  // loadResultCache: this._sourceFileCache.loadResultCache,
480
- // incremental: this._opt.dev
479
+ // incremental: this.#opt.dev
481
480
  // }, {
482
- // workspaceRoot: this._opt.pkgPath,
483
- // optimization: !this._opt.dev,
484
- // sourcemap: this._opt.dev ? 'inline' : false,
481
+ // workspaceRoot: this.#opt.pkgPath,
482
+ // optimization: !this.#opt.dev,
483
+ // sourcemap: this.#opt.dev ? 'inline' : false,
485
484
  // outputNames: {bundles: '[name]', media: 'media/[name]'},
486
485
  // includePaths: [],
487
486
  // externalDependencies: [],
@@ -507,33 +506,33 @@ export class SdNgBundler {
507
506
  private _getStyleContext(): SdNgBundlerContext {
508
507
  const pluginFactory = new StylesheetPluginFactory(
509
508
  {
510
- sourcemap: true, //this._opt.dev,
509
+ sourcemap: true, //this.#opt.dev,
511
510
  includePaths: []
512
511
  },
513
512
  this.#styleLoadResultCache,
514
513
  );
515
514
 
516
- return new SdNgBundlerContext(this._opt.pkgPath, {
517
- absWorkingDir: this._opt.pkgPath,
515
+ return new SdNgBundlerContext(this.#opt.pkgPath, {
516
+ absWorkingDir: this.#opt.pkgPath,
518
517
  bundle: true,
519
518
  entryNames: '[name]',
520
519
  assetNames: 'media/[name]',
521
520
  logLevel: 'silent',
522
- minify: !this._opt.dev,
521
+ minify: !this.#opt.dev,
523
522
  metafile: true,
524
- sourcemap: true, //this._opt.dev,
525
- outdir: this._opt.pkgPath,
523
+ sourcemap: true, //this.#opt.dev,
524
+ outdir: this.#opt.pkgPath,
526
525
  write: false,
527
526
  platform: 'browser',
528
- target: this._browserTarget,
527
+ target: this.#browserTarget,
529
528
  preserveSymlinks: false,
530
529
  external: [],
531
530
  conditions: ['style', 'sass'],
532
531
  mainFields: ['style', 'sass'],
533
- legalComments: !this._opt.dev ? "none" : "eof",
532
+ legalComments: !this.#opt.dev ? "none" : "eof",
534
533
  entryPoints: {
535
534
  // styles: 'angular:styles/global;styles'
536
- styles: path.resolve(this._opt.pkgPath, "src/styles.scss")
535
+ styles: path.resolve(this.#opt.pkgPath, "src/styles.scss")
537
536
  },
538
537
  plugins: [
539
538
  // createVirtualModulePlugin({
@@ -542,7 +541,7 @@ export class SdNgBundler {
542
541
  // loadContent: () => ({
543
542
  // contents: `@import 'src/styles.scss';`,
544
543
  // loader: 'css',
545
- // resolveDir: this._opt.pkgPath
544
+ // resolveDir: this.#opt.pkgPath
546
545
  // }),
547
546
  // }) as esbuild.Plugin,
548
547
  pluginFactory.create(SassStylesheetLanguage) as esbuild.Plugin,
@@ -553,36 +552,45 @@ export class SdNgBundler {
553
552
  }
554
553
 
555
554
  private _getElectronMainContext() {
556
- return new SdNgBundlerContext(this._opt.pkgPath, {
557
- absWorkingDir: this._opt.pkgPath,
555
+ return new SdNgBundlerContext(this.#opt.pkgPath, {
556
+ absWorkingDir: this.#opt.pkgPath,
558
557
  bundle: true,
559
558
  entryNames: '[name]',
560
559
  assetNames: 'media/[name]',
561
560
  conditions: ['es2020', 'es2015', 'module'],
562
561
  resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
563
562
  metafile: true,
564
- legalComments: this._opt.dev ? 'eof' : 'none',
563
+ legalComments: this.#opt.dev ? 'eof' : 'none',
565
564
  logLevel: 'silent',
566
- minify: !this._opt.dev,
567
- outdir: this._opt.pkgPath,
568
- sourcemap: true, //this._opt.dev,
569
- tsconfig: this._tsConfigFilePath,
565
+ minify: !this.#opt.dev,
566
+ outdir: this.#opt.pkgPath,
567
+ sourcemap: true, //this.#opt.dev,
568
+ tsconfig: this.#tsConfigFilePath,
570
569
  write: false,
571
570
  preserveSymlinks: false,
572
571
  external: ["electron"],
573
572
  define: {
574
- ...!this._opt.dev ? {ngDevMode: 'false'} : {},
575
- 'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
576
- "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
577
- ...this._opt.env ? Object.keys(this._opt.env).toObject(
573
+ ...!this.#opt.dev ? {ngDevMode: 'false'} : {},
574
+ 'process.env.SD_VERSION': JSON.stringify(this.#pkgNpmConf.version),
575
+ "process.env.NODE_ENV": JSON.stringify(this.#opt.dev ? "development" : "production"),
576
+ ...this.#opt.env ? Object.keys(this.#opt.env).toObject(
578
577
  key => `process.env.${key}`,
579
- key => JSON.stringify(this._opt.env![key])
578
+ key => JSON.stringify(this.#opt.env![key])
580
579
  ) : {}
581
580
  },
582
581
  platform: 'node',
583
582
  entryPoints: {
584
- "electron-main": path.resolve(this._opt.pkgPath, "src/electron-main.ts"),
583
+ "electron-main": path.resolve(this.#opt.pkgPath, "src/electron-main.ts"),
585
584
  }
586
585
  });
587
586
  }
587
+ }
588
+
589
+ interface IOptions {
590
+ dev: boolean;
591
+ outputPath: string;
592
+ pkgPath: string;
593
+ builderType: string;
594
+ env: Record<string, string> | undefined;
595
+ cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
588
596
  }
@@ -1,7 +1,7 @@
1
1
  import {ISdCliPackageBuildResult} from "../commons";
2
2
  import esbuild from "esbuild";
3
3
  import path from "path";
4
- import {IServerBundlerResultCache, sdServerPlugin} from "../bundle-plugins/sdServerPlugin";
4
+ import {IServerPluginResultCache, sdServerPlugin} from "../bundle-plugins/sdServerPlugin";
5
5
  import ts from "typescript";
6
6
  import {Logger} from "@simplysm/sd-core-node";
7
7
 
@@ -11,7 +11,7 @@ export class SdServerBundler {
11
11
  #context?: esbuild.BuildContext;
12
12
 
13
13
  #modifiedFileSet = new Set<string>();
14
- #resultCache: Partial<IServerBundlerResultCache> = {};
14
+ #resultCache: IServerPluginResultCache = {};
15
15
 
16
16
  constructor(private readonly _opt: {
17
17
  dev: boolean;