@simplysm/sd-cli 12.5.6 → 12.5.8

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 (51) hide show
  1. package/dist/build-tools/SdCliIndexFileGenerator.js +4 -7
  2. package/dist/build-tools/SdCliIndexFileGenerator.js.map +1 -1
  3. package/dist/build-tools/SdCliNgRoutesFileGenerator.d.ts +2 -2
  4. package/dist/build-tools/SdCliNgRoutesFileGenerator.js +22 -13
  5. package/dist/build-tools/SdCliNgRoutesFileGenerator.js.map +1 -1
  6. package/dist/build-tools/SdLinter.js +2 -1
  7. package/dist/build-tools/SdLinter.js.map +1 -1
  8. package/dist/build-tools/SdNgBundler.d.ts +0 -1
  9. package/dist/build-tools/SdNgBundler.js +4 -2
  10. package/dist/build-tools/SdNgBundler.js.map +1 -1
  11. package/dist/build-tools/SdReactBundler.d.ts +24 -0
  12. package/dist/build-tools/SdReactBundler.js +251 -0
  13. package/dist/build-tools/SdReactBundler.js.map +1 -0
  14. package/dist/build-tools/SdReactBundlerContext.d.ts +14 -0
  15. package/dist/build-tools/SdReactBundlerContext.js +59 -0
  16. package/dist/build-tools/SdReactBundlerContext.js.map +1 -0
  17. package/dist/build-tools/SdTsCompiler.js +32 -29
  18. package/dist/build-tools/SdTsCompiler.js.map +1 -1
  19. package/dist/build-tools/SdTsLibBundler.js +4 -3
  20. package/dist/build-tools/SdTsLibBundler.js.map +1 -1
  21. package/dist/builders/SdCliClientBuilder.js +53 -32
  22. package/dist/builders/SdCliClientBuilder.js.map +1 -1
  23. package/dist/builders/SdCliTsLibBuilder.js +8 -11
  24. package/dist/builders/SdCliTsLibBuilder.js.map +1 -1
  25. package/dist/bundle-plugins/sdNgPlugin.js +21 -11
  26. package/dist/bundle-plugins/sdNgPlugin.js.map +1 -1
  27. package/dist/bundle-plugins/sdReactPlugin.d.ts +15 -0
  28. package/dist/bundle-plugins/sdReactPlugin.js +111 -0
  29. package/dist/bundle-plugins/sdReactPlugin.js.map +1 -0
  30. package/dist/commons.d.ts +1 -2
  31. package/dist/entry/SdCliProject.js +1 -0
  32. package/dist/entry/SdCliProject.js.map +1 -1
  33. package/dist/index.d.ts +3 -0
  34. package/dist/index.js +3 -0
  35. package/dist/index.js.map +1 -1
  36. package/package.json +12 -5
  37. package/src/build-tools/SdCliIndexFileGenerator.ts +10 -12
  38. package/src/build-tools/SdCliNgRoutesFileGenerator.ts +33 -22
  39. package/src/build-tools/SdLinter.ts +2 -1
  40. package/src/build-tools/SdNgBundler.ts +4 -3
  41. package/src/build-tools/SdReactBundler.ts +325 -0
  42. package/src/build-tools/SdReactBundlerContext.ts +71 -0
  43. package/src/build-tools/SdTsCompiler.ts +146 -129
  44. package/src/build-tools/SdTsLibBundler.ts +9 -13
  45. package/src/builders/SdCliClientBuilder.ts +108 -69
  46. package/src/builders/SdCliTsLibBuilder.ts +35 -32
  47. package/src/bundle-plugins/sdNgPlugin.ts +59 -56
  48. package/src/bundle-plugins/sdReactPlugin.ts +157 -0
  49. package/src/commons.ts +1 -2
  50. package/src/entry/SdCliProject.ts +1 -0
  51. package/src/index.ts +3 -0
