@visulima/tsconfig 3.2.4 → 3.2.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## @visulima/tsconfig [3.2.5](https://github.com/visulima/visulima/compare/%40visulima%2Ftsconfig%403.2.4...%40visulima%2Ftsconfig%403.2.5) (2026-07-27)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/fs:** upgraded to 5.0.11
7
+
1
8
  ## @visulima/tsconfig [3.2.4](https://github.com/visulima/visulima/compare/%40visulima%2Ftsconfig%403.2.3...%40visulima%2Ftsconfig%403.2.4) (2026-07-27)
2
9
 
3
10
 
package/dist/index.d.ts CHANGED
@@ -4,32 +4,32 @@ import { WriteJsonOptions } from '@visulima/fs';
4
4
  type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
5
5
  type Options$1 = {
6
6
  /**
7
- * Make the configuration compatible with the specified TypeScript version.
8
- *
9
- * Controls *derived* defaults — fields TypeScript synthesizes when other
10
- * fields are set (e.g. `module: nodenext` ⇒ `moduleResolution: nodenext`).
11
- *
12
- * When `true`, it will make the configuration compatible with the latest TypeScript version.
13
- *
14
- * Supported version strings map to the version gates below — `"5.3"` is
15
- * intentionally absent because TypeScript 5.3 introduced no derived-default
16
- * changes over 5.2, so it would be a silent no-op.
17
- * @default undefined
18
- */
7
+ * Make the configuration compatible with the specified TypeScript version.
8
+ *
9
+ * Controls *derived* defaults — fields TypeScript synthesizes when other
10
+ * fields are set (e.g. `module: nodenext` ⇒ `moduleResolution: nodenext`).
11
+ *
12
+ * When `true`, it will make the configuration compatible with the latest TypeScript version.
13
+ *
14
+ * Supported version strings map to the version gates below — `"5.3"` is
15
+ * intentionally absent because TypeScript 5.3 introduced no derived-default
16
+ * changes over 5.2, so it would be a silent no-op.
17
+ * @default undefined
18
+ */
19
19
  tscCompatible?: "5.4" | "5.5" | "5.6" | "5.7" | "5.8" | "5.9" | "6.0" | "7.0" | true;
20
20
  /**
21
- * Apply the *unconditional* compiler-option defaults TypeScript would
22
- * synthesize for the given version (e.g. TS 6.0's `strict: true`,
23
- * `target: 'es2025'`, `moduleResolution: 'bundler'`).
24
- * - `'auto'` — auto-detect the installed TypeScript version by walking up
25
- * from the tsconfig directory (and consulting Yarn Berry pnp).
26
- * - `string` — pin to an explicit version (e.g. `'6.0.0'`, `'5.4'`).
27
- * - `false` (default) — do not apply unconditional defaults; preserves
28
- * prior behaviour where the parsed config matches `tsc --showConfig`.
29
- * Distinct from `tscCompatible`, which only governs derived defaults.
30
- * Both can be combined.
31
- * @default false
32
- */
21
+ * Apply the *unconditional* compiler-option defaults TypeScript would
22
+ * synthesize for the given version (e.g. TS 6.0's `strict: true`,
23
+ * `target: 'es2025'`, `moduleResolution: 'bundler'`).
24
+ * - `'auto'` — auto-detect the installed TypeScript version by walking up
25
+ * from the tsconfig directory (and consulting Yarn Berry pnp).
26
+ * - `string` — pin to an explicit version (e.g. `'6.0.0'`, `'5.4'`).
27
+ * - `false` (default) — do not apply unconditional defaults; preserves
28
+ * prior behaviour where the parsed config matches `tsc --showConfig`.
29
+ * Distinct from `tscCompatible`, which only governs derived defaults.
30
+ * Both can be combined.
31
+ * @default false
32
+ */
33
33
  typescriptVersion?: "auto" | false | (Record<never, never> & string);
34
34
  };
35
35
  declare const configDirectoryPlaceholder: string;
@@ -37,20 +37,20 @@ declare const implicitBaseUrlSymbol: symbol;
37
37
  declare const readTsConfig: (tsconfigPath: string, options?: Options$1) => TsConfigJsonResolved;
38
38
  type Options = {
39
39
  /**
40
- * Cache parsed configs across calls.
41
- * - `true` — use a process-wide shared cache.
42
- * - `Map` — use a caller-owned cache (useful for scoping / clearing).
43
- *
44
- * Cache keys embed the file's last-modified time, so editing a tsconfig
45
- * on disk transparently invalidates its cached entry.
46
- */
40
+ * Cache parsed configs across calls.
41
+ * - `true` — use a process-wide shared cache.
42
+ * - `Map` — use a caller-owned cache (useful for scoping / clearing).
43
+ *
44
+ * Cache keys embed the file's last-modified time, so editing a tsconfig
45
+ * on disk transparently invalidates its cached entry.
46
+ */
47
47
  cache?: Map<string, TsConfigResult> | boolean;
48
48
  /**
49
- * Name of the config file to search for. Defaults to `"tsconfig.json"`.
50
- *
51
- * The fallback to `jsconfig.json` only applies when this is left at the
52
- * default — supplying a custom name searches for that name only.
53
- */
49
+ * Name of the config file to search for. Defaults to `"tsconfig.json"`.
50
+ *
51
+ * The fallback to `jsconfig.json` only applies when this is left at the
52
+ * default — supplying a custom name searches for that name only.
53
+ */
54
54
  configFileName?: string;
55
55
  } & Options$1;
