@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.
- package/dist/build-cluster.js +16 -3
- package/dist/build-cluster.js.map +1 -1
- 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 +11 -20
- package/dist/build-tools/SdNgBundler.js +103 -96
- package/dist/build-tools/SdNgBundler.js.map +1 -1
- package/dist/build-tools/SdServerBundler.js.map +1 -1
- package/dist/build-tools/SdTsCompiler.d.ts +24 -27
- package/dist/build-tools/SdTsCompiler.js +237 -184
- package/dist/build-tools/SdTsCompiler.js.map +1 -1
- package/dist/builders/SdCliTsLibBuilder.d.ts +2 -6
- package/dist/builders/SdCliTsLibBuilder.js +30 -30
- package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
- package/dist/bundle-plugins/sdNgPlugin.d.ts +3 -3
- package/dist/bundle-plugins/sdNgPlugin.js +22 -212
- package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
- package/dist/bundle-plugins/sdServerPlugin.d.ts +2 -2
- package/dist/bundle-plugins/sdServerPlugin.js +17 -110
- package/dist/bundle-plugins/sdServerPlugin.js.map +1 -1
- package/dist/commons.d.ts +1 -0
- package/dist/entry/SdCliProject.d.ts +1 -0
- package/dist/entry/SdCliProject.js +14 -30
- package/dist/entry/SdCliProject.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/sd-cli.d.ts +1 -1
- package/dist/sd-cli.js +8 -2
- package/dist/sd-cli.js.map +1 -1
- package/dist/server-worker.js.map +1 -1
- package/dist/utils/SdCliBuildResultUtil.d.ts +10 -0
- package/dist/utils/SdCliBuildResultUtil.js +17 -1
- package/dist/utils/SdCliBuildResultUtil.js.map +1 -1
- package/package.json +15 -15
- package/src/build-cluster.ts +18 -4
- package/src/build-tools/SdLibBundler.ts +70 -0
- package/src/build-tools/SdLinter.ts +4 -4
- package/src/build-tools/SdNgBundler.ts +120 -112
- package/src/build-tools/SdServerBundler.ts +2 -2
- package/src/build-tools/SdTsCompiler.ts +352 -241
- package/src/builders/SdCliTsLibBuilder.ts +33 -31
- package/src/bundle-plugins/sdNgPlugin.ts +26 -320
- package/src/bundle-plugins/sdServerPlugin.ts +20 -168
- package/src/commons.ts +1 -0
- package/src/entry/SdCliProject.ts +15 -31
- package/src/index.ts +1 -0
- package/src/sd-cli.ts +8 -2
- package/src/server-worker.ts +3 -3
- 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 {
|
|
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.
|
|
46
|
+
// path.resolve(this.#opt.pkgPath, ".cache")
|
|
47
47
|
// );
|
|
48
48
|
|
|
49
|
-
#modifiedFileSet = new Set<string>();
|
|
50
|
-
#ngResultCache:
|
|
51
|
-
|
|
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
|
-
|
|
56
|
+
#contexts: SdNgBundlerContext[] | undefined;
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
readonly #outputCache = new Map<string, string | number>();
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
pkgPath
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this
|
|
77
|
-
this
|
|
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
|
|
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
|
|
103
|
-
this
|
|
101
|
+
if (!this.#contexts) {
|
|
102
|
+
this.#contexts = [
|
|
104
103
|
await this._getAppContextAsync(),
|
|
105
104
|
this._getStyleContext(),
|
|
106
|
-
...this.
|
|
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.
|
|
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.
|
|
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.
|
|
172
|
-
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));
|
|
173
172
|
}
|
|
174
173
|
|
|
175
174
|
//-- service worker
|
|
176
|
-
if (FsUtil.exists(this
|
|
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.
|
|
198
|
-
const prev = this.
|
|
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.
|
|
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.
|
|
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.
|
|
209
|
-
this.
|
|
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.
|
|
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
|
|
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.
|
|
247
|
+
...this.#opt.builderType === "cordova" ? [
|
|
249
248
|
["cordova-entry", true] as Entrypoint
|
|
250
249
|
] : []
|
|
251
250
|
],
|
|
252
251
|
optimization: {
|
|
253
|
-
scripts: !this.
|
|
254
|
-
fonts: {inline: !this.
|
|
252
|
+
scripts: !this.#opt.dev,
|
|
253
|
+
fonts: {inline: !this.#opt.dev},
|
|
255
254
|
styles: {
|
|
256
|
-
minify: !this.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
361
|
-
this
|
|
362
|
-
this
|
|
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.
|
|
371
|
-
absWorkingDir: this.
|
|
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.
|
|
378
|
+
legalComments: this.#opt.dev ? 'eof' : 'none',
|
|
380
379
|
logLevel: 'silent',
|
|
381
|
-
minifyIdentifiers: !this.
|
|
382
|
-
minifySyntax: !this.
|
|
383
|
-
minifyWhitespace: !this.
|
|
380
|
+
minifyIdentifiers: !this.#opt.dev,
|
|
381
|
+
minifySyntax: !this.#opt.dev,
|
|
382
|
+
minifyWhitespace: !this.#opt.dev,
|
|
384
383
|
pure: ['forwardRef'],
|
|
385
|
-
outdir: this.
|
|
384
|
+
outdir: this.#opt.pkgPath,
|
|
386
385
|
outExtension: undefined,
|
|
387
|
-
sourcemap: true, //this.
|
|
386
|
+
sourcemap: true, //this.#opt.dev,
|
|
388
387
|
splitting: true,
|
|
389
388
|
chunkNames: 'chunk-[hash]',
|
|
390
|
-
tsconfig: this
|
|
389
|
+
tsconfig: this.#tsConfigFilePath,
|
|
391
390
|
write: false,
|
|
392
391
|
preserveSymlinks: false,
|
|
393
392
|
define: {
|
|
394
|
-
...!this.
|
|
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.
|
|
400
|
-
"process.env.NODE_ENV": JSON.stringify(this.
|
|
401
|
-
...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(
|
|
402
401
|
key => `process.env.${key}`,
|
|
403
|
-
key => JSON.stringify(this.
|
|
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
|
|
409
|
+
main: this.#mainFilePath,
|
|
411
410
|
// polyfills: 'angular:polyfills',
|
|
412
|
-
polyfills: path.resolve(this.
|
|
413
|
-
...this.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
468
|
-
pkgPath: this.
|
|
466
|
+
dev: this.#opt.dev,
|
|
467
|
+
pkgPath: this.#opt.pkgPath,
|
|
469
468
|
result: this.#ngResultCache
|
|
470
469
|
}),
|
|
471
470
|
// createCompilerPlugin({
|
|
472
|
-
// sourcemap: this.
|
|
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.
|
|
479
|
+
// incremental: this.#opt.dev
|
|
481
480
|
// }, {
|
|
482
|
-
// workspaceRoot: this.
|
|
483
|
-
// optimization: !this.
|
|
484
|
-
// sourcemap: this.
|
|
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.
|
|
509
|
+
sourcemap: true, //this.#opt.dev,
|
|
511
510
|
includePaths: []
|
|
512
511
|
},
|
|
513
512
|
this.#styleLoadResultCache,
|
|
514
513
|
);
|
|
515
514
|
|
|
516
|
-
return new SdNgBundlerContext(this.
|
|
517
|
-
absWorkingDir: this.
|
|
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.
|
|
521
|
+
minify: !this.#opt.dev,
|
|
523
522
|
metafile: true,
|
|
524
|
-
sourcemap: true, //this.
|
|
525
|
-
outdir: this.
|
|
523
|
+
sourcemap: true, //this.#opt.dev,
|
|
524
|
+
outdir: this.#opt.pkgPath,
|
|
526
525
|
write: false,
|
|
527
526
|
platform: 'browser',
|
|
528
|
-
target: this
|
|
527
|
+
target: this.#browserTarget,
|
|
529
528
|
preserveSymlinks: false,
|
|
530
529
|
external: [],
|
|
531
530
|
conditions: ['style', 'sass'],
|
|
532
531
|
mainFields: ['style', 'sass'],
|
|
533
|
-
legalComments: !this.
|
|
532
|
+
legalComments: !this.#opt.dev ? "none" : "eof",
|
|
534
533
|
entryPoints: {
|
|
535
534
|
// styles: 'angular:styles/global;styles'
|
|
536
|
-
styles: path.resolve(this.
|
|
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.
|
|
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.
|
|
557
|
-
absWorkingDir: this.
|
|
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.
|
|
563
|
+
legalComments: this.#opt.dev ? 'eof' : 'none',
|
|
565
564
|
logLevel: 'silent',
|
|
566
|
-
minify: !this.
|
|
567
|
-
outdir: this.
|
|
568
|
-
sourcemap: true, //this.
|
|
569
|
-
tsconfig: this
|
|
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.
|
|
575
|
-
'process.env.SD_VERSION': JSON.stringify(this.
|
|
576
|
-
"process.env.NODE_ENV": JSON.stringify(this.
|
|
577
|
-
...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(
|
|
578
577
|
key => `process.env.${key}`,
|
|
579
|
-
key => JSON.stringify(this.
|
|
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.
|
|
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 {
|
|
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:
|
|
14
|
+
#resultCache: IServerPluginResultCache = {};
|
|
15
15
|
|
|
16
16
|
constructor(private readonly _opt: {
|
|
17
17
|
dev: boolean;
|