@@ -1,14 +1,14 @@
1
- import ts, {CompilerOptions} from "typescript";
1
+ import ts, { CompilerOptions } from "typescript";
2
2
  import path from "path";
3
- import {FsUtil, Logger, PathUtil} from "@simplysm/sd-core-node";
4
- import browserslist from "browserslist";
5
- import {NeverEntryError, StringUtil} from "@simplysm/sd-core-common";
3
+ import { FsUtil, Logger, PathUtil } from "@simplysm/sd-core-node";
4
+ import { NeverEntryError, StringUtil } from "@simplysm/sd-core-common";
6
5
  import esbuild from "esbuild";
7
- import {NgtscProgram, OptimizeFor} from "@angular/compiler-cli";
8
- import {createHash} from "crypto";
9
- import {ComponentStylesheetBundler} from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
10
- import {AngularCompilerHost} from "@angular/build/src/tools/angular/angular-host";
11
- import {transformSupportedBrowsersToTargets} from "@angular/build/src/tools/esbuild/utils";
6
+ import { NgtscProgram, OptimizeFor } from "@angular/compiler-cli";
7
+ import { createHash } from "crypto";
8
+ import { ComponentStylesheetBundler } from "@angular/build/src/tools/esbuild/angular/component-stylesheets";
9
+ import { AngularCompilerHost } from "@angular/build/src/tools/angular/angular-host";
10
+ import { transformSupportedBrowsersToTargets } from "@angular/build/src/tools/esbuild/utils";
11
+ import browserslist from "browserslist";
12
12
 
