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