@ng-prism/core 21.5.0 → 21.5.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"prism-pipeline.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/prism-pipeline.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,mBAAmB,IAAI,kBAAkB,CAExD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAmD9B"}
1
+ {"version":3,"file":"prism-pipeline.d.ts","sourceRoot":"","sources":["../../../src/builder/shared/prism-pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhE,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,wBAAgB,mBAAmB,IAAI,kBAAkB,CAExD;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAmD9B"}
@@ -1,5 +1,6 @@
1
- import { join } from 'path';
1
+ import { join, dirname } from 'path';
2
2
  import { writeFileSync, readFileSync, mkdirSync, statSync, renameSync, existsSync, unlinkSync } from 'fs';
3
+ import ts from 'typescript';
3
4
  import { createScanner } from '../scanner/scanner.js';
4
5
  import { discoverSecondaryEntryPoints } from '../scanner/entry-point-discovery.js';
5
6
  import { loadConfig } from '../config-loader/config-loader.js';
@@ -68,15 +69,31 @@ function isDirectory(path) {
68
69
  return false;
69
70
  }
70
71
  }
72
+ function resolveTsconfigPaths(entryPointDir) {
73
+ const configPath = ts.findConfigFile(entryPointDir, ts.sys.fileExists, 'tsconfig.json');
74
+ if (!configPath)
75
+ return {};
76
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
77
+ if (configFile.error)
78
+ return {};
79
+ const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, dirname(configPath));
80
+ const result = {};
81
+ if (parsed.options.paths)
82
+ result.paths = parsed.options.paths;
83
+ if (parsed.options.baseUrl)
84
+ result.baseUrl = parsed.options.baseUrl;
85
+ return result;
86
+ }
71
87
  function scanEntryPoints(workspaceRoot, options, state) {
72
88
  const absoluteEntryPoint = join(workspaceRoot, options.entryPoint);
89
+ const pathOptions = resolveTsconfigPaths(dirname(absoluteEntryPoint));
73
90
  if (!isDirectory(absoluteEntryPoint)) {
74
- return getOrCreateScanner(state, absoluteEntryPoint).scan();
91
+ return getOrCreateScanner(state, absoluteEntryPoint, pathOptions).scan();
75
92
  }
76
93
  const entryPoints = discoverSecondaryEntryPoints(absoluteEntryPoint, options.libraryImportPath);
77
94
  const allComponents = [];
78
95
  for (const ep of entryPoints) {
79
- const scanner = getOrCreateScanner(state, ep.entryFile);
96
+ const scanner = getOrCreateScanner(state, ep.entryFile, pathOptions);
80
97
  const result = scanner.scan();
81
98
  for (const comp of result.components) {
82
99
  comp.importPath = ep.importPath;
@@ -85,10 +102,10 @@ function scanEntryPoints(workspaceRoot, options, state) {
85
102
  }
86
103
  return { components: allComponents };
87
104
  }
88
- function getOrCreateScanner(state, entryFile) {
105
+ function getOrCreateScanner(state, entryFile, compilerOptions) {
89
106
  let scanner = state.scanners.get(entryFile);
90
107
  if (!scanner) {
91
- scanner = createScanner({ entryPoint: entryFile });
108
+ scanner = createScanner({ entryPoint: entryFile, compilerOptions });
92
109
  state.scanners.set(entryFile, scanner);
93
110
  }
94
111
  return scanner;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-prism/core",
3
- "version": "21.5.0",
3
+ "version": "21.5.1",
4
4
  "description": "Lightweight Angular-native component showcase — no story files needed.",
5
5
  "keywords": [
6
6
  "angular",