13
13
  export class SdTsCompiler {
14
14
  readonly #logger = Logger.get(["simplysm", "sd-cli", "SdTsCompiler"]);
@@ -19,17 +19,19 @@ export class SdTsCompiler {
19
19
  readonly #revDependencyCacheMap = new Map<string, Set<string>>();
20
20
  readonly #resourceDependencyCacheMap = new Map<string, Set<string>>();
21
21
  readonly #sourceFileCacheMap = new Map<string, ts.SourceFile>();
22
- readonly #emittedFilesCacheMap = new Map<string, {
23
- outAbsPath?: string;
24
- text: string;
25
- }[]>();
22
+ readonly #emittedFilesCacheMap = new Map<
23
+ string,
24
+ {
25
+ outAbsPath?: string;
26
+ text: string;
27
+ }[]
28
+ >();
26
29
 
27
30
  readonly #stylesheetBundler: ComponentStylesheetBundler | undefined;
28
31
  readonly #compilerHost: ts.CompilerHost | AngularCompilerHost;
29
32
 
30
33
  #ngProgram: NgtscProgram | undefined;
31
34
  #program: ts.Program | undefined;
32
- // #builder: ts.EmitAndSemanticDiagnosticsBuilderProgram | undefined;
33
35
 
34
36
  readonly #modifiedFileSet = new Set<string>();
35
37
 
@@ -40,23 +42,20 @@ export class SdTsCompiler {
40
42
  readonly #distPath: string;
41
43
  readonly #globalStyleFilePath?: string;
42
44
 
43
- constructor(pkgPath: string,
44
- additionalOptions: CompilerOptions,
45
- isDevMode: boolean,
46
- globalStyleFilePath?: string) {
45
+ constructor(pkgPath: string, additionalOptions: CompilerOptions, isDevMode: boolean, globalStyleFilePath?: string) {
47
46
  this.#pkgPath = pkgPath;
48
47
  this.#globalStyleFilePath = globalStyleFilePath != null ? path.normalize(globalStyleFilePath) : undefined;
49
48
 
50
49
  this.#debug("초기화...");
51
50
 
52
- //-- isForAngular / parsedTsConfig
51
+ //-- isForAngular / parsedTsConfig / isForReact
53
52
 
54
53
  const tsconfigPath = path.resolve(pkgPath, "tsconfig.json");
55
54
  const tsconfig = FsUtil.readJson(tsconfigPath);
56
55
  this.#isForAngular = Boolean(tsconfig.angularCompilerOptions);
57
56
  this.#parsedTsconfig = ts.parseJsonConfigFileContent(tsconfig, ts.sys, pkgPath, {
58
57
  ...tsconfig.angularCompilerOptions,
59
- ...additionalOptions
58
+ ...additionalOptions,
60
59
  });
61
60
 
62
61
  this.#distPath = this.#parsedTsconfig.options.outDir ?? path.resolve(pkgPath, "dist");
@@ -66,24 +65,22 @@ export class SdTsCompiler {
66
65
  this.#compilerHost = ts.createCompilerHost(this.#parsedTsconfig.options);
67
66
 
68
67
  const baseGetSourceFile = this.#compilerHost.getSourceFile;
69
- this.#compilerHost.getSourceFile = (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile, ...args) => {
68
+ this.#compilerHost.getSourceFile = (
69
+ fileName,
70
+ languageVersionOrOptions,
71
+ onError,
72
+ shouldCreateNewSourceFile,
73
+ ...args
74
+ ) => {
70
75
  if (!shouldCreateNewSourceFile && this.#sourceFileCacheMap.has(path.normalize(fileName))) {
71
76
  return this.#sourceFileCacheMap.get(path.normalize(fileName));
72
77
  }
73
78
 
74
- const sf = baseGetSourceFile.call(
75
- this.#compilerHost,
76
- fileName,
77
- languageVersionOrOptions,
78
- onError,
79
- true,
80
- ...args,
81
- );
79
+ const sf = baseGetSourceFile.call(this.#compilerHost, fileName, languageVersionOrOptions, onError, true, ...args);
82
80
 
83
81
  if (sf) {
84
82
  this.#sourceFileCacheMap.set(path.normalize(fileName), sf);
85
- }
86
- else {
83
+ } else {
87
84
  this.#sourceFileCacheMap.delete(path.normalize(fileName));
88
85
  }
89
86
 
@@ -98,27 +95,28 @@ export class SdTsCompiler {
98
95
 
99
96
  if (this.#isForAngular) {
100
97
  //-- stylesheetBundler
101
-
102
- const browserTarget = transformSupportedBrowsersToTargets(browserslist("defaults and fully supports es6-module"));
103
98
  this.#stylesheetBundler = new ComponentStylesheetBundler(
104
99
  {
105
100
  workspaceRoot: pkgPath,
106
101
  optimization: !isDevMode,
107
102
  inlineFonts: true,
108
103
  preserveSymlinks: false,
109
- sourcemap: 'inline', //conf.dev ? 'inline' : false,
110
- outputNames: {bundles: '[name]', media: 'media/[name]'},
104
+ sourcemap: "inline", //conf.dev ? 'inline' : false,
105
+ outputNames: { bundles: "[name]", media: "media/[name]" },
111
106
  includePaths: [],
112
107
  externalDependencies: [],
113
- target: browserTarget,
108
+ target: transformSupportedBrowsersToTargets(browserslist(["Chrome > 78"])),
109
+ postcssConfiguration: {
110
+ plugins: [["css-has-pseudo"]],
111
+ },
114
112
  tailwindConfiguration: undefined,
115
113
  cacheOptions: {
116
114
  enabled: true,
117
115
  path: ".cache/angular",
118
- basePath: ".cache"
119
- }
116
+ basePath: ".cache",
117
+ },
120
118
  },
121
- isDevMode
119
+ isDevMode,
122
120
  );
123
121
 
124
122
  //-- compilerHost
@@ -127,18 +125,21 @@ export class SdTsCompiler {
127
125
  return this.#compilerHost.readFile(fileName) ?? "";
128
126
  };
129
127
 
130
- (this.#compilerHost as AngularCompilerHost).transformResource = async (data: string, context: {
131
- type: string,
132
- containingFile: string,
133
- resourceFile: string | null
134
- }) => {
128
+ (this.#compilerHost as AngularCompilerHost).transformResource = async (
129
+ data: string,
130
+ context: {
131
+ type: string;
132
+ containingFile: string;
133
+ resourceFile: string | null;
134
+ },
135
+ ) => {
135
136
  if (context.type !== "style") {
136
137
  return null;
137
138
  }
138
139
 
139
140
  const contents = await this.#bundleStylesheetAsync(data, context.containingFile, context.resourceFile);
140
141
 
141
- return StringUtil.isNullOrEmpty(contents) ? null : {content: contents};
142
+ return StringUtil.isNullOrEmpty(contents) ? null : { content: contents };
142
143
  };
143
144
 
144
145
  (this.#compilerHost as AngularCompilerHost).getModifiedResourceFiles = () => {
@@ -154,35 +155,37 @@ export class SdTsCompiler {
154
155
 
155
156
  this.#debug(`스타일시트 번들링...(${containingFile}, ${resourceFile})`);
156
157
 
157
- const stylesheetResult = resourceFile != null
158
- ? await this.#stylesheetBundler!.bundleFile(resourceFile)
159
- : await this.#stylesheetBundler!.bundleInline(
160
- data,
161
- containingFile,
162
- "scss",
163
- );
158
+ const stylesheetResult =
159
+ resourceFile != null
160
+ ? await this.#stylesheetBundler!.bundleFile(resourceFile)
161
+ : await this.#stylesheetBundler!.bundleInline(data, containingFile, "scss");
164
162
 
165
163
  if (stylesheetResult.referencedFiles) {
166
164
  for (const referencedFile of stylesheetResult.referencedFiles) {
167
- const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(path.normalize(referencedFile), new Set<string>());
165
+ const depCacheSet = this.#resourceDependencyCacheMap.getOrCreate(
166
+ path.normalize(referencedFile),
167
+ new Set<string>(),
168
+ );
168
169
  depCacheSet.add(path.normalize(resourceFile ?? containingFile));
169
170
  }
170
171
 
171
- this.#watchFileSet.adds(...Array.from(stylesheetResult.referencedFiles.values()).map(item => path.normalize(item)));
172
+ this.#watchFileSet.adds(
173
+ ...Array.from(stylesheetResult.referencedFiles.values()).map((item) => path.normalize(item)),
174
+ );
172
175
  }
173
176
 
174
177
  this.#stylesheetBundlingResultMap.set(path.normalize(resourceFile ?? containingFile), {
175
178
  outputFiles: stylesheetResult.outputFiles,
176
179
  metafile: stylesheetResult.metafile,
177
180
  errors: stylesheetResult.errors,
178
- warnings: stylesheetResult.warnings
181
+ warnings: stylesheetResult.warnings,
179
182
  });
180
183
 
181
184
  return stylesheetResult.contents;
182
185
  }
