@simplysm/sd-cli 11.0.12 → 11.0.14

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 (35) hide show
  1. package/dist/build-tools/SdLinter.js +2 -2
  2. package/dist/build-tools/SdLinter.js.map +1 -1
  3. package/dist/build-tools/SdNgBundler.d.ts +2 -3
  4. package/dist/build-tools/SdNgBundler.js +59 -74
  5. package/dist/build-tools/SdNgBundler.js.map +1 -1
  6. package/dist/build-tools/SdNgBundlerContext.d.ts +16 -0
  7. package/dist/build-tools/SdNgBundlerContext.js +98 -0
  8. package/dist/build-tools/SdNgBundlerContext.js.map +1 -0
  9. package/dist/build-tools/SdTsBundler.js +4 -4
  10. package/dist/build-tools/SdTsBundler.js.map +1 -1
  11. package/dist/builders/SdCliClientBuilder.js +2 -2
  12. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  13. package/dist/entry/SdCliProject.js +20 -15
  14. package/dist/entry/SdCliProject.js.map +1 -1
  15. package/dist/index.d.ts +1 -0
  16. package/dist/index.js +1 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/utils/SdCliBuildResultUtil.js +3 -3
  19. package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
  20. package/dist/utils/SdMemoryLoadResultCache.js +1 -5
  21. package/dist/utils/SdMemoryLoadResultCache.js.map +1 -1
  22. package/dist/utils/SdSourceFileCache.d.ts +2 -1
  23. package/dist/utils/SdSourceFileCache.js +7 -1
  24. package/dist/utils/SdSourceFileCache.js.map +1 -1
  25. package/package.json +11 -11
  26. package/src/build-tools/SdLinter.ts +2 -2
  27. package/src/build-tools/SdNgBundler.ts +215 -234
  28. package/src/build-tools/SdNgBundlerContext.ts +116 -0
  29. package/src/build-tools/SdTsBundler.ts +4 -4
  30. package/src/builders/SdCliClientBuilder.ts +2 -2
  31. package/src/entry/SdCliProject.ts +22 -15
  32. package/src/index.ts +1 -0
  33. package/src/utils/SdCliBuildResultUtil.ts +3 -3
  34. package/src/utils/SdMemoryLoadResultCache.ts +1 -5
  35. package/src/utils/SdSourceFileCache.ts +9 -1
@@ -1,7 +1,7 @@
1
1
  import {createCompilerPlugin} from "@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin";
2
2
  import path from "path";
3
- import {BundlerContext, InitialFileRecord} from "@angular-devkit/build-angular/src/tools/esbuild/bundler-context";
4
- import esbuild from "esbuild";
3
+ import {InitialFileRecord} from "@angular-devkit/build-angular/src/tools/esbuild/bundler-context";
4
+ import esbuild, {Metafile} from "esbuild";
5
5
  import {FsUtil, PathUtil} from "@simplysm/sd-core-node";
6
6
  import {fileURLToPath} from "url";
7
7
  import {createVirtualModulePlugin} from "@angular-devkit/build-angular/src/tools/esbuild/virtual-module-plugin";
@@ -10,13 +10,15 @@ import {
10
10
  } from "@angular-devkit/build-angular/src/tools/esbuild/sourcemap-ignorelist-plugin";
11
11
  import nodeStdLibBrowser from "node-stdlib-browser";
12
12
  import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
13
- import {ExecutionResult} from "@angular-devkit/build-angular/src/tools/esbuild/bundler-execution-result";
14
- import {INpmConfig, ISdCliPackageBuildResult} from "../commons";
13
+ import {INpmConfig, ISdCliClientBuilderCordovaConfig, ISdCliPackageBuildResult} from "../commons";
15
14
  import {copyAssets} from "@angular-devkit/build-angular/src/utils/copy-assets";
16
15
  import {extractLicenses} from "@angular-devkit/build-angular/src/tools/esbuild/license-extractor";
17
16
  import {augmentAppWithServiceWorkerEsbuild} from "@angular-devkit/build-angular/src/utils/service-worker";
18
17
  import browserslist from "browserslist";
