@simplysm/sd-cli 11.0.40 → 11.1.2
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.d.ts +1 -1
- package/dist/build-cluster.js +181 -181
- package/dist/build-tools/SdCliCordova.d.ts +21 -21
- package/dist/build-tools/SdCliCordova.js +217 -217
- package/dist/build-tools/SdCliIndexFileGenerator.d.ts +5 -5
- package/dist/build-tools/SdCliIndexFileGenerator.js +50 -50
- package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +4 -4
- package/dist/build-tools/SdCliNgRoutesFileGenerator.js +57 -57
- package/dist/build-tools/SdLinter.d.ts +5 -5
- package/dist/build-tools/SdLinter.js +54 -54
- package/dist/build-tools/SdNgBundler.d.ts +34 -35
- package/dist/build-tools/SdNgBundler.js +534 -533
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdNgBundlerContext.d.ts +15 -16
- package/dist/build-tools/SdNgBundlerContext.js +97 -97
- package/dist/build-tools/SdNgBundlerContext.js.map +1 -1
- package/dist/build-tools/SdTsBundler.d.ts +15 -15
- package/dist/build-tools/SdTsBundler.js +87 -87
- package/dist/build-tools/SdTsCompiler.d.ts +29 -29
- package/dist/build-tools/SdTsCompiler.js +227 -227
- package/dist/builders/SdCliClientBuilder.d.ts +18 -18
- package/dist/builders/SdCliClientBuilder.js +129 -129
- package/dist/builders/SdCliJsLibLinter.d.ts +14 -14
- package/dist/builders/SdCliJsLibLinter.js +59 -59
- package/dist/builders/SdCliServerBuilder.d.ts +20 -20
- package/dist/builders/SdCliServerBuilder.js +215 -215
- package/dist/builders/SdCliTsLibBuilder.d.ts +17 -17
- package/dist/builders/SdCliTsLibBuilder.js +79 -79
- package/dist/commons.d.ts +132 -132
- package/dist/commons.js +1 -1
- package/dist/entry/SdCliElectron.d.ts +12 -12
- package/dist/entry/SdCliElectron.js +99 -99
- package/dist/entry/SdCliLocalUpdate.d.ts +12 -12
- package/dist/entry/SdCliLocalUpdate.js +90 -90
- package/dist/entry/SdCliProject.d.ts +26 -26
- package/dist/entry/SdCliProject.js +477 -477
- package/dist/index.d.ts +19 -19
- package/dist/index.js +19 -19
- package/dist/sd-cli.d.ts +2 -2
- package/dist/sd-cli.js +210 -210
- package/dist/server-worker.d.ts +1 -1
- package/dist/server-worker.js +38 -38
- package/dist/utils/SdCliBuildResultUtil.d.ts +6 -6
- package/dist/utils/SdCliBuildResultUtil.js +37 -37
- package/dist/utils/SdMemoryLoadResultCache.d.ts +10 -9
- package/dist/utils/SdMemoryLoadResultCache.js +36 -34
- package/dist/utils/SdMemoryLoadResultCache.js.map +1 -1
- package/dist/utils/SdSourceFileCache.d.ts +6 -6
- package/dist/utils/SdSourceFileCache.js +21 -14
- package/dist/utils/SdSourceFileCache.js.map +1 -1
- package/package.json +18 -18
- package/src/build-tools/SdNgBundler.ts +30 -36
- package/src/build-tools/SdNgBundlerContext.ts +11 -11
- package/src/utils/SdMemoryLoadResultCache.ts +4 -1
- package/src/utils/SdSourceFileCache.ts +10 -3
|
@@ -1,534 +1,535 @@
|
|
|
1
|
-
import { createCompilerPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import
|
|
4
|
-
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
5
|
-
import { fileURLToPath
|
|
6
|
-
import { createVirtualModulePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/virtual-module-plugin";
|
|
7
|
-
import { createSourcemapIgnorelistPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
8
|
-
import nodeStdLibBrowser from "node-stdlib-browser";
|
|
9
|
-
import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
|
|
10
|
-
import { copyAssets } from "@angular-devkit/build-angular/src/utils/copy-assets";
|
|
11
|
-
import { extractLicenses } from "@angular-devkit/build-angular/src/tools/esbuild/license-extractor";
|
|
12
|
-
import { augmentAppWithServiceWorkerEsbuild } from "@angular-devkit/build-angular/src/utils/service-worker";
|
|
13
|
-
import browserslist from "browserslist";
|
|
14
|
-
import { createOutputFileFromText, transformSupportedBrowsersToTargets } from "@angular-devkit/build-angular/src/tools/esbuild/utils";
|
|
15
|
-
import { createCssResourcePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
16
|
-
import { CssStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-language";
|
|
17
|
-
import { SassStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/sass-language";
|
|
18
|
-
import { StylesheetPluginFactory } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
19
|
-
import { IndexHtmlGenerator } from "@angular-devkit/build-angular/src/utils/index-file/index-html-generator";
|
|
20
|
-
import { CrossOrigin } from "@angular-devkit/build-angular";
|
|
21
|
-
import { InlineCriticalCssProcessor } from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
|
|
22
|
-
import { SdSourceFileCache } from "../utils/SdSourceFileCache";
|
|
23
|
-
import { SdNgBundlerContext } from "./SdNgBundlerContext";
|
|
24
|
-
export class SdNgBundler {
|
|
25
|
-
constructor(_opt) {
|
|
26
|
-
this._opt = _opt;
|
|
27
|
-
this._sourceFileCache = new SdSourceFileCache(path.resolve(this._opt.pkgPath, ".cache"));
|
|
28
|
-
this._outputCache = new Map();
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
//
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
if (prev !==
|
|
192
|
-
await FsUtil.
|
|
193
|
-
this._outputCache.set(
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
return
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
...this._opt.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
".
|
|
366
|
-
".
|
|
367
|
-
".
|
|
368
|
-
".
|
|
369
|
-
".
|
|
370
|
-
".
|
|
371
|
-
".
|
|
372
|
-
".
|
|
373
|
-
".
|
|
374
|
-
".
|
|
375
|
-
".
|
|
376
|
-
".
|
|
377
|
-
".
|
|
378
|
-
".
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
...this._opt.cordovaConfig?.plugins ? [{
|
|
448
|
-
name: "cordova:plugin-empty",
|
|
449
|
-
setup: ({ onResolve }) => {
|
|
450
|
-
onResolve({ filter: new RegExp("(" + this._opt.cordovaConfig.plugins.join("|") + ")") }, () => {
|
|
451
|
-
return {
|
|
452
|
-
path: `./cordova-empty.js`,
|
|
453
|
-
external: true
|
|
454
|
-
};
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
}] : [],
|
|
458
|
-
createVirtualModulePlugin({
|
|
459
|
-
namespace: "angular:polyfills",
|
|
460
|
-
loadContent: () => ({
|
|
461
|
-
contents: `import "./src/polyfills.ts";`,
|
|
462
|
-
loader: 'js',
|
|
463
|
-
resolveDir: this._opt.pkgPath
|
|
464
|
-
})
|
|
465
|
-
}),
|
|
466
|
-
createSourcemapIgnorelistPlugin(),
|
|
467
|
-
createCompilerPlugin({
|
|
468
|
-
sourcemap: this._opt.dev,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
fileReplacements: undefined,
|
|
474
|
-
sourceFileCache: this._sourceFileCache,
|
|
475
|
-
loadResultCache: this._sourceFileCache.loadResultCache
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
pluginFactory.create(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
1
|
+
import { createCompilerPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { BuildOutputFileType } from "@angular-devkit/build-angular/src/tools/esbuild/bundler-context";
|
|
4
|
+
import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
import { createVirtualModulePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/virtual-module-plugin";
|
|
7
|
+
import { createSourcemapIgnorelistPlugin } from "@angular-devkit/build-angular/src/tools/esbuild/sourcemap-ignorelist-plugin";
|
|
8
|
+
import nodeStdLibBrowser from "node-stdlib-browser";
|
|
9
|
+
import nodeStdLibBrowserPlugin from "node-stdlib-browser/helpers/esbuild/plugin";
|
|
10
|
+
import { copyAssets } from "@angular-devkit/build-angular/src/utils/copy-assets";
|
|
11
|
+
import { extractLicenses } from "@angular-devkit/build-angular/src/tools/esbuild/license-extractor";
|
|
12
|
+
import { augmentAppWithServiceWorkerEsbuild } from "@angular-devkit/build-angular/src/utils/service-worker";
|
|
13
|
+
import browserslist from "browserslist";
|
|
14
|
+
import { convertOutputFile, createOutputFileFromText, transformSupportedBrowsersToTargets } from "@angular-devkit/build-angular/src/tools/esbuild/utils";
|
|
15
|
+
import { createCssResourcePlugin } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-resource-plugin";
|
|
16
|
+
import { CssStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/css-language";
|
|
17
|
+
import { SassStylesheetLanguage } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/sass-language";
|
|
18
|
+
import { StylesheetPluginFactory } from "@angular-devkit/build-angular/src/tools/esbuild/stylesheets/stylesheet-plugin-factory";
|
|
19
|
+
import { IndexHtmlGenerator } from "@angular-devkit/build-angular/src/utils/index-file/index-html-generator";
|
|
20
|
+
import { CrossOrigin } from "@angular-devkit/build-angular";
|
|
21
|
+
import { InlineCriticalCssProcessor } from "@angular-devkit/build-angular/src/utils/index-file/inline-critical-css";
|
|
22
|
+
import { SdSourceFileCache } from "../utils/SdSourceFileCache";
|
|
23
|
+
import { SdNgBundlerContext } from "./SdNgBundlerContext";
|
|
24
|
+
export class SdNgBundler {
|
|
25
|
+
constructor(_opt) {
|
|
26
|
+
this._opt = _opt;
|
|
27
|
+
this._sourceFileCache = new SdSourceFileCache(path.resolve(this._opt.pkgPath, ".cache"));
|
|
28
|
+
this._outputCache = new Map();
|
|
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}/` : ``;
|
|
37
|
+
}
|
|
38
|
+
removeCache(filePaths) {
|
|
39
|
+
this._sourceFileCache.invalidate(filePaths);
|
|
40
|
+
}
|
|
41
|
+
async bundleAsync() {
|
|
42
|
+
if (!this._contexts) {
|
|
43
|
+
this._contexts = [];
|
|
44
|
+
this._contexts.push(await this._getAppContextAsync());
|
|
45
|
+
this._contexts.push(this._getStyleContext());
|
|
46
|
+
}
|
|
47
|
+
//-- build
|
|
48
|
+
const bundlingResults = await this._contexts.mapAsync(async (ctx) => await ctx.bundleAsync());
|
|
49
|
+
const results = bundlingResults.mapMany(bundlingResult => bundlingResult.results);
|
|
50
|
+
const watchFilePaths = [
|
|
51
|
+
...Array.from(this._sourceFileCache.typeScriptFileCache.keys()).map(item => fileURLToPath(item)),
|
|
52
|
+
...this._sourceFileCache.referencedFiles ?? [],
|
|
53
|
+
...this._sourceFileCache.babelFileCache.keys(),
|
|
54
|
+
...this._sourceFileCache.loadResultCache.watchFiles
|
|
55
|
+
].map((item) => path.resolve(item)).distinct();
|
|
56
|
+
let affectedSourceFilePaths = watchFilePaths.filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));
|
|
57
|
+
if (this._sourceFileCache.modifiedFiles.size > 0) {
|
|
58
|
+
affectedSourceFilePaths = Array.from(this._sourceFileCache.modifiedFiles)
|
|
59
|
+
.filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath))
|
|
60
|
+
.map((item) => path.resolve(item))
|
|
61
|
+
.distinct();
|
|
62
|
+
/*const depMap = new Map<string, Set<string>>();
|
|
63
|
+
for (const bundlingResult of bundlingResults) {
|
|
64
|
+
for (const [k, v] of bundlingResult.dependencyMap) {
|
|
65
|
+
const currSet = depMap.getOrCreate(k, new Set<string>());
|
|
66
|
+
currSet.adds(...v);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const [k, v] of this._sourceFileCache.loadResultCache.fileDependencies) {
|
|
70
|
+
const currSet = depMap.getOrCreate(k, new Set<string>());
|
|
71
|
+
currSet.adds(...Array.from(v).map((item) => item.startsWith("file:") ? fileURLToPath(item) : undefined).filterExists());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const searchAffectedFiles = (filePath: string, prev?: Set<string>): Set<string> => {
|
|
75
|
+
const result = new Set<string>(prev);
|
|
76
|
+
|
|
77
|
+
const importerPaths = depMap.get(filePath);
|
|
78
|
+
if (!importerPaths) return result;
|
|
79
|
+
|
|
80
|
+
for (const importerPath of importerPaths) {
|
|
81
|
+
if (result.has(importerPath)) continue;
|
|
82
|
+
result.adds(importerPath);
|
|
83
|
+
result.adds(...searchAffectedFiles(importerPath, result));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return result;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const affectedFilePathSet = new Set<string>();
|
|
90
|
+
for (const modFile of this._sourceFileCache.modifiedFiles) {
|
|
91
|
+
affectedFilePathSet.add(path.resolve(modFile));
|
|
92
|
+
affectedFilePathSet.adds(...searchAffectedFiles(path.resolve(modFile)));
|
|
93
|
+
}
|
|
94
|
+
affectedSourceFilePaths = Array.from(affectedFilePathSet.values()).filter((item) => PathUtil.isChildPath(item, this._opt.pkgPath));*/
|
|
95
|
+
}
|
|
96
|
+
/*const executionResult = new ExecutionResult(this._contexts, this._sourceFileCache);
|
|
97
|
+
executionResult.outputFiles.push(...bundlingResult.outputFiles);*/
|
|
98
|
+
const outputFiles = bundlingResults.mapMany(item => item.outputFiles?.map(file => convertOutputFile(file, BuildOutputFileType.Root)) ?? []);
|
|
99
|
+
const initialFiles = new Map();
|
|
100
|
+
const metafile = {
|
|
101
|
+
inputs: {},
|
|
102
|
+
outputs: {}
|
|
103
|
+
};
|
|
104
|
+
for (const bundlingResult of bundlingResults) {
|
|
105
|
+
bundlingResult.initialFiles.forEach((v, k) => initialFiles.set(k, v));
|
|
106
|
+
metafile.inputs = { ...metafile.inputs, ...bundlingResult.metafile?.inputs };
|
|
107
|
+
metafile.outputs = { ...metafile.outputs, ...bundlingResult.metafile?.outputs };
|
|
108
|
+
}
|
|
109
|
+
const assetFiles = [];
|
|
110
|
+
//-- Check commonjs
|
|
111
|
+
// if (!this._opt.dev) {
|
|
112
|
+
// const messages = checkCommonJSModules(bundlingResult.metafile, []);
|
|
113
|
+
// for (const msg of messages) {
|
|
114
|
+
// results.push({
|
|
115
|
+
// filePath: msg.location?.file,
|
|
116
|
+
// line: msg.location?.line,
|
|
117
|
+
// char: msg.location?.column,
|
|
118
|
+
// code: msg.pluginName,
|
|
119
|
+
// severity: "warning",
|
|
120
|
+
// message: msg.text ?? "",
|
|
121
|
+
// type: "build"
|
|
122
|
+
// });
|
|
123
|
+
// }
|
|
124
|
+
// }
|
|
125
|
+
//-- cordova empty
|
|
126
|
+
if (this._opt.cordovaConfig?.plugins) {
|
|
127
|
+
outputFiles.push(createOutputFileFromText("cordova-empty.js", "export default {};", BuildOutputFileType.Root));
|
|
128
|
+
}
|
|
129
|
+
//-- index
|
|
130
|
+
const genIndexHtmlResult = await this._genIndexHtmlAsync(outputFiles, initialFiles);
|
|
131
|
+
for (const warning of genIndexHtmlResult.warnings) {
|
|
132
|
+
results.push({
|
|
133
|
+
filePath: undefined,
|
|
134
|
+
line: undefined,
|
|
135
|
+
char: undefined,
|
|
136
|
+
code: undefined,
|
|
137
|
+
severity: "warning",
|
|
138
|
+
message: `(gen-index) ${warning}`,
|
|
139
|
+
type: "build",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
for (const error of genIndexHtmlResult.errors) {
|
|
143
|
+
results.push({
|
|
144
|
+
filePath: undefined,
|
|
145
|
+
line: undefined,
|
|
146
|
+
char: undefined,
|
|
147
|
+
code: undefined,
|
|
148
|
+
severity: "error",
|
|
149
|
+
message: `(gen-index) ${error}`,
|
|
150
|
+
type: "build",
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
outputFiles.push(createOutputFileFromText("index.html", genIndexHtmlResult.content, BuildOutputFileType.Root));
|
|
154
|
+
//-- copy assets
|
|
155
|
+
assetFiles.push(...(await this._copyAssetsAsync()));
|
|
156
|
+
//-- extract 3rdpartylicenses
|
|
157
|
+
if (!this._opt.dev) {
|
|
158
|
+
outputFiles.push(createOutputFileFromText('3rdpartylicenses.txt', await extractLicenses(metafile, this._opt.pkgPath), BuildOutputFileType.Root));
|
|
159
|
+
}
|
|
160
|
+
//-- service worker
|
|
161
|
+
if (FsUtil.exists(this._swConfFilePath)) {
|
|
162
|
+
try {
|
|
163
|
+
const serviceWorkerResult = await this._genServiceWorkerAsync(outputFiles, assetFiles);
|
|
164
|
+
outputFiles.push(createOutputFileFromText('ngsw.json', serviceWorkerResult.manifest, BuildOutputFileType.Root));
|
|
165
|
+
assetFiles.push(...serviceWorkerResult.assetFiles);
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
results.push({
|
|
169
|
+
filePath: undefined,
|
|
170
|
+
line: undefined,
|
|
171
|
+
char: undefined,
|
|
172
|
+
code: undefined,
|
|
173
|
+
severity: "error",
|
|
174
|
+
message: `(gen-sw) ${err.toString()}`,
|
|
175
|
+
type: "build",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
//-- write
|
|
180
|
+
for (const outputFile of outputFiles) {
|
|
181
|
+
const distFilePath = path.resolve(this._opt.outputPath, outputFile.fullOutputPath);
|
|
182
|
+
const prev = this._outputCache.get(distFilePath);
|
|
183
|
+
if (prev !== Buffer.from(outputFile.contents).toString("base64")) {
|
|
184
|
+
await FsUtil.writeFileAsync(distFilePath, outputFile.contents);
|
|
185
|
+
this._outputCache.set(distFilePath, Buffer.from(outputFile.contents).toString("base64"));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
for (const assetFile of assetFiles) {
|
|
189
|
+
const prev = this._outputCache.get(assetFile.source);
|
|
190
|
+
const curr = FsUtil.lstat(assetFile.source).mtime.getTime();
|
|
191
|
+
if (prev !== curr) {
|
|
192
|
+
await FsUtil.copyAsync(assetFile.source, path.resolve(this._opt.outputPath, assetFile.destination));
|
|
193
|
+
this._outputCache.set(assetFile.source, curr);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
filePaths: watchFilePaths,
|
|
198
|
+
affectedFilePaths: affectedSourceFilePaths,
|
|
199
|
+
results
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
async _genIndexHtmlAsync(outputFiles, initialFiles) {
|
|
203
|
+
const readAsset = (filePath) => {
|
|
204
|
+
const relFilePath = path.relative("/", filePath);
|
|
205
|
+
const currFile = outputFiles.find((outputFile) => outputFile.path === relFilePath);
|
|
206
|
+
if (currFile) {
|
|
207
|
+
return Promise.resolve(currFile.text);
|
|
208
|
+
}
|
|
209
|
+
throw new Error(`Output file does not exist: ${relFilePath}`);
|
|
210
|
+
};
|
|
211
|
+
const indexHtmlGenerator = new IndexHtmlGenerator({
|
|
212
|
+
indexPath: this._indexHtmlFilePath,
|
|
213
|
+
entrypoints: [
|
|
214
|
+
['runtime', true],
|
|
215
|
+
['polyfills', true],
|
|
216
|
+
['styles', false],
|
|
217
|
+
['vendor', true],
|
|
218
|
+
['main', true],
|
|
219
|
+
...this._opt.builderType === "cordova" ? [
|
|
220
|
+
["cordova-entry", true]
|
|
221
|
+
] : []
|
|
222
|
+
],
|
|
223
|
+
optimization: {
|
|
224
|
+
scripts: !this._opt.dev,
|
|
225
|
+
fonts: { inline: !this._opt.dev },
|
|
226
|
+
styles: {
|
|
227
|
+
minify: !this._opt.dev,
|
|
228
|
+
inlineCritical: false
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
crossOrigin: CrossOrigin.None,
|
|
232
|
+
});
|
|
233
|
+
indexHtmlGenerator.readAsset = readAsset;
|
|
234
|
+
const hints = [];
|
|
235
|
+
if (!this._opt.dev) {
|
|
236
|
+
for (const [key, value] of initialFiles) {
|
|
237
|
+
if (value.entrypoint) {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (value.type === 'script') {
|
|
241
|
+
hints.push({ url: key, mode: 'modulepreload' });
|
|
242
|
+
}
|
|
243
|
+
else if (value.type === 'style') {
|
|
244
|
+
hints.push({ url: key, mode: 'preload', as: 'style' });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const transformResult = await indexHtmlGenerator.process({
|
|
249
|
+
baseHref: this._baseHref,
|
|
250
|
+
lang: undefined,
|
|
251
|
+
outputPath: "/",
|
|
252
|
+
files: [...initialFiles].map(([file, record]) => ({
|
|
253
|
+
name: record.name ?? '',
|
|
254
|
+
file,
|
|
255
|
+
extension: path.extname(file),
|
|
256
|
+
})),
|
|
257
|
+
hints,
|
|
258
|
+
});
|
|
259
|
+
if (this._opt.dev) {
|
|
260
|
+
return transformResult;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
|
|
264
|
+
minify: false,
|
|
265
|
+
readAsset,
|
|
266
|
+
});
|
|
267
|
+
const { content, errors, warnings } = await inlineCriticalCssProcessor.process(transformResult.content, { outputPath: "/", });
|
|
268
|
+
return {
|
|
269
|
+
warnings: [...transformResult.warnings, ...warnings],
|
|
270
|
+
errors: [...transformResult.errors, ...errors],
|
|
271
|
+
content
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
async _copyAssetsAsync() {
|
|
276
|
+
return await copyAssets([
|
|
277
|
+
{ input: 'src', glob: 'favicon.ico', output: '' },
|
|
278
|
+
{ input: 'src', glob: 'manifest.webmanifest', output: '' },
|
|
279
|
+
{ input: 'src/assets', glob: '**/*', output: 'assets' },
|
|
280
|
+
...this._opt.dev && this._opt.builderType === "cordova" ? Object.keys(this._opt.cordovaConfig?.platform ?? { browser: {} }).mapMany((platform) => [
|
|
281
|
+
{
|
|
282
|
+
input: `.cordova/platforms/${platform}/platform_www/plugins`,
|
|
283
|
+
glob: '**/*',
|
|
284
|
+
output: `cordova-${platform}/plugins`
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
input: `.cordova/platforms/${platform}/platform_www`,
|
|
288
|
+
glob: 'cordova.js',
|
|
289
|
+
output: `cordova-${platform}`
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
input: `.cordova/platforms/${platform}/platform_www`,
|
|
293
|
+
glob: 'cordova_plugins.js',
|
|
294
|
+
output: `cordova-${platform}`
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
input: `.cordova/platforms/${platform}/www`,
|
|
298
|
+
glob: 'config.xml',
|
|
299
|
+
output: `cordova-${platform}`
|
|
300
|
+
},
|
|
301
|
+
]) : []
|
|
302
|
+
], [], this._opt.pkgPath);
|
|
303
|
+
}
|
|
304
|
+
async _genServiceWorkerAsync(outputFiles, assetFiles) {
|
|
305
|
+
return await augmentAppWithServiceWorkerEsbuild(this._opt.pkgPath, this._swConfFilePath, this._baseHref, outputFiles, assetFiles);
|
|
306
|
+
}
|
|
307
|
+
async _getAppContextAsync() {
|
|
308
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
309
|
+
absWorkingDir: this._opt.pkgPath,
|
|
310
|
+
bundle: true,
|
|
311
|
+
keepNames: true,
|
|
312
|
+
format: 'esm',
|
|
313
|
+
assetNames: 'media/[name]',
|
|
314
|
+
conditions: ['es2020', 'es2015', 'module'],
|
|
315
|
+
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
316
|
+
metafile: true,
|
|
317
|
+
legalComments: this._opt.dev ? 'eof' : 'none',
|
|
318
|
+
logLevel: 'silent',
|
|
319
|
+
minifyIdentifiers: !this._opt.dev,
|
|
320
|
+
minifySyntax: !this._opt.dev,
|
|
321
|
+
minifyWhitespace: !this._opt.dev,
|
|
322
|
+
pure: ['forwardRef'],
|
|
323
|
+
outdir: this._opt.pkgPath,
|
|
324
|
+
outExtension: undefined,
|
|
325
|
+
sourcemap: this._opt.dev,
|
|
326
|
+
splitting: true,
|
|
327
|
+
chunkNames: 'chunk-[hash]',
|
|
328
|
+
tsconfig: this._tsConfigFilePath,
|
|
329
|
+
/*external: [
|
|
330
|
+
...this._opt.cordovaConfig?.plugins ?? []
|
|
331
|
+
],*/
|
|
332
|
+
write: false,
|
|
333
|
+
preserveSymlinks: false,
|
|
334
|
+
define: {
|
|
335
|
+
...!this._opt.dev ? { ngDevMode: 'false' } : {},
|
|
336
|
+
ngJitMode: 'false',
|
|
337
|
+
global: 'global',
|
|
338
|
+
process: 'process',
|
|
339
|
+
Buffer: 'Buffer',
|
|
340
|
+
'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
|
|
341
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
342
|
+
...this._opt.env ? Object.keys(this._opt.env).toObject(key => `process.env.${key}`, key => JSON.stringify(this._opt.env[key])) : {}
|
|
343
|
+
},
|
|
344
|
+
platform: 'browser',
|
|
345
|
+
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
|
|
346
|
+
entryNames: '[name]',
|
|
347
|
+
entryPoints: {
|
|
348
|
+
main: this._mainFilePath,
|
|
349
|
+
polyfills: 'angular:polyfills',
|
|
350
|
+
...this._opt.builderType === "cordova" ? {
|
|
351
|
+
"cordova-entry": path.resolve(path.dirname(fileURLToPath(import.meta.url)), `../../lib/cordova-entry.js`)
|
|
352
|
+
} : {}
|
|
353
|
+
},
|
|
354
|
+
target: this._browserTarget,
|
|
355
|
+
supported: { 'async-await': false, 'object-rest-spread': false },
|
|
356
|
+
loader: {
|
|
357
|
+
".png": "file",
|
|
358
|
+
".jpeg": "file",
|
|
359
|
+
".jpg": "file",
|
|
360
|
+
".jfif": "file",
|
|
361
|
+
".gif": "file",
|
|
362
|
+
".svg": "file",
|
|
363
|
+
".woff": "file",
|
|
364
|
+
".woff2": "file",
|
|
365
|
+
".ttf": "file",
|
|
366
|
+
".eot": "file",
|
|
367
|
+
".ico": "file",
|
|
368
|
+
".otf": "file",
|
|
369
|
+
".csv": "file",
|
|
370
|
+
".xlsx": "file",
|
|
371
|
+
".xls": "file",
|
|
372
|
+
".pptx": "file",
|
|
373
|
+
".ppt": "file",
|
|
374
|
+
".docx": "file",
|
|
375
|
+
".doc": "file",
|
|
376
|
+
".zip": "file",
|
|
377
|
+
".pfx": "file",
|
|
378
|
+
".pkl": "file"
|
|
379
|
+
},
|
|
380
|
+
inject: [PathUtil.posix(fileURLToPath(await import.meta.resolve("node-stdlib-browser/helpers/esbuild/shim")))],
|
|
381
|
+
plugins: [
|
|
382
|
+
/*{
|
|
383
|
+
name: "sd-worker",
|
|
384
|
+
setup: ({onLoad}) => {
|
|
385
|
+
onLoad({filter: /\.ts$/}, async args => {
|
|
386
|
+
if (args.path.endsWith(".d.ts")) return;
|
|
387
|
+
|
|
388
|
+
// ts sourefile 로 Worker사용여부 확인 (URL, import.meta.url)
|
|
389
|
+
let contents = this._sourceFileCache.typeScriptFileCache.get(pathToFileURL(args.path).toString());
|
|
390
|
+
if (typeof contents !== "string") return;
|
|
391
|
+
|
|
392
|
+
const regexp = /new Worker\(new URL\("(.*\.ts)", import\.meta\.url\)/;
|
|
393
|
+
const matches = contents.match(new RegExp(regexp, "g"));
|
|
394
|
+
if (!matches) return;
|
|
395
|
+
|
|
396
|
+
for (const match of matches) {
|
|
397
|
+
const urlPath = match.match(regexp)![1];
|
|
398
|
+
|
|
399
|
+
// 해당 URL의 파일을 esbuild로 빌드
|
|
400
|
+
const outFileName = path.basename(urlPath, path.extname(urlPath)) + ".js";
|
|
401
|
+
await esbuild.build({
|
|
402
|
+
entryPoints: [path.resolve(path.dirname(args.path), urlPath)],
|
|
403
|
+
outfile: path.resolve(this._opt.pkgPath, "dist", outFileName),
|
|
404
|
+
target: this._browserTarget,
|
|
405
|
+
format: "esm",
|
|
406
|
+
bundle: true,
|
|
407
|
+
keepNames: true,
|
|
408
|
+
minifyIdentifiers: !this._opt.dev,
|
|
409
|
+
minifySyntax: !this._opt.dev,
|
|
410
|
+
minifyWhitespace: !this._opt.dev,
|
|
411
|
+
sourcemap: this._opt.dev,
|
|
412
|
+
platform: 'browser',
|
|
413
|
+
conditions: ['es2020', 'es2015', 'module'],
|
|
414
|
+
mainFields: ['es2020', 'es2015', 'browser', 'module', 'main'],
|
|
415
|
+
resolveExtensions: ['.ts', '.tsx', '.mjs', '.js'],
|
|
416
|
+
tsconfig: this._tsConfigFilePath,
|
|
417
|
+
preserveSymlinks: false,
|
|
418
|
+
define: {
|
|
419
|
+
...!this._opt.dev ? {ngDevMode: 'false'} : {},
|
|
420
|
+
ngJitMode: 'false',
|
|
421
|
+
global: 'global',
|
|
422
|
+
process: 'process',
|
|
423
|
+
Buffer: 'Buffer',
|
|
424
|
+
'process.env.SD_VERSION': JSON.stringify(this._pkgNpmConf.version),
|
|
425
|
+
"process.env.NODE_ENV": JSON.stringify(this._opt.dev ? "development" : "production"),
|
|
426
|
+
...this._opt.env ? Object.keys(this._opt.env).toObject(
|
|
427
|
+
key => `process.env.${key}`,
|
|
428
|
+
key => JSON.stringify(this._opt.env![key])
|
|
429
|
+
) : {}
|
|
430
|
+
},
|
|
431
|
+
inject: [PathUtil.posix(fileURLToPath(await import.meta.resolve!("node-stdlib-browser/helpers/esbuild/shim")))],
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
// 빌드된 파일을 가리키도록 URL변경
|
|
435
|
+
contents = contents.replace(urlPath, "./" + outFileName);
|
|
436
|
+
|
|
437
|
+
const currSet = this._customDepsCache.getOrCreate(path.resolve(path.dirname(args.path), urlPath), new Set());
|
|
438
|
+
currSet.add(path.resolve(args.path));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
this._sourceFileCache.typeScriptFileCache.set(pathToFileURL(args.path).toString(), contents);
|
|
442
|
+
|
|
443
|
+
return undefined;
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
},*/
|
|
447
|
+
...this._opt.cordovaConfig?.plugins ? [{
|
|
448
|
+
name: "cordova:plugin-empty",
|
|
449
|
+
setup: ({ onResolve }) => {
|
|
450
|
+
onResolve({ filter: new RegExp("(" + this._opt.cordovaConfig.plugins.join("|") + ")") }, () => {
|
|
451
|
+
return {
|
|
452
|
+
path: `./cordova-empty.js`,
|
|
453
|
+
external: true
|
|
454
|
+
};
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}] : [],
|
|
458
|
+
createVirtualModulePlugin({
|
|
459
|
+
namespace: "angular:polyfills",
|
|
460
|
+
loadContent: () => ({
|
|
461
|
+
contents: `import "./src/polyfills.ts";`,
|
|
462
|
+
loader: 'js',
|
|
463
|
+
resolveDir: this._opt.pkgPath
|
|
464
|
+
})
|
|
465
|
+
}),
|
|
466
|
+
createSourcemapIgnorelistPlugin(),
|
|
467
|
+
createCompilerPlugin({
|
|
468
|
+
sourcemap: this._opt.dev,
|
|
469
|
+
tsconfig: this._tsConfigFilePath,
|
|
470
|
+
jit: false,
|
|
471
|
+
advancedOptimizations: true,
|
|
472
|
+
thirdPartySourcemaps: false,
|
|
473
|
+
fileReplacements: undefined,
|
|
474
|
+
sourceFileCache: this._sourceFileCache,
|
|
475
|
+
loadResultCache: this._sourceFileCache.loadResultCache,
|
|
476
|
+
incremental: this._opt.dev
|
|
477
|
+
}, {
|
|
478
|
+
workspaceRoot: this._opt.pkgPath,
|
|
479
|
+
optimization: !this._opt.dev,
|
|
480
|
+
sourcemap: this._opt.dev ? 'inline' : false,
|
|
481
|
+
outputNames: { bundles: '[name]', media: 'media/[name]' },
|
|
482
|
+
includePaths: [],
|
|
483
|
+
externalDependencies: [],
|
|
484
|
+
target: this._browserTarget,
|
|
485
|
+
inlineStyleLanguage: 'scss',
|
|
486
|
+
preserveSymlinks: false,
|
|
487
|
+
tailwindConfiguration: undefined
|
|
488
|
+
}),
|
|
489
|
+
nodeStdLibBrowserPlugin(nodeStdLibBrowser),
|
|
490
|
+
]
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
_getStyleContext() {
|
|
494
|
+
const browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
|
|
495
|
+
const pluginFactory = new StylesheetPluginFactory({
|
|
496
|
+
sourcemap: this._opt.dev,
|
|
497
|
+
includePaths: []
|
|
498
|
+
}, this._sourceFileCache.loadResultCache);
|
|
499
|
+
return new SdNgBundlerContext(this._opt.pkgPath, {
|
|
500
|
+
absWorkingDir: this._opt.pkgPath,
|
|
501
|
+
bundle: true,
|
|
502
|
+
entryNames: '[name]',
|
|
503
|
+
assetNames: 'media/[name]',
|
|
504
|
+
logLevel: 'silent',
|
|
505
|
+
minify: !this._opt.dev,
|
|
506
|
+
metafile: true,
|
|
507
|
+
sourcemap: this._opt.dev,
|
|
508
|
+
outdir: this._opt.pkgPath,
|
|
509
|
+
write: false,
|
|
510
|
+
platform: 'browser',
|
|
511
|
+
target: browserTarget,
|
|
512
|
+
preserveSymlinks: false,
|
|
513
|
+
external: [],
|
|
514
|
+
conditions: ['style', 'sass'],
|
|
515
|
+
mainFields: ['style', 'sass'],
|
|
516
|
+
legalComments: !this._opt.dev ? "none" : "eof",
|
|
517
|
+
entryPoints: { styles: 'angular:styles/global;styles' },
|
|
518
|
+
plugins: [
|
|
519
|
+
createVirtualModulePlugin({
|
|
520
|
+
namespace: "angular:styles/global",
|
|
521
|
+
transformPath: (currPath) => currPath.split(';', 2)[1],
|
|
522
|
+
loadContent: () => ({
|
|
523
|
+
contents: `@import 'src/styles.scss';`,
|
|
524
|
+
loader: 'css',
|
|
525
|
+
resolveDir: this._opt.pkgPath
|
|
526
|
+
}),
|
|
527
|
+
}),
|
|
528
|
+
pluginFactory.create(SassStylesheetLanguage),
|
|
529
|
+
pluginFactory.create(CssStylesheetLanguage),
|
|
530
|
+
createCssResourcePlugin(this._sourceFileCache.loadResultCache),
|
|
531
|
+
],
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
}
|
|
534
535
|
//# sourceMappingURL=SdNgBundler.js.map
|