183
186
 
184
187
  invalidate(modifiedFileSet: Set<string>) {
185
- this.#modifiedFileSet.adds(...Array.from(modifiedFileSet).map(item => path.normalize(item)));
188
+ this.#modifiedFileSet.adds(...Array.from(modifiedFileSet).map((item) => path.normalize(item)));
186
189
  }
187
190
 
188
191
  async buildAsync(): Promise<ISdTsCompilerResult> {
@@ -219,16 +222,15 @@ export class SdTsCompiler {
219
222
  this.#parsedTsconfig.fileNames,
220
223
  this.#parsedTsconfig.options,
221
224
  this.#compilerHost,
222
- this.#ngProgram
225
+ this.#ngProgram,
223
226
  );
224
227
  this.#program = this.#ngProgram.getTsProgram();
225
- }
226
- else {
228
+ } else {
227
229
  this.#program = ts.createProgram(
228
230
  this.#parsedTsconfig.fileNames,
229
231
  this.#parsedTsconfig.options,
230
232
  this.#compilerHost,
231
- this.#program
233
+ this.#program,
232
234
  );
233
235
  }
234
236
 
@@ -252,8 +254,8 @@ export class SdTsCompiler {
252
254
  }
253
255
 
254
256
  const getOrgSourceFile = (sf: ts.SourceFile) => {
255
- if (sf.fileName.endsWith('.ngtypecheck.ts')) {
256
- const orgFileName = sf.fileName.slice(0, -15) + '.ts';
257
+ if (sf.fileName.endsWith(".ngtypecheck.ts")) {
258
+ const orgFileName = sf.fileName.slice(0, -15) + ".ts";
257
259
  return this.#program!.getSourceFile(orgFileName);
258
260
  }
259
261
 
@@ -262,15 +264,21 @@ export class SdTsCompiler {
262
264
 
263
265
  this.#debug(`get affected (new deps)...`);
264
266
 
265
- const sourceFileSet = new Set(this.#program.getSourceFiles()
266
- .map(sf => getOrgSourceFile(sf))
267
- .filterExists());
267
+ const sourceFileSet = new Set(
268
+ this.#program
269
+ .getSourceFiles()
270
+ .map((sf) => getOrgSourceFile(sf))
271
+ .filterExists(),
272
+ );
268
273
 
269
- const depMap = new Map<string, {
270
- fileName: string;
271
- importName: string;
272
- exportName?: string;
273
- }[]>();
274
+ const depMap = new Map<
275
+ string,
276
+ {
277
+ fileName: string;
278
+ importName: string;
279
+ exportName?: string;
280
+ }[]
281
+ >();
274
282
  for (const sf of sourceFileSet) {
275
283
  const refs = this.#findDeps(sf);
276
284
  depMap.set(path.normalize(sf.fileName), refs);
@@ -285,21 +293,20 @@ export class SdTsCompiler {
285
293
  const result = new Set<string>();
286
294
 
287
295
  const deps = depMap.get(fileName) ?? [];
288
- result.adds(...deps.map(item => item.fileName));
296
+ result.adds(...deps.map((item) => item.fileName));
289
297
 
290
298
  for (const dep of deps) {
291
299
  const targetDeps = depMap.get(dep.fileName) ?? [];
292
300
 
293
301
  if (dep.importName === "*") {
294
- for (const targetRefItem of targetDeps.filter(item => item.exportName != null)) {
302
+ for (const targetRefItem of targetDeps.filter((item) => item.exportName != null)) {
295
303
  if (prevSet?.has(targetRefItem.fileName)) continue;
296
304
 
297
305
  result.add(targetRefItem.fileName);
298
306
  result.adds(...getAllDeps(targetRefItem.fileName, new Set<string>(prevSet).adds(...result)));
299
307
  }
300
- }
301
- else {
302
- for (const targetRefItem of targetDeps.filter(item => item.exportName === dep.importName)) {
308
+ } else {
309
+ for (const targetRefItem of targetDeps.filter((item) => item.exportName === dep.importName)) {
303
310
  if (prevSet?.has(targetRefItem.fileName)) continue;
304
311
 
305
312
  result.add(targetRefItem.fileName);
@@ -356,7 +363,7 @@ export class SdTsCompiler {
356
363
  diagnostics.push(
357
364
  ...this.#program.getConfigFileParsingDiagnostics(),
358
365
  ...this.#program.getOptionsDiagnostics(),
359
- ...this.#program.getGlobalDiagnostics()
366
+ ...this.#program.getGlobalDiagnostics(),
360
367
  );
361
368
 
362
369
  if (this.#ngProgram) {
@@ -365,13 +372,16 @@ export class SdTsCompiler {
365
372
 
366
373
  for (const affectedFile of affectedFileSet) {
367
374
  const affectedSourceFile = this.#program.getSourceFile(affectedFile);
368
- if (!affectedSourceFile || (this.#ngProgram && this.#ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))) {
375
+ if (
376
+ !affectedSourceFile ||
377
+ (this.#ngProgram && this.#ngProgram.compiler.ignoreForDiagnostics.has(affectedSourceFile))
378
+ ) {
369
379
  continue;
370
380
  }
371
381
 
372
382
  diagnostics.push(
373
383
  ...this.#program.getSyntacticDiagnostics(affectedSourceFile),
374
- ...this.#program.getSemanticDiagnostics(affectedSourceFile)
384
+ ...this.#program.getSemanticDiagnostics(affectedSourceFile),
375
385
  );
376
386
 
377
387
  if (this.#ngProgram) {
@@ -415,53 +425,61 @@ export class SdTsCompiler {
415
425
  }
416
426
 
417
427
  this.#debug(`emit for`, sf.fileName);
418
- this.#program.emit(sf, (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
419
- if (!sourceFiles || sourceFiles.length === 0) {
420
- this.#compilerHost.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
421
- return;
422
- }
423
-
424
- const sourceFile = ts.getOriginalNode(sourceFiles[0], ts.isSourceFile);
425
- if (this.#ngProgram) {
426
- if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) {
428
+ this.#program.emit(
429
+ sf,
430
+ (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
431
+ if (!sourceFiles || sourceFiles.length === 0) {
432
+ this.#compilerHost.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
427
433
  return;
428
434
  }
429
- this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
430
- }
431
435
 
432
- const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(path.normalize(sourceFile.fileName), []);
433
- if (PathUtil.isChildPath(sourceFile.fileName, this.#pkgPath)) {
434
- let realFilePath = fileName;
435
- let realText = text;
436
- if (PathUtil.isChildPath(realFilePath, path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"))) {
437
- realFilePath = path.resolve(this.#distPath, path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath));
438
-
439
- if (fileName.endsWith(".js.map")) {
440
- const sourceMapContents = JSON.parse(realText);
441
- // remove "../../"
442
- sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
443
- realText = JSON.stringify(sourceMapContents);
436
+ const sourceFile = ts.getOriginalNode(sourceFiles[0], ts.isSourceFile);
437
+ if (this.#ngProgram) {
438
+ if (this.#ngProgram.compiler.ignoreForEmit.has(sourceFile)) {
439
+ return;
444
440
  }
441
+ this.#ngProgram.compiler.incrementalCompilation.recordSuccessfulEmit(sourceFile);
445
442
  }
446
443
 
447
- emitFileInfoCaches.push({
448
- outAbsPath: realFilePath,
449
- text: realText
450
- });
451
- }
452
- else {
453
- emitFileInfoCaches.push({text});
454
- }
444
+ const emitFileInfoCaches = this.#emittedFilesCacheMap.getOrCreate(path.normalize(sourceFile.fileName), []);
445
+ if (PathUtil.isChildPath(sourceFile.fileName, this.#pkgPath)) {
446
+ let realFilePath = fileName;
447
+ let realText = text;
448
+ if (PathUtil.isChildPath(realFilePath, path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"))) {
449
+ realFilePath = path.resolve(
450
+ this.#distPath,
451
+ path.relative(path.resolve(this.#distPath, path.basename(this.#pkgPath), "src"), realFilePath),
452
+ );
453
+
454
+ if (fileName.endsWith(".js.map")) {
455
+ const sourceMapContents = JSON.parse(realText);
456
+ // remove "../../"
457
+ sourceMapContents.sources[0] = sourceMapContents.sources[0].slice(6);
458
+ realText = JSON.stringify(sourceMapContents);
459
+ }
460
+ }
455
461
 
456
- emitFileSet.add(path.normalize(sourceFile.fileName));
457
- }, undefined, undefined, ngTransformers);
462
+ emitFileInfoCaches.push({
463
+ outAbsPath: realFilePath,
464
+ text: realText,
465
+ });
466
+ } else {
467
+ emitFileInfoCaches.push({ text });
468
+ }
469
+
470
+ emitFileSet.add(path.normalize(sourceFile.fileName));
471
+ },
472
+ undefined,
473
+ undefined,
474
+ ngTransformers,
475
+ );
458
476
  }
459
477
 
460
478
  //-- global style
461
479
  if (
462
- this.#globalStyleFilePath != null
463
- && FsUtil.exists(this.#globalStyleFilePath)
464
- && !this.#emittedFilesCacheMap.has(this.#globalStyleFilePath)
480
+ this.#globalStyleFilePath != null &&
481
+ FsUtil.exists(this.#globalStyleFilePath) &&
482
+ !this.#emittedFilesCacheMap.has(this.#globalStyleFilePath)
465
483
  ) {
466
484
  this.#debug(`bundle global style...`);
467
485
 
@@ -469,8 +487,11 @@ export class SdTsCompiler {
469
487
  const contents = await this.#bundleStylesheetAsync(data, this.#globalStyleFilePath, this.#globalStyleFilePath);
470
488
  const emitFileInfos = this.#emittedFilesCacheMap.getOrCreate(this.#globalStyleFilePath, []);
471
489
  emitFileInfos.push({
472
- outAbsPath: path.resolve(this.#pkgPath, path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath).replace(/\.scss$/, ".css")),
473
- text: contents
490
+ outAbsPath: path.resolve(
491
+ this.#pkgPath,
492
+ path.relative(path.resolve(this.#pkgPath, "src"), this.#globalStyleFilePath).replace(/\.scss$/, ".css"),
493
+ ),
494
+ text: contents,
474
495
  });
475
496
  emitFileSet.add(this.#globalStyleFilePath);
476
497
  }
@@ -490,7 +511,7 @@ export class SdTsCompiler {
490
511
  emittedFilesCacheMap: this.#emittedFilesCacheMap,
491
512
  watchFileSet: this.#watchFileSet,
492
513
  affectedFileSet,
493
- emitFileSet
514
+ emitFileSet,
494
515
  };
495
516
  }
496
517
 
@@ -523,12 +544,11 @@ export class SdTsCompiler {
523
544
  deps.push({
524
545
  fileName: path.normalize(decl.getSourceFile().fileName),
525
546
  importName: el.name.text,
526
- exportName: el.propertyName?.text ?? el.name.text
547
+ exportName: el.propertyName?.text ?? el.name.text,
527
548
  });
528
549
  }
529
550
  }
530
- }
531
- else {
551
+ } else {
532
552
  if (!moduleSymbol.exports) {
533
553
  throw new NeverEntryError("1234");
534
554
  }
@@ -538,14 +558,13 @@ export class SdTsCompiler {
538
558
  deps.push({
539
559
  fileName: path.normalize(decl.getSourceFile().fileName),
540
560
  importName: key.toString(),
541
- exportName: key.toString()
561
+ exportName: key.toString(),
542
562
  });
543
563
  }
544
564
  }
545
565
  }
546
566
  }
547
- }
548
- else if (ts.isImportDeclaration(node)) {
567
+ } else if (ts.isImportDeclaration(node)) {
549
568
  const moduleSymbol = tc.getSymbolAtLocation(node.moduleSpecifier);
550
569
  if (!moduleSymbol) {
551
570
  if (ts.isStringLiteral(node.moduleSpecifier) && node.moduleSpecifier.text.startsWith("./")) {
@@ -557,8 +576,7 @@ export class SdTsCompiler {
557
576
  /*else {
558
577
  throw new NeverEntryError(`import moduleSymbol: ${sf.fileName} ${node.moduleSpecifier["text"]}`);
559
578
  }*/
560
- }
561
- else {
579
+ } else {
562
580
  const decls = moduleSymbol.getDeclarations();
563
581
  if (!decls) throw new NeverEntryError(`import decls: ${sf.fileName}`);
564
582
 
@@ -572,8 +590,7 @@ export class SdTsCompiler {
572
590
  });
573
591
  }
574
592
  }
575
- }
576
- else {
593
+ } else {
577
594
  for (const decl of decls) {
578
595
  deps.push({
579
596
  fileName: path.normalize(decl.getSourceFile().fileName),
@@ -593,7 +610,7 @@ export interface ISdTsCompilerResult {
593
610
  program: ts.Program;
594
611
  typescriptDiagnostics: ts.Diagnostic[];
595
612
  stylesheetBundlingResultMap: Map<string, IStylesheetBundlingResult>;
596
- emittedFilesCacheMap: Map<string, { outAbsPath?: string; text: string; }[]>;
613
+ emittedFilesCacheMap: Map<string, { outAbsPath?: string; text: string }[]>;
597
614
  watchFileSet: Set<string>;
598
615
 
599
616
  affectedFileSet: Set<string>;
@@ -605,4 +622,4 @@ interface IStylesheetBundlingResult {
605
622
  metafile?: esbuild.Metafile;
606
623
  errors?: esbuild.PartialMessage[];
607
624
  warnings?: esbuild.PartialMessage[];
608
- }
625
+ }
@@ -1,9 +1,9 @@
1
- import {SdCliBuildResultUtil} from "../utils/SdCliBuildResultUtil";
2
- import {ISdCliPackageBuildResult} from "../commons";
3
- import {SdTsCompiler} from "./SdTsCompiler";
1
+ import { SdCliBuildResultUtil } from "../utils/SdCliBuildResultUtil";
2
+ import { ISdCliPackageBuildResult } from "../commons";
3
+ import { SdTsCompiler } from "./SdTsCompiler";
4
4
  import ts from "typescript";
5
5
  import path from "path";
6
- import {FsUtil, PathUtil} from "@simplysm/sd-core-node";
6
+ import { FsUtil, PathUtil } from "@simplysm/sd-core-node";
7
7
 
8
8
  export class SdTsLibBundler {
9
9
  readonly #compiler: SdTsCompiler;
@@ -12,12 +12,7 @@ export class SdTsLibBundler {
12
12
 
13
13
  public constructor(pkgPath: string, dev: boolean) {
14
14
  this.#pkgPath = pkgPath;
15
- this.#compiler = new SdTsCompiler(
16
- pkgPath,
17
- {declaration: true},
18
- dev,
19
- path.resolve(pkgPath, "src/styles.scss")
20
- );
15
+ this.#compiler = new SdTsCompiler(pkgPath, { declaration: true }, dev, path.resolve(pkgPath, "src/styles.scss"));
21
16
  }
22
17
 
23
18
  public markChanges(modifiedFileSet: Set<string>): void {
@@ -59,11 +54,12 @@ export class SdTsLibBundler {
59
54
  affectedFileSet: buildResult.affectedFileSet,
60
55
  results: [
61
56
  ...buildResult.typescriptDiagnostics.map((item) => SdCliBuildResultUtil.convertFromTsDiag(item, "build")),
62
- ...Array.from(buildResult.stylesheetBundlingResultMap.values()).mapMany(item => item.errors ?? [])
63
- .map(err => SdCliBuildResultUtil.convertFromEsbuildResult(err, "build", "error")),
57
+ ...Array.from(buildResult.stylesheetBundlingResultMap.values())
58
+ .mapMany((item) => item.errors ?? [])
59
+ .map((err) => SdCliBuildResultUtil.convertFromEsbuildResult(err, "build", "error")),
64
60
  /*...Array.from(buildResult.stylesheetResultMap.values()).mapMany(item => item.warnings!)
65
61
  .map(warn => SdCliBuildResultUtil.convertFromEsbuildResult(warn, "build", "warning"))*/
66
- ]
62
+ ],
67
63
  };
68
64
  }
69
65
  }