19
- import {transformSupportedBrowsersToTargets} from "@angular-devkit/build-angular/src/tools/esbuild/utils";
18
+ import {
19
+ createOutputFileFromText,
20
+ transformSupportedBrowsersToTargets
21
+ } from "@angular-devkit/build-angular/src/tools/esbuild/utils";
20
22
  import {createCssResourcePlugin} from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-resource-plugin";
21
23
  import {CssStylesheetLanguage} from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-language";
22
24
  import {SassStylesheetLanguage} from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/sass-language";
@@ -32,11 +34,14 @@ import {Entrypoint} from "@angular-devkit/build-angular/src/utils/index-file/aug
32
34
  import {CrossOrigin} from "@angular-devkit/build-angular";
33
35
  import {InlineCriticalCssProcessor} from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
34
36
  import {SdSourceFileCache} from "../utils/SdSourceFileCache";
37
+ import {SdNgBundlerContext} from "./SdNgBundlerContext";
35
38
 
36
39
  export class SdNgBundler {
37
- private readonly _sourceFileCache = new SdSourceFileCache();
40
+ private readonly _sourceFileCache = new SdSourceFileCache(
41
+ path.resolve(this._opt.pkgPath, ".cache")
42
+ );
38
43
 
39
- private _contexts: BundlerContext[] | undefined;
44
+ private _contexts: SdNgBundlerContext[] | undefined;
40
45
 
41
46
  private readonly _outputCache = new Map<string, string | number>();
42
47
 
@@ -49,15 +54,13 @@ export class SdNgBundler {
49
54
  private readonly _pkgName: string;
50
55
  private readonly _baseHref: string;
51
56
 
52
- private _depsMap?: Map<string, Set<string>>;
53
-
54
57
  public constructor(private readonly _opt: {
55
58
  dev: boolean;
56
59
  outputPath: string;
57
60
  pkgPath: string;
58
61
  builderType: string;
59
- cordovaPlatforms: string[] | undefined;
60
62
  env: Record<string, string> | undefined;
63
+ cordovaConfig: ISdCliClientBuilderCordovaConfig | undefined;
61
64
  }) {
62
65
  this._pkgNpmConf = FsUtil.readJson(path.resolve(this._opt.pkgPath, "package.json"));
63
66
  this._mainFilePath = path.resolve(this._opt.pkgPath, "src/main.ts");
@@ -85,28 +88,10 @@ export class SdNgBundler {
85
88
  }
86
89
 
87
90
  //-- build
88
- const bundlingResult = await BundlerContext.bundleAll(this._contexts);
91
+ const bundlingResults = await this._contexts.mapAsync(async ctx => await ctx.bundleAsync());
92
+
93
+ const results = bundlingResults.mapMany(bundlingResult => bundlingResult.results);
89
94
 
90
- const results = [
91
- ...bundlingResult.warnings.map((warn) => ({
92
- filePath: warn.location?.file !== undefined ? path.resolve(this._opt.pkgPath, warn.location.file) : undefined,
93
- line: warn.location?.line,
94
- char: warn.location?.column,
95
- code: undefined,
96
- severity: "warning",
97
- message: warn.text.replace(/^(NG|TS)[0-9]+: /, ""),
98
- type: "build"
99
- })),
100
- ...bundlingResult.errors?.map((err) => ({
101
- filePath: err.location?.file !== undefined ? path.resolve(this._opt.pkgPath, err.location.file) : undefined,
102
- line: err.location?.line,
103
- char: err.location?.column !== undefined ? err.location.column + 1 : undefined,
104
- code: undefined,
105
- severity: "error",
106
- message: err.text.replace(/^[^:]*: /, ""),
107
- type: "build"
108
- })) ?? []
109
- ] as ISdCliPackageBuildResult[];
110
95
  const watchFilePaths = [
111
96
  ...this._sourceFileCache.keys(),
112
97
  ...this._sourceFileCache.babelFileCache.keys(),
@@ -115,36 +100,34 @@ export class SdNgBundler {
115
100
 
116
101
  let affectedSourceFilePaths = watchFilePaths.filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
117
102
 
118
- if (bundlingResult.errors) {
119
- // TODO: 제대로 deps를 적용해야함.. 코드 분석 필요
120
- this._depsMap = this._depsMap ?? new Map<string, Set<string>>();
121
- }
122
- else {
123
- this._depsMap = new Map<string, Set<string>>();
124
- for (const entry of Object.entries(bundlingResult.metafile.inputs)) {
125
- for (const imp of entry[1].imports) {
126
- const deps = this._depsMap.getOrCreate(path.resolve(this._opt.pkgPath, imp.path), new Set<string>());
127
- deps.add(path.resolve(this._opt.pkgPath, entry[0]));
103
+ if (this._sourceFileCache.modifiedFiles.size > 0) {
104
+ const depMap = new Map<string, Set<string>>();
105
+ for (const bundlingResult of bundlingResults) {
106
+ for (const [k, v] of bundlingResult.dependencyMap) {
107
+ const currSet = depMap.getOrCreate(k, new Set<string>());
108
+ currSet.adds(...v);
128
109
  }
129
110
  }
130
- }
111
+ for (const [k, v] of this._sourceFileCache.loadResultCache.fileDependencies) {
112
+ const currSet = depMap.getOrCreate(k, new Set<string>());
113
+ currSet.adds(...Array.from(v).map((item) => item.startsWith("file:") ? fileURLToPath(item) : undefined).filterExists());
114
+ }
131
115
 
132
- const searchAffectedFiles = (filePath: string, prev?: Set<string>): Set<string> => {
133
- const result = new Set<string>(prev);
116
+ const searchAffectedFiles = (filePath: string, prev?: Set<string>): Set<string> => {
117
+ const result = new Set<string>(prev);
134
118
 
135
- const importerPaths = this._depsMap!.get(filePath);
136
- if (!importerPaths) return result;
119
+ const importerPaths = depMap.get(filePath);
120
+ if (!importerPaths) return result;
137
121
 
138
- for (const importerPath of importerPaths) {
139
- if (result.has(importerPath)) continue;
140
- result.adds(importerPath);
141
- result.adds(...searchAffectedFiles(importerPath, result));
142
- }
122
+ for (const importerPath of importerPaths) {
123
+ if (result.has(importerPath)) continue;
124
+ result.adds(importerPath);
125
+ result.adds(...searchAffectedFiles(importerPath, result));
126
+ }
143
127
 
144
- return result;
145
- };
128
+ return result;
129
+ };
146
130
 
147
- if (this._sourceFileCache.modifiedFiles.size > 0) {
148
131
  const affectedFilePathSet = new Set<string>();
149
132
  for (const modFile of this._sourceFileCache.modifiedFiles) {
150
133
  affectedFilePathSet.add(path.resolve(modFile));
@@ -153,16 +136,26 @@ export class SdNgBundler {
153
136
  affectedSourceFilePaths = Array.from(affectedFilePathSet.values()).filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
154
137
  }
155
138
 
156
- if (bundlingResult.errors) {
157
- return {
158
- filePaths: watchFilePaths,
159
- affectedFilePaths: affectedSourceFilePaths,
160
- results
161
- };
162
- }
163
139
 
164
- const executionResult = new ExecutionResult(this._contexts, this._sourceFileCache);
165
- executionResult.outputFiles.push(...bundlingResult.outputFiles);
140
+ /*const executionResult = new ExecutionResult(this._contexts, this._sourceFileCache);
141
+ executionResult.outputFiles.push(...bundlingResult.outputFiles);*/
142
+
143
+
144
+ const outputFiles = bundlingResults.mapMany(item => item.outputFiles ?? []);
145
+ const initialFiles = new Map<string, InitialFileRecord>();
146
+ const metafile: {
147
+ inputs: Metafile["inputs"],
148
+ outputs: Metafile["outputs"]
149
+ } = {
150
+ inputs: {},
151
+ outputs: {}
152
+ };
153
+ for (const bundlingResult of bundlingResults) {
154
+ bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
155
+ metafile.inputs = {...metafile.inputs, ...bundlingResult.metafile?.inputs};
156
+ metafile.outputs = {...metafile.outputs, ...bundlingResult.metafile?.outputs};
157
+ }
158
+ const assetFiles: { source: string; destination: string }[] = [];
166
159
 
167
160
  //-- Check commonjs
168
161
  // if (!this._opt.dev) {
@@ -181,10 +174,8 @@ export class SdNgBundler {
181
174
  // }
182
175
 
183
176
  //-- index
184
- const genIndexHtmlResult = await this._genIndexHtmlAsync(
185
- bundlingResult.outputFiles,
186
- bundlingResult.initialFiles
187
- );
177
+
178
+ const genIndexHtmlResult = await this._genIndexHtmlAsync(outputFiles, initialFiles);
188
179
  for (const warning of genIndexHtmlResult.warnings) {
189
180
  results.push({
190
181
  filePath: undefined,
@@ -192,7 +183,7 @@ export class SdNgBundler {
192
183
  char: undefined,
193
184
  code: undefined,
194
185
  severity: "warning",
195
- message: warning,
186
+ message: `(gen-index) ${warning}`,
196
187
  type: "build",
197
188
  });
198
189
  }
@@ -203,29 +194,26 @@ export class SdNgBundler {
203
194
  char: undefined,
204
195
  code: undefined,
205
196
  severity: "error",
206
- message: error,
197
+ message: `(gen-index) ${error}`,
207
198
  type: "build",
208
199
  });
209
200
  }
210
- executionResult.addOutputFile("index.html", genIndexHtmlResult.content);
201
+ outputFiles.push(createOutputFileFromText("index.html", genIndexHtmlResult.content));
211
202
 
212
203
  //-- copy assets
213
- executionResult.assetFiles.push(...(await this._copyAssetsAsync()));
204
+ assetFiles.push(...(await this._copyAssetsAsync()));
214
205
 
215
206
  //-- extract 3rdpartylicenses
216
207
  if (!this._opt.dev) {
217
- executionResult.addOutputFile('3rdpartylicenses.txt', await extractLicenses(bundlingResult.metafile, this._opt.pkgPath));
208
+ outputFiles.push(createOutputFileFromText('3rdpartylicenses.txt', await extractLicenses(metafile, this._opt.pkgPath)));
218
209
  }
219
210
 
220
211
  //-- service worker
221
212
  if (FsUtil.exists(this._swConfFilePath)) {
222
213
  try {
223
- const serviceWorkerResult = await this._genServiceWorkerAsync(
224
- executionResult.outputFiles,
225
- executionResult.assetFiles
226
- );
227
- executionResult.addOutputFile('ngsw.json', serviceWorkerResult.manifest);
228
- executionResult.assetFiles.push(...serviceWorkerResult.assetFiles);
214
+ const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
215
+ outputFiles.push(createOutputFileFromText('ngsw.json', serviceWorkerResult.manifest));
216
+ assetFiles.push(...serviceWorkerResult.assetFiles);
229
217
  }
230
218
  catch (err) {
231
219
  results.push({
@@ -234,14 +222,14 @@ export class SdNgBundler {
234
222
  char: undefined,
235
223
  code: undefined,
236
224
  severity: "error",
237
- message: err.toString(),
225
+ message: `(gen-sw) ${err.toString()}`,
238
226
  type: "build",
239
227
  });
240
228
  }
241
229
  }
242
230
 
243
231
  //-- write
244
- for (const outputFile of executionResult.outputFiles) {
232
+ for (const outputFile of outputFiles) {
245
233
  const distFilePath = path.resolve(this._opt.outputPath, outputFile.path);
246
234
 
247
235
  const prev = this._outputCache.get(distFilePath);
@@ -250,7 +238,7 @@ export class SdNgBundler {
250
238
  this._outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
251
239
  }
252
240
  }
253
- for (const assetFile of executionResult.assetFiles) {
241
+ for (const assetFile of assetFiles) {
254
242
  const prev = this._outputCache.get(assetFile.source);
255
243
  const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
256
244
  if (prev !== curr) {
@@ -361,7 +349,7 @@ export class SdNgBundler {
361
349
  {input: 'src', glob: 'favicon.ico', output: ''},
362
350
  {input: 'src', glob: 'manifest.webmanifest', output: ''},
363
351
  {input: 'src/assets', glob: '**/*', output: 'assets'},
364
- ...this._opt.dev && this._opt.cordovaPlatforms ? this._opt.cordovaPlatforms.mapMany((platform) => [
352
+ ...this._opt.dev && this._opt.builderType === "cordova" ? Object.keys(this._opt.cordovaConfig?.platform ?? {browser: {}}).mapMany((platform) => [
365
353
  {
366
354
  input: `.cordova/platforms/${platform}/platform_www/plugins`,
367
355
  glob: '**/*',
@@ -408,122 +396,120 @@ export class SdNgBundler {
408
396
  );
409
397
  }
410
398
 
411
- private async _getAppContextAsync(): Promise<BundlerContext> {
412
- return new BundlerContext(
413
- this._opt.pkgPath,
414
- true,
415
- {
416
- absWorkingDir: this._opt.pkgPath,
417
- bundle: true,
418
- keepNames: true,
419
- format: 'esm',
420
- assetNames: 'media/[name]',
421
- conditions: ['es2020', 'es2015', 'module'],
422
- resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
423
- metafile: true,
424
- legalComments: this._opt.dev ? 'eof' : 'none',
425
- logLevel: 'silent',
426
- minifyIdentifiers: !this._opt.dev,
427
- minifySyntax: !this._opt.dev,
428
- minifyWhitespace: !this._opt.dev,
429
- pure: ['forwardRef'],
430
- outdir: this._opt.pkgPath,
431
- outExtension: undefined,
432
- sourcemap: this._opt.dev,
433
- splitting: true,
434
- chunkNames: 'chunk-[hash]',
435
- tsconfig: this._tsConfigFilePath,
436
- external: [],
437
- write: false,
438
- preserveSymlinks: false,
439
- define: {
440
- ...!this._opt.dev ? {ngDevMode: 'false'} : {},
441
- ngJitMode: 'false',
442
- global: 'global',
443
- process: 'process',
444
- Buffer: 'Buffer',
445
- 'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
446
- "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
447
- ...this._opt.env ? Object.keys(this._opt.env).toObject(
448
- key => `process.env.${key}`,
449
- key => JSON.stringify(this._opt.env![key])
450
- ) : {}
451
- },
452
- platform: 'browser',
453
- mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
454
- entryNames: '[name]',
455
- entryPoints: {
456
- main: this._mainFilePath,
457
- polyfills: 'angular:polyfills',
458
- ...this._opt.builderType === "cordova" ? {
459
- "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
460
- } : {}
461
- },
462
- target: this._browserTarget,
463
- supported: {'async-await': false, 'object-rest-spread': false},
464
- loader: {
465
- ".png": "file",
466
- ".jpeg": "file",
467
- ".jpg": "file",
468
- ".jfif": "file",
469
- ".gif": "file",
470
- ".svg": "file",
471
- ".woff": "file",
472
- ".woff2": "file",
473
- ".ttf": "file",
474
- ".eot": "file",
475
- ".ico": "file",
476
- ".otf": "file",
477
- ".csv": "file",
478
- ".xlsx": "file",
479
- ".xls": "file",
480
- ".pptx": "file",
481
- ".ppt": "file",
482
- ".docx": "file",
483
- ".doc": "file",
484
- ".zip": "file",
485
- ".pfx": "file",
486
- ".pkl": "file"
487
- },
488
- inject: [PathUtil.posix(fileURLToPath(await import.meta.resolve!("node-stdlib-browser/helpers/esbuild/shim")))],
489
- plugins: [
490
- createVirtualModulePlugin({
491
- namespace: "angular:polyfills",
492
- loadContent: () => ({
493
- contents: `import "./src/polyfills.ts";`,
494
- loader: 'js',
495
- resolveDir: this._opt.pkgPath
496
- })
497
- }) as esbuild.Plugin,
498
- createSourcemapIgnorelistPlugin(),
499
- createCompilerPlugin({
500
- sourcemap: this._opt.dev,
501
- thirdPartySourcemaps: false,
502
- tsconfig: this._tsConfigFilePath,
503
- jit: false,
504
- advancedOptimizations: true,
505
- fileReplacements: undefined,
506
- sourceFileCache: this._sourceFileCache,
507
- loadResultCache: this._sourceFileCache.loadResultCache
508
- }, {
509
- workspaceRoot: this._opt.pkgPath,
510
- optimization: !this._opt.dev,
511
- sourcemap: this._opt.dev ? 'inline' : false,
512
- outputNames: {bundles: '[name]', media: 'media/[name]'},
513
- includePaths: [],
514
- externalDependencies: [],
515
- target: this._browserTarget,
516
- inlineStyleLanguage: 'scss',
517
- preserveSymlinks: false,
518
- tailwindConfiguration: undefined
519
- }) as esbuild.Plugin,
520
- nodeStdLibBrowserPlugin(nodeStdLibBrowser)
521
- ]
522
- }
523
- );
399
+ private async _getAppContextAsync(): Promise<SdNgBundlerContext> {
400
+ return new SdNgBundlerContext(this._opt.pkgPath, {
401
+ absWorkingDir: this._opt.pkgPath,
402
+ bundle: true,
403
+ keepNames: true,
404
+ format: 'esm',
405
+ assetNames: 'media/[name]',
406
+ conditions: ['es2020', 'es2015', 'module'],
407
+ resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
408
+ metafile: true,
409
+ legalComments: this._opt.dev ? 'eof' : 'none',
410
+ logLevel: 'silent',
411
+ minifyIdentifiers: !this._opt.dev,
412
+ minifySyntax: !this._opt.dev,
413
+ minifyWhitespace: !this._opt.dev,
414
+ pure: ['forwardRef'],
415
+ outdir: this._opt.pkgPath,
416
+ outExtension: undefined,
417
+ sourcemap: this._opt.dev,
418
+ splitting: true,
419
+ chunkNames: 'chunk-[hash]',
420
+ tsconfig: this._tsConfigFilePath,
421
+ external: [
422
+ ...this._opt.cordovaConfig?.plugins ?? []
423
+ ],
424
+ write: false,
425
+ preserveSymlinks: false,
426
+ define: {
427
+ ...!this._opt.dev ? {ngDevMode: 'false'} : {},
428
+ ngJitMode: 'false',
429
+ global: 'global',
430
+ process: 'process',
431
+ Buffer: 'Buffer',
432
+ 'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
433
+ "process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
434
+ ...this._opt.env ? Object.keys(this._opt.env).toObject(
435
+ key => `process.env.${key}`,
436
+ key => JSON.stringify(this._opt.env![key])
437
+ ) : {}
438
+ },
439
+ platform: 'browser',
440
+ mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
441
+ entryNames: '[name]',
442
+ entryPoints: {
443
+ main: this._mainFilePath,
444
+ polyfills: 'angular:polyfills',
445
+ ...this._opt.builderType === "cordova" ? {
446
+ "cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
447
+ } : {}
448
+ },
449
+ target: this._browserTarget,
450
+ supported: {'async-await': false, 'object-rest-spread': false},
451
+ loader: {
452
+ ".png": "file",
453
+ ".jpeg": "file",
454
+ ".jpg": "file",
455
+ ".jfif": "file",
456
+ ".gif": "file",
457
+ ".svg": "file",
458
+ ".woff": "file",
459
+ ".woff2": "file",
460
+ ".ttf": "file",
461
+ ".eot": "file",
462
+ ".ico": "file",
463
+ ".otf": "file",
464
+ ".csv": "file",
465
+ ".xlsx": "file",
466
+ ".xls": "file",
467
+ ".pptx": "file",
468
+ ".ppt": "file",
469
+ ".docx": "file",
470
+ ".doc": "file",
471
+ ".zip": "file",
472
+ ".pfx": "file",
473
+ ".pkl": "file"
474
+ },
475
+ inject: [PathUtil.posix(fileURLToPath(await import.meta.resolve!("node-stdlib-browser/helpers/esbuild/shim")))],
476
+ plugins: [
477
+ createVirtualModulePlugin({
478
+ namespace: "angular:polyfills",
479
+ loadContent: () => ({
480
+ contents: `import "./src/polyfills.ts";`,
481
+ loader: 'js',
482
+ resolveDir: this._opt.pkgPath
483
+ })
484
+ }) as esbuild.Plugin,
485
+ createSourcemapIgnorelistPlugin(),
486
+ createCompilerPlugin({
487
+ sourcemap: this._opt.dev,
488
+ thirdPartySourcemaps: false,
489
+ tsconfig: this._tsConfigFilePath,
490
+ jit: false,
491
+ advancedOptimizations: true,
492
+ fileReplacements: undefined,
493
+ sourceFileCache: this._sourceFileCache,
494
+ loadResultCache: this._sourceFileCache.loadResultCache
495
+ }, {
496
+ workspaceRoot: this._opt.pkgPath,
497
+ optimization: !this._opt.dev,
498
+ sourcemap: this._opt.dev ? 'inline' : false,
499
+ outputNames: {bundles: '[name]', media: 'media/[name]'},
500
+ includePaths: [],
501
+ externalDependencies: [],
502
+ target: this._browserTarget,
503
+ inlineStyleLanguage: 'scss',
504
+ preserveSymlinks: false,
505
+ tailwindConfiguration: undefined
506
+ }) as esbuild.Plugin,
507
+ nodeStdLibBrowserPlugin(nodeStdLibBrowser)
508
+ ]
509
+ });
524
510
  }
525
511
 
526
- private _getStyleContext(): BundlerContext {
512
+ private _getStyleContext(): SdNgBundlerContext {
527
513
  const browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
528
514
 
529
515
  const pluginFactory = new StylesheetPluginFactory(
@@ -534,44 +520,39 @@ export class SdNgBundler {
534
520
  this._sourceFileCache.loadResultCache,
535
521
  );
536
522
 
537
- return new BundlerContext(
538
- this._opt.pkgPath,
539
- true,
540
- {
541
- absWorkingDir: this._opt.pkgPath,
542
- bundle: true,
543
- entryNames: '[name]',
544
- assetNames: 'media/[name]',
545
- logLevel: 'silent',
546
- minify: !this._opt.dev,
547
- metafile: true,
548
- sourcemap: this._opt.dev,
549
- outdir: this._opt.pkgPath,
550
- write: false,
551
- platform: 'browser',
552
- target: browserTarget,
553
- preserveSymlinks: false,
554
- external: [],
555
- conditions: ['style', 'sass'],
556
- mainFields: ['style', 'sass'],
557
- legalComments: !this._opt.dev ? "none" : "eof",
558
- entryPoints: {styles: 'angular:styles/global;styles'},
559
- plugins: [
560
- createVirtualModulePlugin({
561
- namespace: "angular:styles/global",
562
- transformPath: (currPath) => currPath.split(';', 2)[1],
563
- loadContent: () => ({
564
- contents: `@import 'src/styles.scss';`,
565
- loader: 'css',
566
- resolveDir: this._opt.pkgPath
567
- }),
523
+ return new SdNgBundlerContext(this._opt.pkgPath, {
524
+ absWorkingDir: this._opt.pkgPath,
525
+ bundle: true,
526
+ entryNames: '[name]',
527
+ assetNames: 'media/[name]',
528
+ logLevel: 'silent',
529
+ minify: !this._opt.dev,
530
+ metafile: true,
531
+ sourcemap: this._opt.dev,
532
+ outdir: this._opt.pkgPath,
533
+ write: false,
534
+ platform: 'browser',
535
+ target: browserTarget,
536
+ preserveSymlinks: false,
537
+ external: [],
538
+ conditions: ['style', 'sass'],
539
+ mainFields: ['style', 'sass'],
540
+ legalComments: !this._opt.dev ? "none" : "eof",
541
+ entryPoints: {styles: 'angular:styles/global;styles'},
542
+ plugins: [
543
+ createVirtualModulePlugin({
544
+ namespace: "angular:styles/global",
545
+ transformPath: (currPath) => currPath.split(';', 2)[1],
546
+ loadContent: () => ({
547
+ contents: `@import 'src/styles.scss';`,
548
+ loader: 'css',
549
+ resolveDir: this._opt.pkgPath
568
550
  }),
569
- pluginFactory.create(SassStylesheetLanguage),
570
- pluginFactory.create(CssStylesheetLanguage),
571
- createCssResourcePlugin(this._sourceFileCache.loadResultCache),
572
- ],
573
- },
574
- () => true
575
- );
551
+ }),
552
+ pluginFactory.create(SassStylesheetLanguage),
553
+ pluginFactory.create(CssStylesheetLanguage),
554
+ createCssResourcePlugin(this._sourceFileCache.loadResultCache),
555
+ ],
556
+ });
576
557
  }
577
558
  }