56
56
  type TsConfigResult = {
@@ -58,53 +58,53 @@ type TsConfigResult = {
58
58
  path: string;
59
59
  };
60
60
  /**
61
- * An asynchronous function that retrieves the TSConfig by searching for the "tsconfig.json" first,
62
- * second attempt is to look for the "jsconfig.json" file from a given current working directory.
63
- *
64
- * Note: only the upward file search is asynchronous. Parsing (and the whole
65
- * `extends` chain) is performed synchronously via {@link readTsConfig}, so a
66
- * very deep `extends` chain will block the event loop during parse.
67
- * @param cwd Optional. The current working directory from which to search for the "tsconfig.json" file.
68
- * The type of `cwd` is `string`.
69
- * @returns A `Promise` that resolves to the TSConfig result object.
70
- * The return type of the function is `Promise&lt;TsConfigResult>`.
71
- * @throws An `Error` when the "tsconfig.json" file is not found.
72
- */
61
+ * An asynchronous function that retrieves the TSConfig by searching for the "tsconfig.json" first,
62
+ * second attempt is to look for the "jsconfig.json" file from a given current working directory.
63
+ *
64
+ * Note: only the upward file search is asynchronous. Parsing (and the whole
65
+ * `extends` chain) is performed synchronously via {@link readTsConfig}, so a
66
+ * very deep `extends` chain will block the event loop during parse.
67
+ * @param cwd Optional. The current working directory from which to search for the "tsconfig.json" file.
68
+ * The type of `cwd` is `string`.
69
+ * @returns A `Promise` that resolves to the TSConfig result object.
70
+ * The return type of the function is `Promise&lt;TsConfigResult>`.
71
+ * @throws An `Error` when the "tsconfig.json" file is not found.
72
+ */
73
73
  declare const findTsConfig: (cwd?: URL | string, options?: Options) => Promise<TsConfigResult>;
74
74
  declare const findTsConfigSync: (cwd?: URL | string, options?: Options) => TsConfigResult;
75
75
  interface WriteTsConfigOptions extends WriteJsonOptions {
76
76
  /** The directory to write the config into. Defaults to `process.cwd()`. */
77
77
  cwd?: URL | string;
78
78
  /**
79
- * The file name to write. Defaults to `tsconfig.json`. Useful when emitting a derived project
80
- * file (e.g. `tsconfig.build.json`) next to an existing config.
81
- */
79
+ * The file name to write. Defaults to `tsconfig.json`. Useful when emitting a derived project
80
+ * file (e.g. `tsconfig.build.json`) next to an existing config.
81
+ */
82
82
  fileName?: string;
83
83
  /**
84
- * The TypeScript major version the written config targets. When set, compiler options removed in
85
- * that version are dropped — e.g. `7` removes `baseUrl` so the config is accepted by the
86
- * TypeScript 7 native compiler.
87
- */
84
+ * The TypeScript major version the written config targets. When set, compiler options removed in
85
+ * that version are dropped — e.g. `7` removes `baseUrl` so the config is accepted by the
86
+ * TypeScript 7 native compiler.
87
+ */
88
88
  typescriptMajor?: number;
89
89
  }
90
90
  /**
91
- * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig file.
92
- *
93
- * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
94
- * object (e.g. from `readTsConfig`) can be written back to a valid config.
95
- * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
96
- * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
97
- * @returns A `Promise` that resolves when the tsconfig file has been written.
98
- * The return type of function is `Promise&lt;void>`.
99
- */
91
+ * An asynchronous function that writes the provided TypeScript configuration object to a tsconfig file.
92
+ *
93
+ * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
94
+ * object (e.g. from `readTsConfig`) can be written back to a valid config.
95
+ * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
96
+ * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
97
+ * @returns A `Promise` that resolves when the tsconfig file has been written.
98
+ * The return type of function is `Promise&lt;void>`.
99
+ */
100
100
  declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteTsConfigOptions) => Promise<void>;
101
101
  /**
102
- * A function that writes the provided TypeScript configuration object to a tsconfig file.
103
- *
104
- * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
105
- * object (e.g. from `readTsConfig`) can be written back to a valid config.
106
- * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
107
- * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
108
- */
102
+ * A function that writes the provided TypeScript configuration object to a tsconfig file.
103
+ *
104
+ * Numeric enum compiler options are normalized to their string names, so a resolved `CompilerOptions`
105
+ * object (e.g. from `readTsConfig`) can be written back to a valid config.
106
+ * @param tsConfig The TypeScript configuration object to write. The type of `tsConfig` is `TsConfigJson`.
107
+ * @param options Optional. Write options plus the target directory (`cwd`), `fileName`, and `typescriptMajor`.
108
+ */
109
109
  declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteTsConfigOptions) => void;
110
110
  export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, type WriteTsConfigOptions, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{findTsConfig as r,findTsConfigSync as f}from"./packem_shared/findTsConfig-eQNXp6cy.js";import{configDirectoryPlaceholder as n,implicitBaseUrlSymbol as t,readTsConfig as c}from"./packem_shared/configDirectoryPlaceholder-BhSMyWHh.js";import{writeTsConfig as s,writeTsConfigSync as l}from"./packem_shared/writeTsConfig-CeJbHO7s.js";export{n as configDirectoryPlaceholder,r as findTsConfig,f as findTsConfigSync,t as implicitBaseUrlSymbol,c as readTsConfig,s as writeTsConfig,l as writeTsConfigSync};
1
+ import{findTsConfig as r,findTsConfigSync as f}from"./packem_shared/findTsConfig-CkDQW7LM.js";import{configDirectoryPlaceholder as n,implicitBaseUrlSymbol as t,readTsConfig as c}from"./packem_shared/configDirectoryPlaceholder-IL6BWezd.js";import{writeTsConfig as s,writeTsConfigSync as l}from"./packem_shared/writeTsConfig-CeJbHO7s.js";export{n as configDirectoryPlaceholder,r as findTsConfig,f as findTsConfigSync,t as implicitBaseUrlSymbol,c as readTsConfig,s as writeTsConfig,l as writeTsConfigSync};
@@ -0,0 +1 @@
1
+ import{createRequire as T}from"node:module";import{isAccessibleSync as O,findUpSync as W,readFileSync as P}from"@visulima/fs";import{NotFoundError as N}from"@visulima/fs/error";import{join as d,resolve as g,isAbsolute as E,dirname as R,relative as x,normalize as k,toNamespacedPath as q}from"@visulima/path";import{isRelative as z}from"@visulima/path/utils";import{parse as _}from"jsonc-parser";import{resolveExports as G}from"resolve-pkg-maps";let V;const B=o=>(V??=T(import.meta.url))(o),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=o=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,s]=w.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return w.getBuiltinModule(o)}return B(o)},{statSync:D}=U("node:fs"),H=U("node:module"),$=(o=process.cwd())=>{const{findPnpApi:i}=H;return i?i(o):void 0},K=o=>_(P(o,{buffer:!1})),S=(o,i,s,r)=>{const e=`resolveFromPackageJsonPath:${o}:${i}:${s?"yes":"no"}`;if(r?.has(e))return r.get(e);const m=K(o);if(!m)return;let t=i||"tsconfig.json";if(!s&&m.exports)try{const[l]=G(m.exports,i,["require","types"]);t=l}catch{return!1}else!i&&m.tsconfig&&(t=m.tsconfig);return t=d(o,"..",t),r?.set(e,t),t},F="package.json",j="tsconfig.json",Q=(o,i,s)=>{let r=o;if(o===".."&&(r=d(r,j)),o.startsWith(".")&&(r=g(i,r)),E(r)){if(O(r)){if(D(r).isFile())return r}else if(!r.endsWith(".json")){const u=`${r}.json`;if(O(u))return u}return}const[e="",...m]=o.split("/"),t=e.startsWith("@")?`${e}/${String(m.shift())}`:e,l=m.join("/"),n=$(i);if(n){const{resolveRequest:u}=n;try{if(t===o){const f=u(d(t,F),i);if(f){const y=S(f,l,!1,s);if(y&&O(y))return y}}else{let f;try{f=u(o,i,{extensions:[".json"]})}catch{f=u(d(o,j),i)}if(f)return f}}catch{}}const c=W(u=>{const f=d(g(u),"node_modules",t);if(O(f))return d("node_modules",t)},{cwd:i,type:"directory"});if(!c||!D(c).isDirectory())return;const p=d(c,F);if(O(p)){const u=S(p,l,!1,s);if(u===!1)return;if(u&&O(u)&&D(u).isFile())return u}const a=d(c,l),v=a.endsWith(".json");if(!v){const u=`${a}.json`;if(O(u))return u}if(O(a)){if(D(a).isDirectory()){const u=d(a,F);if(O(u)){const y=S(u,"",!0,s);if(y&&O(y))return y}const f=d(a,j);if(O(f))return f}else if(v)return a}},X=o=>{const i=g(o);let s;const r=$(i);if(r)try{s=r.resolveRequest("typescript/package.json",i)??void 0}catch{}if(s??=W(e=>d(e,"node_modules","typescript","package.json"),{cwd:i,type:"file"}),!!s)try{const e=_(P(s,{buffer:!1}));if(typeof e?.version=="string")return e.version}catch{}},Y=new Set(["node16","node18","node20","nodenext"]),J=o=>o!==void 0&&Y.has(o),Z=(o,i)=>{!i.has("target")&&!J(o.module)&&(o.target="es3")},oo=(o,i)=>{!i.has("target")&&!J(o.module)&&(o.target="es5")},eo=(o,i)=>{i.has("strict")||(o.strict=!0),i.has("target")||(o.target="es2025"),i.has("module")||(o.module="es2022"),i.has("moduleResolution")||(o.moduleResolution="bundler"),i.has("rootDir")||(o.rootDir="."),i.has("types")||(o.types=[]),i.has("noUncheckedSideEffectImports")||(o.noUncheckedSideEffectImports=!0),i.has("libReplacement")||(o.libReplacement=!1),i.has("alwaysStrict")||(o.alwaysStrict=!0)},to=(o,i)=>{i.has("module")||(o.module="esnext"),i.has("moduleResolution")||(o.moduleResolution="bundler"),i.has("stableTypeOrdering")||(o.stableTypeOrdering=!0)},io=[[4,Z],[5,oo],[6,eo],[7,to]],so=/^v?(\d+)/,ro=o=>{const i=so.exec(o);return i?Number(i[1]):void 0},no=(o,i)=>{const s=ro(i);if(s===void 0)return;const r=new Set(Object.keys(o));for(const[e,m]of io)e<=s&&m(o,r)},lo=o=>_(P(o,{buffer:!1})),co=o=>o.replaceAll("\\","/"),b=o=>{const i=q(o);return z(i)?i:`./${i}`},I=["files","include","exclude"],A=(o,i,s)=>{const r=d(i,s),e=x(o,r);return k(e)||"./"},po=(o,i,s)=>{const r=x(o,i);if(!r)return s;const e=s.startsWith("./")?s.slice(2):s;return`${r}/${e}`},mo=(o,i,s,r,e)=>{if(s.has(o))throw new Error(`Circularity detected while resolving configuration: ${o}`);s.add(o);const m=R(o),t=M(o,r,s,e);delete t.references;const{compilerOptions:l}=t;if(l){const{baseUrl:n}=l;n&&!n.startsWith(h)&&(l.baseUrl=A(i,m,n));const{outDir:c}=l;c&&!c.startsWith(h)&&(l.outDir=A(i,m,c))}for(const n of I){const c=t[n];c&&(t[n]=c.map(p=>p.startsWith(h)||E(p)?p:po(i,m,p)))}return t},M=(o,i,s=new Set,r=new Map)=>{let e;try{e=lo(o)??{}}catch(t){throw new Error(`Cannot resolve tsconfig at path: ${o}`,{cause:t})}if(typeof e!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${o}`);const m=R(o);if(e.compilerOptions){const{compilerOptions:t}=e;t.paths&&!t.baseUrl&&(t[Oo]=m)}if(e.extends){const t=Array.isArray(e.extends)?e.extends:[e.extends];delete e.extends;const l=t.toReversed();for(let n=0;n<l.length;n++){const c=l[n],p=Q(c,m,r);if(!p)throw new N(`No such file or directory, for '${c}' found.`);const a=mo(p,m,new Set(s),i,r);a.compilerOptions?.rootDir!==void 0&&!a.compilerOptions.rootDir.startsWith(h)&&(a.compilerOptions.rootDir=d(R(p),a.compilerOptions.rootDir));const v={...a,...e,compilerOptions:{...a.compilerOptions,...e.compilerOptions}};a.watchOptions&&(v.watchOptions={...a.watchOptions,...e.watchOptions}),e=v}}if(e.compilerOptions){const{compilerOptions:t}=e;for(const l of["baseUrl","rootDir"]){const n=t[l];if(n&&!n.startsWith(h)){const c=g(m,n);t[l]=b(x(m,c))}}for(const l of["outDir","declarationDir"]){let n=t[l];n&&(Array.isArray(e.exclude)||(e.exclude=["outDir","declarationDir"].map(c=>{const p=t[c];if(p)return p.startsWith(h)||E(p)?p:d(m,p)}).filter(Boolean)),n.startsWith(h)||(n=b(n)),t[l]=n)}}else e.compilerOptions={};if(e.include&&(e.include=e.include.map(t=>co(t))),e.files&&(e.files=e.files.map(t=>t.startsWith(h)?t:b(t))),e.watchOptions){const{watchOptions:t}=e;t.excludeDirectories&&(t.excludeDirectories=t.excludeDirectories.map(l=>k(g(m,l)))),t.excludeFiles&&(t.excludeFiles=t.excludeFiles.map(l=>k(g(m,l)))),t.watchFile&&(t.watchFile=t.watchFile.toLowerCase()),t.watchDirectory&&(t.watchDirectory=t.watchDirectory.toLowerCase()),t.fallbackPolling&&(t.fallbackPolling=t.fallbackPolling.toLowerCase())}if(e.compilerOptions.lib&&(e.compilerOptions.lib=e.compilerOptions.lib.map(t=>t.toLowerCase())),e.compilerOptions.module){let t=e.compilerOptions.module.toLowerCase();t==="es2015"&&(t="es6"),e.compilerOptions.module=t}if(e.compilerOptions.target){let t=e.compilerOptions.target.toLowerCase();t==="es2015"&&(t="es6"),e.compilerOptions.target=t}if(e.compilerOptions.moduleResolution){let t=e.compilerOptions.moduleResolution.toLowerCase();t==="node"&&(t="node10"),e.compilerOptions.moduleResolution=t}return e.compilerOptions.jsx&&(e.compilerOptions.jsx=e.compilerOptions.jsx.toLowerCase()),e.compilerOptions.moduleDetection&&(e.compilerOptions.moduleDetection=e.compilerOptions.moduleDetection.toLowerCase()),e.compilerOptions.importsNotUsedAsValues&&(e.compilerOptions.importsNotUsedAsValues=e.compilerOptions.importsNotUsedAsValues.toLowerCase()),e.compilerOptions.newLine&&(e.compilerOptions.newLine=e.compilerOptions.newLine.toLowerCase()),e},C=(o,i)=>{if(o.startsWith(h))return k(d(i,o.slice(h.length)))},ao=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],L=o=>o==="es2022"||o==="es2023"||o==="es2024"||o==="es2025"||o==="esnext",uo=(o,i)=>{if(o.compilerOptions===void 0)return o;if(o.compilerOptions.rewriteRelativeImportExtensions&&(o.compilerOptions.allowImportingTsExtensions??=!0),o.compilerOptions.composite&&(o.compilerOptions.declaration??=!0,o.compilerOptions.incremental??=!0),o.compilerOptions.checkJs&&(o.compilerOptions.allowJs??=!0),o.compilerOptions.verbatimModuleSyntax&&(o.compilerOptions.isolatedModules??=!0,o.compilerOptions.preserveConstEnums??=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))){if(o.compilerOptions.esModuleInterop===void 0&&(o.compilerOptions.module==="node16"||o.compilerOptions.module==="node18"||o.compilerOptions.module==="node20"||o.compilerOptions.module==="nodenext"||o.compilerOptions.module==="preserve")&&(o.compilerOptions.esModuleInterop=!0),o.compilerOptions.moduleDetection===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.moduleDetection="force"),o.compilerOptions.moduleResolution===void 0){let s="classic";if(o.compilerOptions.module!==void 0)switch(o.compilerOptions.module.toLocaleLowerCase()){case"commonjs":{s="node10";break}case"node16":case"node18":{s="node16";break}case"node20":{s="node16";break}case"nodenext":{s="nodenext";break}case"preserve":{s="bundler";break}}s!=="classic"&&(o.compilerOptions.moduleResolution=s)}if(o.compilerOptions.moduleResolution==="bundler"&&(o.compilerOptions.resolveJsonModule??=!0),o.compilerOptions.module&&["node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.resolveJsonModule??=!0),(o.compilerOptions.esModuleInterop||o.compilerOptions.module==="system"||o.compilerOptions.moduleResolution==="bundler")&&o.compilerOptions.allowSyntheticDefaultImports===void 0&&(o.compilerOptions.allowSyntheticDefaultImports=!0),["5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&o.compilerOptions.moduleResolution){let s=!1;["bundler","node16","nodenext"].includes(o.compilerOptions.moduleResolution.toLocaleLowerCase())&&(s=!0),o.compilerOptions.resolvePackageJsonExports===void 0&&s&&(o.compilerOptions.resolvePackageJsonExports=!0),o.compilerOptions.resolvePackageJsonImports===void 0&&s&&(o.compilerOptions.resolvePackageJsonImports=!0)}if(o.compilerOptions.target===void 0){let s="es5";switch(o.compilerOptions.module){case"node16":case"node18":{s="es2022";break}case"node20":{s="es2023";break}case"nodenext":{s="esnext";break}}s!=="es5"&&(o.compilerOptions.target=s)}o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.target&&L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!0)}if(["5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&o.compilerOptions.strict&&o.compilerOptions.strictBuiltinIteratorReturn===void 0&&(o.compilerOptions.strictBuiltinIteratorReturn=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&(o.compilerOptions.strict&&(o.compilerOptions.noImplicitAny=o.compilerOptions.noImplicitAny??!0,o.compilerOptions.noImplicitThis=o.compilerOptions.noImplicitThis??!0,o.compilerOptions.strictNullChecks=o.compilerOptions.strictNullChecks??!0,o.compilerOptions.strictFunctionTypes=o.compilerOptions.strictFunctionTypes??!0,o.compilerOptions.strictBindCallApply=o.compilerOptions.strictBindCallApply??!0,o.compilerOptions.strictPropertyInitialization=o.compilerOptions.strictPropertyInitialization??!0,o.compilerOptions.alwaysStrict=o.compilerOptions.alwaysStrict??!0),o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.target&&L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!0),o.compilerOptions.strict&&o.compilerOptions.useUnknownInCatchVariables===void 0&&(o.compilerOptions.useUnknownInCatchVariables=!0),o.compilerOptions.isolatedModules&&(o.compilerOptions.preserveConstEnums=o.compilerOptions.preserveConstEnums??!0)),["6.0","7.0","true"].includes(String(i?.tscCompatible))){if(o.compilerOptions.moduleDetection===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.moduleDetection="force"),o.compilerOptions.moduleResolution===void 0&&o.compilerOptions.module){const s=o.compilerOptions.module.toLocaleLowerCase();s==="node16"||s==="node18"||s==="node20"?o.compilerOptions.moduleResolution="node16":s==="nodenext"&&(o.compilerOptions.moduleResolution="nodenext")}if(o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&o.compilerOptions.target&&!L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!1),o.compilerOptions.isolatedModules&&o.compilerOptions.preserveConstEnums===void 0&&(o.compilerOptions.preserveConstEnums=!0),o.compilerOptions.resolveJsonModule===void 0){const s=o.compilerOptions.module,r=o.compilerOptions.moduleResolution?.toLocaleLowerCase();!(s!==void 0&&["node20","nodenext"].includes(s)||r==="bundler")&&r&&(o.compilerOptions.resolveJsonModule=!1)}if(o.compilerOptions.moduleResolution){const s=o.compilerOptions.moduleResolution.toLocaleLowerCase();["bundler","node16","nodenext"].includes(s)||(o.compilerOptions.resolvePackageJsonExports??=!1,o.compilerOptions.resolvePackageJsonImports??=!1)}}return o.compileOnSave===!1&&delete o.compileOnSave,o},fo=(o,i)=>{const s=o?.typescriptVersion;if(!(s===!1||s===void 0))return s==="auto"?X(i):s},h="${configDir}",Oo=Symbol("implicitBaseUrl"),Do=(o,i)=>{const s=g(o),r=M(s,i),e=R(s),m=fo(i,e);m&&r.compilerOptions&&no(r.compilerOptions,m);const{compilerOptions:t}=r;if(t){for(const n of ao){const c=t[n];if(c){const p=C(c,e);t[n]=p?b(x(e,p)):c}}for(const n of["rootDirs","typeRoots"]){const c=t[n];c&&(t[n]=c.map(p=>{const a=C(p,e);return a?b(x(e,a)):p}))}const{paths:l}=t;if(l){const n=Object.keys(l);for(let c=0;c<n.length;c++){const p=n[c];l[p]=l[p].map(a=>C(a,e)??a)}}}for(let l=0;l<I.length;l++){const n=I[l],c=r[n];c&&(r[n]=c.map(p=>C(p,e)??p))}return uo(r,i)};export{h as configDirectoryPlaceholder,Oo as implicitBaseUrlSymbol,Do as readTsConfig};
@@ -0,0 +1 @@
1
+ import{createRequire as m}from"node:module";import{findUp as a,findUpSync as p}from"@visulima/fs";import{NotFoundError as l}from"@visulima/fs/error";import{readTsConfig as d}from"./configDirectoryPlaceholder-IL6BWezd.js";let y;const j=t=>(y??=m(import.meta.url))(t),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=t=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[o,e]=f.versions.node.split(".").map(Number);if(o>22||o===22&&e>=3||o===20&&e>=16)return f.getBuiltinModule(t)}return j(t)},{statSync:b}=_("node:fs"),u=new Map,h="tsconfig.json",g=(t,o)=>{let e=0;try{e=b(t).mtimeMs}catch{}return`${t}::${String(o.tscCompatible)}::${String(o.typescriptVersion)}::${String(e)}`},S=async(t,o={})=>{const e=o.configFileName??h,i=o.configFileName===void 0;let c=await a(e,{...t&&{cwd:t},type:"file"});if(!c&&i&&(c=await a("jsconfig.json",{...t&&{cwd:t},type:"file"})),!c)throw new l(i?`No such file or directory, for '${e}' or 'jsconfig.json' found.`:`No such file or directory, for '${e}' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:u,r=g(c,o);if(o.cache&&n.has(r))return n.get(r);const s={config:d(c,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:c};return o.cache&&n.set(r,s),s},T=(t,o={})=>{const e=o.configFileName??h,i=o.configFileName===void 0;let c=p(e,{...t&&{cwd:t},type:"file"});if(!c&&i&&(c=p("jsconfig.json",{...t&&{cwd:t},type:"file"})),!c)throw new l(i?`No such file or directory, for '${e}' or 'jsconfig.json' found.`:`No such file or directory, for '${e}' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:u,r=g(c,o);if(o.cache&&n.has(r))return n.get(r);const s={config:d(c,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:c};return o.cache&&n.set(r,s),s};export{S as findTsConfig,T as findTsConfigSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/tsconfig",
3
- "version": "3.2.4",
3
+ "version": "3.2.5",
4
4
  "description": "Find and/or parse the tsconfig.json file from a directory path.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -52,7 +52,7 @@
52
52
  "provenance": true
53
53
  },
54
54
  "dependencies": {
55
- "@visulima/fs": "5.0.10",
55
+ "@visulima/fs": "5.0.11",
56
56
  "@visulima/path": "3.0.0",
57
57
  "jsonc-parser": "^3.3.1",
58
58
  "resolve-pkg-maps": "^1.0.0"
@@ -1 +0,0 @@
1
- import{createRequire as T}from"node:module";import{isAccessibleSync as O,findUpSync as $,readFileSync as P}from"@visulima/fs";import{NotFoundError as B}from"@visulima/fs/error";import{join as d,resolve as g,isAbsolute as E,dirname as k,relative as x,normalize as R,toNamespacedPath as N}from"@visulima/path";import{isRelative as q}from"@visulima/path/utils";import{parse as A}from"jsonc-parser";import{resolveExports as z}from"resolve-pkg-maps";const V=T(import.meta.url),w=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,W=o=>{if(typeof w<"u"&&w.versions&&w.versions.node){const[i,s]=w.versions.node.split(".").map(Number);if(i>22||i===22&&s>=3||i===20&&s>=16)return w.getBuiltinModule(o)}return V(o)},{statSync:D}=W("node:fs"),G=W("node:module"),J=(o=process.cwd())=>{const{findPnpApi:i}=G;return i?i(o):void 0},H=o=>A(P(o,{buffer:!1})),S=(o,i,s,r)=>{const e=`resolveFromPackageJsonPath:${o}:${i}:${s?"yes":"no"}`;if(r?.has(e))return r.get(e);const m=H(o);if(!m)return;let t=i||"tsconfig.json";if(!s&&m.exports)try{const[l]=z(m.exports,i,["require","types"]);t=l}catch{return!1}else!i&&m.tsconfig&&(t=m.tsconfig);return t=d(o,"..",t),r?.set(e,t),t},F="package.json",j="tsconfig.json",K=(o,i,s)=>{let r=o;if(o===".."&&(r=d(r,j)),o.startsWith(".")&&(r=g(i,r)),E(r)){if(O(r)){if(D(r).isFile())return r}else if(!r.endsWith(".json")){const u=`${r}.json`;if(O(u))return u}return}const[e="",...m]=o.split("/"),t=e.startsWith("@")?`${e}/${String(m.shift())}`:e,l=m.join("/"),n=J(i);if(n){const{resolveRequest:u}=n;try{if(t===o){const f=u(d(t,F),i);if(f){const y=S(f,l,!1,s);if(y&&O(y))return y}}else{let f;try{f=u(o,i,{extensions:[".json"]})}catch{f=u(d(o,j),i)}if(f)return f}}catch{}}const c=$(u=>{const f=d(g(u),"node_modules",t);if(O(f))return d("node_modules",t)},{cwd:i,type:"directory"});if(!c||!D(c).isDirectory())return;const p=d(c,F);if(O(p)){const u=S(p,l,!1,s);if(u===!1)return;if(u&&O(u)&&D(u).isFile())return u}const a=d(c,l),v=a.endsWith(".json");if(!v){const u=`${a}.json`;if(O(u))return u}if(O(a)){if(D(a).isDirectory()){const u=d(a,F);if(O(u)){const y=S(u,"",!0,s);if(y&&O(y))return y}const f=d(a,j);if(O(f))return f}else if(v)return a}},Q=o=>{const i=g(o);let s;const r=J(i);if(r)try{s=r.resolveRequest("typescript/package.json",i)??void 0}catch{}if(s??=$(e=>d(e,"node_modules","typescript","package.json"),{cwd:i,type:"file"}),!!s)try{const e=A(P(s,{buffer:!1}));if(typeof e?.version=="string")return e.version}catch{}},X=new Set(["node16","node18","node20","nodenext"]),M=o=>o!==void 0&&X.has(o),Y=(o,i)=>{!i.has("target")&&!M(o.module)&&(o.target="es3")},Z=(o,i)=>{!i.has("target")&&!M(o.module)&&(o.target="es5")},oo=(o,i)=>{i.has("strict")||(o.strict=!0),i.has("target")||(o.target="es2025"),i.has("module")||(o.module="es2022"),i.has("moduleResolution")||(o.moduleResolution="bundler"),i.has("rootDir")||(o.rootDir="."),i.has("types")||(o.types=[]),i.has("noUncheckedSideEffectImports")||(o.noUncheckedSideEffectImports=!0),i.has("libReplacement")||(o.libReplacement=!1),i.has("alwaysStrict")||(o.alwaysStrict=!0)},eo=(o,i)=>{i.has("module")||(o.module="esnext"),i.has("moduleResolution")||(o.moduleResolution="bundler"),i.has("stableTypeOrdering")||(o.stableTypeOrdering=!0)},to=[[4,Y],[5,Z],[6,oo],[7,eo]],io=/^v?(\d+)/,so=o=>{const i=io.exec(o);return i?Number(i[1]):void 0},ro=(o,i)=>{const s=so(i);if(s===void 0)return;const r=new Set(Object.keys(o));for(const[e,m]of to)e<=s&&m(o,r)},no=o=>A(P(o,{buffer:!1})),lo=o=>o.replaceAll("\\","/"),b=o=>{const i=N(o);return q(i)?i:`./${i}`},I=["files","include","exclude"],U=(o,i,s)=>{const r=d(i,s),e=x(o,r);return R(e)||"./"},co=(o,i,s)=>{const r=x(o,i);if(!r)return s;const e=s.startsWith("./")?s.slice(2):s;return`${r}/${e}`},po=(o,i,s,r,e)=>{if(s.has(o))throw new Error(`Circularity detected while resolving configuration: ${o}`);s.add(o);const m=k(o),t=_(o,r,s,e);delete t.references;const{compilerOptions:l}=t;if(l){const{baseUrl:n}=l;n&&!n.startsWith(h)&&(l.baseUrl=U(i,m,n));const{outDir:c}=l;c&&!c.startsWith(h)&&(l.outDir=U(i,m,c))}for(const n of I){const c=t[n];c&&(t[n]=c.map(p=>p.startsWith(h)||E(p)?p:co(i,m,p)))}return t},_=(o,i,s=new Set,r=new Map)=>{let e;try{e=no(o)??{}}catch(t){throw new Error(`Cannot resolve tsconfig at path: ${o}`,{cause:t})}if(typeof e!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${o}`);const m=k(o);if(e.compilerOptions){const{compilerOptions:t}=e;t.paths&&!t.baseUrl&&(t[fo]=m)}if(e.extends){const t=Array.isArray(e.extends)?e.extends:[e.extends];delete e.extends;const l=t.toReversed();for(let n=0;n<l.length;n++){const c=l[n],p=K(c,m,r);if(!p)throw new B(`No such file or directory, for '${c}' found.`);const a=po(p,m,new Set(s),i,r);a.compilerOptions?.rootDir!==void 0&&!a.compilerOptions.rootDir.startsWith(h)&&(a.compilerOptions.rootDir=d(k(p),a.compilerOptions.rootDir));const v={...a,...e,compilerOptions:{...a.compilerOptions,...e.compilerOptions}};a.watchOptions&&(v.watchOptions={...a.watchOptions,...e.watchOptions}),e=v}}if(e.compilerOptions){const{compilerOptions:t}=e;for(const l of["baseUrl","rootDir"]){const n=t[l];if(n&&!n.startsWith(h)){const c=g(m,n);t[l]=b(x(m,c))}}for(const l of["outDir","declarationDir"]){let n=t[l];n&&(Array.isArray(e.exclude)||(e.exclude=["outDir","declarationDir"].map(c=>{const p=t[c];if(p)return p.startsWith(h)||E(p)?p:d(m,p)}).filter(Boolean)),n.startsWith(h)||(n=b(n)),t[l]=n)}}else e.compilerOptions={};if(e.include&&(e.include=e.include.map(t=>lo(t))),e.files&&(e.files=e.files.map(t=>t.startsWith(h)?t:b(t))),e.watchOptions){const{watchOptions:t}=e;t.excludeDirectories&&(t.excludeDirectories=t.excludeDirectories.map(l=>R(g(m,l)))),t.excludeFiles&&(t.excludeFiles=t.excludeFiles.map(l=>R(g(m,l)))),t.watchFile&&(t.watchFile=t.watchFile.toLowerCase()),t.watchDirectory&&(t.watchDirectory=t.watchDirectory.toLowerCase()),t.fallbackPolling&&(t.fallbackPolling=t.fallbackPolling.toLowerCase())}if(e.compilerOptions.lib&&(e.compilerOptions.lib=e.compilerOptions.lib.map(t=>t.toLowerCase())),e.compilerOptions.module){let t=e.compilerOptions.module.toLowerCase();t==="es2015"&&(t="es6"),e.compilerOptions.module=t}if(e.compilerOptions.target){let t=e.compilerOptions.target.toLowerCase();t==="es2015"&&(t="es6"),e.compilerOptions.target=t}if(e.compilerOptions.moduleResolution){let t=e.compilerOptions.moduleResolution.toLowerCase();t==="node"&&(t="node10"),e.compilerOptions.moduleResolution=t}return e.compilerOptions.jsx&&(e.compilerOptions.jsx=e.compilerOptions.jsx.toLowerCase()),e.compilerOptions.moduleDetection&&(e.compilerOptions.moduleDetection=e.compilerOptions.moduleDetection.toLowerCase()),e.compilerOptions.importsNotUsedAsValues&&(e.compilerOptions.importsNotUsedAsValues=e.compilerOptions.importsNotUsedAsValues.toLowerCase()),e.compilerOptions.newLine&&(e.compilerOptions.newLine=e.compilerOptions.newLine.toLowerCase()),e},C=(o,i)=>{if(o.startsWith(h))return R(d(i,o.slice(h.length)))},mo=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],L=o=>o==="es2022"||o==="es2023"||o==="es2024"||o==="es2025"||o==="esnext",ao=(o,i)=>{if(o.compilerOptions===void 0)return o;if(o.compilerOptions.rewriteRelativeImportExtensions&&(o.compilerOptions.allowImportingTsExtensions??=!0),o.compilerOptions.composite&&(o.compilerOptions.declaration??=!0,o.compilerOptions.incremental??=!0),o.compilerOptions.checkJs&&(o.compilerOptions.allowJs??=!0),o.compilerOptions.verbatimModuleSyntax&&(o.compilerOptions.isolatedModules??=!0,o.compilerOptions.preserveConstEnums??=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))){if(o.compilerOptions.esModuleInterop===void 0&&(o.compilerOptions.module==="node16"||o.compilerOptions.module==="node18"||o.compilerOptions.module==="node20"||o.compilerOptions.module==="nodenext"||o.compilerOptions.module==="preserve")&&(o.compilerOptions.esModuleInterop=!0),o.compilerOptions.moduleDetection===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.moduleDetection="force"),o.compilerOptions.moduleResolution===void 0){let s="classic";if(o.compilerOptions.module!==void 0)switch(o.compilerOptions.module.toLocaleLowerCase()){case"commonjs":{s="node10";break}case"node16":case"node18":{s="node16";break}case"node20":{s="node16";break}case"nodenext":{s="nodenext";break}case"preserve":{s="bundler";break}}s!=="classic"&&(o.compilerOptions.moduleResolution=s)}if(o.compilerOptions.moduleResolution==="bundler"&&(o.compilerOptions.resolveJsonModule??=!0),o.compilerOptions.module&&["node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.resolveJsonModule??=!0),(o.compilerOptions.esModuleInterop||o.compilerOptions.module==="system"||o.compilerOptions.moduleResolution==="bundler")&&o.compilerOptions.allowSyntheticDefaultImports===void 0&&(o.compilerOptions.allowSyntheticDefaultImports=!0),["5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&o.compilerOptions.moduleResolution){let s=!1;["bundler","node16","nodenext"].includes(o.compilerOptions.moduleResolution.toLocaleLowerCase())&&(s=!0),o.compilerOptions.resolvePackageJsonExports===void 0&&s&&(o.compilerOptions.resolvePackageJsonExports=!0),o.compilerOptions.resolvePackageJsonImports===void 0&&s&&(o.compilerOptions.resolvePackageJsonImports=!0)}if(o.compilerOptions.target===void 0){let s="es5";switch(o.compilerOptions.module){case"node16":case"node18":{s="es2022";break}case"node20":{s="es2023";break}case"nodenext":{s="esnext";break}}s!=="es5"&&(o.compilerOptions.target=s)}o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.target&&L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!0)}if(["5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&o.compilerOptions.strict&&o.compilerOptions.strictBuiltinIteratorReturn===void 0&&(o.compilerOptions.strictBuiltinIteratorReturn=!0),["5.4","5.5","5.6","5.7","5.8","5.9"].includes(String(i?.tscCompatible))&&(o.compilerOptions.strict&&(o.compilerOptions.noImplicitAny=o.compilerOptions.noImplicitAny??!0,o.compilerOptions.noImplicitThis=o.compilerOptions.noImplicitThis??!0,o.compilerOptions.strictNullChecks=o.compilerOptions.strictNullChecks??!0,o.compilerOptions.strictFunctionTypes=o.compilerOptions.strictFunctionTypes??!0,o.compilerOptions.strictBindCallApply=o.compilerOptions.strictBindCallApply??!0,o.compilerOptions.strictPropertyInitialization=o.compilerOptions.strictPropertyInitialization??!0,o.compilerOptions.alwaysStrict=o.compilerOptions.alwaysStrict??!0),o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.target&&L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!0),o.compilerOptions.strict&&o.compilerOptions.useUnknownInCatchVariables===void 0&&(o.compilerOptions.useUnknownInCatchVariables=!0),o.compilerOptions.isolatedModules&&(o.compilerOptions.preserveConstEnums=o.compilerOptions.preserveConstEnums??!0)),["6.0","7.0","true"].includes(String(i?.tscCompatible))){if(o.compilerOptions.moduleDetection===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&(o.compilerOptions.moduleDetection="force"),o.compilerOptions.moduleResolution===void 0&&o.compilerOptions.module){const s=o.compilerOptions.module.toLocaleLowerCase();s==="node16"||s==="node18"||s==="node20"?o.compilerOptions.moduleResolution="node16":s==="nodenext"&&(o.compilerOptions.moduleResolution="nodenext")}if(o.compilerOptions.useDefineForClassFields===void 0&&o.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(o.compilerOptions.module)&&o.compilerOptions.target&&!L(o.compilerOptions.target)&&(o.compilerOptions.useDefineForClassFields=!1),o.compilerOptions.isolatedModules&&o.compilerOptions.preserveConstEnums===void 0&&(o.compilerOptions.preserveConstEnums=!0),o.compilerOptions.resolveJsonModule===void 0){const s=o.compilerOptions.module,r=o.compilerOptions.moduleResolution?.toLocaleLowerCase();!(s!==void 0&&["node20","nodenext"].includes(s)||r==="bundler")&&r&&(o.compilerOptions.resolveJsonModule=!1)}if(o.compilerOptions.moduleResolution){const s=o.compilerOptions.moduleResolution.toLocaleLowerCase();["bundler","node16","nodenext"].includes(s)||(o.compilerOptions.resolvePackageJsonExports??=!1,o.compilerOptions.resolvePackageJsonImports??=!1)}}return o.compileOnSave===!1&&delete o.compileOnSave,o},uo=(o,i)=>{const s=o?.typescriptVersion;if(!(s===!1||s===void 0))return s==="auto"?Q(i):s},h="${configDir}",fo=Symbol("implicitBaseUrl"),xo=(o,i)=>{const s=g(o),r=_(s,i),e=k(s),m=uo(i,e);m&&r.compilerOptions&&ro(r.compilerOptions,m);const{compilerOptions:t}=r;if(t){for(const n of mo){const c=t[n];if(c){const p=C(c,e);t[n]=p?b(x(e,p)):c}}for(const n of["rootDirs","typeRoots"]){const c=t[n];c&&(t[n]=c.map(p=>{const a=C(p,e);return a?b(x(e,a)):p}))}const{paths:l}=t;if(l){const n=Object.keys(l);for(let c=0;c<n.length;c++){const p=n[c];l[p]=l[p].map(a=>C(a,e)??a)}}}for(let l=0;l<I.length;l++){const n=I[l],c=r[n];c&&(r[n]=c.map(p=>C(p,e)??p))}return ao(r,i)};export{h as configDirectoryPlaceholder,fo as implicitBaseUrlSymbol,xo as readTsConfig};
@@ -1 +0,0 @@
1
- import{createRequire as m}from"node:module";import{findUp as a,findUpSync as p}from"@visulima/fs";import{NotFoundError as l}from"@visulima/fs/error";import{readTsConfig as d}from"./configDirectoryPlaceholder-BhSMyWHh.js";const y=m(import.meta.url),f=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,j=t=>{if(typeof f<"u"&&f.versions&&f.versions.node){const[o,e]=f.versions.node.split(".").map(Number);if(o>22||o===22&&e>=3||o===20&&e>=16)return f.getBuiltinModule(t)}return y(t)},{statSync:_}=j("node:fs"),u=new Map,g="tsconfig.json",h=(t,o)=>{let e=0;try{e=_(t).mtimeMs}catch{}return`${t}::${String(o.tscCompatible)}::${String(o.typescriptVersion)}::${String(e)}`},$=async(t,o={})=>{const e=o.configFileName??g,i=o.configFileName===void 0;let c=await a(e,{...t&&{cwd:t},type:"file"});if(!c&&i&&(c=await a("jsconfig.json",{...t&&{cwd:t},type:"file"})),!c)throw new l(i?`No such file or directory, for '${e}' or 'jsconfig.json' found.`:`No such file or directory, for '${e}' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:u,r=h(c,o);if(o.cache&&n.has(r))return n.get(r);const s={config:d(c,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:c};return o.cache&&n.set(r,s),s},S=(t,o={})=>{const e=o.configFileName??g,i=o.configFileName===void 0;let c=p(e,{...t&&{cwd:t},type:"file"});if(!c&&i&&(c=p("jsconfig.json",{...t&&{cwd:t},type:"file"})),!c)throw new l(i?`No such file or directory, for '${e}' or 'jsconfig.json' found.`:`No such file or directory, for '${e}' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:u,r=h(c,o);if(o.cache&&n.has(r))return n.get(r);const s={config:d(c,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:c};return o.cache&&n.set(r,s),s};export{$ as findTsConfig,S as findTsConfigSync};