@visulima/tsconfig 3.0.0-alpha.30 → 3.0.0-alpha.32

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,38 @@
1
+ ## @visulima/tsconfig [3.0.0-alpha.32](https://github.com/visulima/visulima/compare/@visulima/tsconfig@3.0.0-alpha.31...@visulima/tsconfig@3.0.0-alpha.32) (2026-06-30)
2
+
3
+ ### Miscellaneous Chores
4
+
5
+ * add fallow code-intelligence across all packages ([a3b4821](https://github.com/visulima/visulima/commit/a3b48215002e86fed20f2973038b5d4a0aa1ce04))
6
+
7
+ ### Continuous Integration
8
+
9
+ * **fallow:** make fallow:health advisory (--report-only) ([d57148e](https://github.com/visulima/visulima/commit/d57148ea0e3556b4c24d8d336b9fa14987f5dc7d))
10
+
11
+
12
+ ### Dependencies
13
+
14
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.33
15
+
16
+ ## @visulima/tsconfig [3.0.0-alpha.31](https://github.com/visulima/visulima/compare/@visulima/tsconfig@3.0.0-alpha.30...@visulima/tsconfig@3.0.0-alpha.31) (2026-06-13)
17
+
18
+ ### Bug Fixes
19
+
20
+ * **tsconfig:** correct docs, pnp issuer, cache invalidation ([c3e0b9d](https://github.com/visulima/visulima/commit/c3e0b9d4281ee78f70780192fdf1d51b22bb2e9a))
21
+
22
+ ### Documentation
23
+
24
+ * **tsconfig:** fix stale API reference ([514b1b0](https://github.com/visulima/visulima/commit/514b1b0a6ae8e2533162afcc39ad541762ea92e2))
25
+
26
+ ### Code Refactoring
27
+
28
+ * **tsconfig:** reorder type exports and add eslint-disable comments ([5b4bb2b](https://github.com/visulima/visulima/commit/5b4bb2b0f706abf6b39c46be3175c8a7981f92f5))
29
+
30
+
31
+ ### Dependencies
32
+
33
+ * **@visulima/fs:** upgraded to 5.0.0-alpha.32
34
+ * **@visulima/path:** upgraded to 3.0.0-alpha.13
35
+
1
36
  ## @visulima/tsconfig [3.0.0-alpha.30](https://github.com/visulima/visulima/compare/@visulima/tsconfig@3.0.0-alpha.29...@visulima/tsconfig@3.0.0-alpha.30) (2026-06-04)
2
37
 
3
38
 
package/README.md CHANGED
@@ -37,10 +37,11 @@
37
37
  ## Features
38
38
 
39
39
  - Tested against TypeScript for correctness
40
- - Supports comments & dangling commas in tsconfig.json
41
- - Resolves extends
40
+ - Supports comments & dangling commas in tsconfig.json (JSONC)
41
+ - Resolves `extends` (relative paths, package names, and Yarn PnP)
42
+ - Resolves `${configDir}` template variables
42
43
  - Fully typed tsconfig.json
43
- - Validates and throws parsing errors
44
+ - Synchronous and asynchronous search helpers
44
45
 
45
46
  ## Install
46
47
 
@@ -58,37 +59,77 @@ pnpm add @visulima/tsconfig
58
59
 
59
60
  ## Usage
60
61
 
61
- ### findTsConfig
62
+ ### findTsConfig / findTsConfigSync
62
63
 
63
- Retrieves the TsConfig by searching for the "tsconfig.json" file from a given current working directory.
64
+ Retrieves the TsConfig by searching upward for a `tsconfig.json` file (falling back to `jsconfig.json`) from a given directory. `findTsConfig` is asynchronous; `findTsConfigSync` is the synchronous variant.
64
65
 
65
66
  ```ts
66
- import { findTsConfig } from "@visulima/tsconfig";
67
+ import { findTsConfig, findTsConfigSync } from "@visulima/tsconfig";
67
68
 
68
- const tsconfig = await findTsConfig(); // => { path: "/Users/../Projects/visulima/packages/tsconfig/tsconfig.json", config: { compilerOptions: { ... } } }
69
+ const tsconfig = await findTsConfig();
70
+ // => { path: "/Users/.../visulima/packages/tsconfig/tsconfig.json", config: { compilerOptions: { ... } } }
71
+
72
+ // Synchronous, with a custom start directory
73
+ const tsconfigSync = findTsConfigSync("/path/to/project");
69
74
  ```
70
75
 
71
- ### writeTsConfig
76
+ Options (`findTsConfig`/`findTsConfigSync`):
77
+
78
+ | Option | Type | Default | Description |
79
+ | ------------------- | ---------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | `configFileName` | `string` | `"tsconfig.json"` | Name of the file to search for. Supplying a custom name disables the `jsconfig.json` fallback. |
81
+ | `cache` | `boolean \| Map<string, TsConfigResult>` | `undefined` | Cache parsed configs. `true` uses a process-wide cache; pass a `Map` for a caller-owned cache. Keys embed the file mtime, so on-disk edits invalidate cached entries automatically. |
82
+ | `tscCompatible` | see [readTsConfig](#readtsconfig) | `undefined` | Forwarded to `readTsConfig`. |
83
+ | `typescriptVersion` | see [readTsConfig](#readtsconfig) | `undefined` | Forwarded to `readTsConfig`. |
72
84
 
73
- Writes the provided TypeScript configuration object to a tsconfig.json file.
85
+ > Note: only the upward file search is async. Parsing (including the full `extends` chain) is synchronous, so a very deep `extends` chain still blocks the event loop during parse.
86
+
87
+ ### readTsConfig
88
+
89
+ Reads and parses the TypeScript configuration from a `tsconfig.json` path. **This function is synchronous** — it returns the resolved config object directly (no `await`).
74
90
 
75
91
  ```ts
76
- import { writeTsConfig } from '@visulima/package';
92
+ import { readTsConfig } from "@visulima/tsconfig";
93
+
94
+ const tsconfig = readTsConfig("/path/to/tsconfig.json");
95
+
96
+ // Make derived defaults match a specific TypeScript version
97
+ const compatible = readTsConfig("/path/to/tsconfig.json", { tscCompatible: "5.8" });
77
98
 
78
- writeTsConfig({ compilerOptions: { ... } }/* ,{ cwd: "./" }*/);
99
+ // Apply the unconditional compiler-option defaults of the installed TypeScript
100
+ const withDefaults = readTsConfig("/path/to/tsconfig.json", { typescriptVersion: "auto" });
79
101
  ```
80
102
 
81
- ### readTsConfig
103
+ Options (`ReadTsConfigOptions`):
104
+
105
+ | Option | Type | Default | Description |
106
+ | ------------------- | --------------------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
107
+ | `tscCompatible` | `"5.4" \| "5.5" \| "5.6" \| "5.7" \| "5.8" \| "5.9" \| "6.0" \| true` | `undefined` | Synthesize the _derived_ defaults TypeScript would imply from other options for the given version (e.g. `module: nodenext` ⇒ `moduleResolution: nodenext`). `true` targets the latest supported version. |
108
+ | `typescriptVersion` | `"auto" \| false \| string` | `false` | Apply the _unconditional_ compiler-option defaults of a TypeScript version. `"auto"` detects the installed version (including Yarn PnP); a string pins an explicit version; `false` applies none. Can be combined with `tscCompatible`. |
82
109
 
83
- Reads the TypeScript configuration from a tsconfig.json file.
110
+ ### writeTsConfig / writeTsConfigSync
111
+
112
+ Writes the provided TypeScript configuration object to a `tsconfig.json` file. `writeTsConfig` is asynchronous; `writeTsConfigSync` is the synchronous variant.
84
113
 
85
114
  ```ts
86
- import { readTsConfig } from "@visulima/package";
115
+ import { writeTsConfig, writeTsConfigSync } from "@visulima/tsconfig";
116
+
117
+ await writeTsConfig({ compilerOptions: { strict: true } }, { cwd: "./" });
87
118
 
88
- const tsconfig = await readTsConfig("/Users/../Projects/visulima/packages/tsconfig.json" /* { tscCompatible: false } */);
119
+ writeTsConfigSync({ compilerOptions: { strict: true } }, { cwd: "./" });
89
120
  ```
90
121
 
91
- > tscCompatible: If true, the configuration will be parsed in a way that is compatible with the TypeScript compiler.
122
+ ### configDirectoryPlaceholder
123
+
124
+ The literal `${configDir}` template string used by TypeScript. Re-exported so consumers can detect un-interpolated values without deep-importing internals.
125
+
126
+ ```ts
127
+ import { configDirectoryPlaceholder } from "@visulima/tsconfig";
128
+
129
+ if (someValue.startsWith(configDirectoryPlaceholder)) {
130
+ // value still references ${configDir}
131
+ }
132
+ ```
92
133
 
93
134
  ## Api Docs
94
135
 
@@ -474,13 +515,15 @@ Defined in: [packages/tsconfig/src/read-tsconfig.ts:444](https://github.com/visu
474
515
  ##### tscCompatible?
475
516
 
476
517
  ```ts
477
- optional tscCompatible: "5.3" | "5.4" | "5.5" | "5.6" | true;
518
+ optional tscCompatible: "5.4" | "5.5" | "5.6" | "5.7" | "5.8" | "5.9" | "6.0" | true;
478
519
  ```
479
520
 
480
- Defined in: [packages/tsconfig/src/read-tsconfig.ts:452](https://github.com/visulima/visulima/blob/afe199ce97ec3025aa13484407254660803d8d9c/packages/tsconfig/src/read-tsconfig.ts#L452)
521
+ Defined in: [packages/tsconfig/src/read-tsconfig.ts:703](https://github.com/visulima/visulima/blob/afe199ce97ec3025aa13484407254660803d8d9c/packages/tsconfig/src/read-tsconfig.ts#L703)
481
522
 
482
523
  Make the configuration compatible with the specified TypeScript version.
483
524
 
525
+ Controls _derived_ defaults — fields TypeScript synthesizes when other fields are set (e.g. `module: nodenext` ⇒ `moduleResolution: nodenext`).
526
+
484
527
  When `true`, it will make the configuration compatible with the latest TypeScript version.
485
528
 
486
529
  ###### Default
@@ -489,6 +532,22 @@ When `true`, it will make the configuration compatible with the latest TypeScrip
489
532
  undefined;
490
533
  ```
491
534
 
535
+ ##### typescriptVersion?
536
+
537
+ ```ts
538
+ optional typescriptVersion: "auto" | false | string;
539
+ ```
540
+
541
+ Defined in: [packages/tsconfig/src/read-tsconfig.ts:718](https://github.com/visulima/visulima/blob/afe199ce97ec3025aa13484407254660803d8d9c/packages/tsconfig/src/read-tsconfig.ts#L718)
542
+
543
+ Apply the _unconditional_ compiler-option defaults TypeScript would synthesize for the given version. `"auto"` detects the installed TypeScript version (including Yarn PnP); a string pins an explicit version; `false` applies none. Distinct from `tscCompatible`, and both can be combined.
544
+
545
+ ###### Default
546
+
547
+ ```ts
548
+ false;
549
+ ```
550
+
492
551
  ---
493
552
 
494
553
  ### TsConfigJsonResolved
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TsConfigJson, Except } from 'type-fest';
2
- export { type TsConfigJson } from 'type-fest';
2
+ export type { TsConfigJson } from 'type-fest';
3
3
  import { WriteJsonOptions } from '@visulima/fs';
4
4
  type TsConfigJsonResolved = Except<TsConfigJson, "extends">;
5
5
  type Options$1 = {
@@ -10,9 +10,13 @@ type Options$1 = {
10
10
  * fields are set (e.g. `module: nodenext` ⇒ `moduleResolution: nodenext`).
11
11
  *
12
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.
13
17
  * @default undefined
14
18
  */
15
- tscCompatible?: "5.3" | "5.4" | "5.5" | "5.6" | "5.7" | "5.8" | "5.9" | "6.0" | true;
19
+ tscCompatible?: "5.4" | "5.5" | "5.6" | "5.7" | "5.8" | "5.9" | "6.0" | true;
16
20
  /**
17
21
  * Apply the *unconditional* compiler-option defaults TypeScript would
18
22
  * synthesize for the given version (e.g. TS 6.0's `strict: true`,
@@ -28,12 +32,27 @@ type Options$1 = {
28
32
  */
29
33
  typescriptVersion?: "auto" | false | (Record<never, never> & string);
30
34
  };
35
+ declare const configDirectoryPlaceholder: string;
31
36
  declare const implicitBaseUrlSymbol: symbol;
32
37
  declare const readTsConfig: (tsconfigPath: string, options?: Options$1) => TsConfigJsonResolved;
33
- type Options = Options$1 & {
38
+ type Options = {
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
+ */
34
47
  cache?: Map<string, TsConfigResult> | boolean;
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
+ */
35
54
  configFileName?: string;
36
- };
55
+ } & Options$1;
37
56
  type TsConfigResult = {
38
57
  config: TsConfigJsonResolved;
39
58
  path: string;
@@ -41,6 +60,10 @@ type TsConfigResult = {
41
60
  /**
42
61
  * An asynchronous function that retrieves the TSConfig by searching for the "tsconfig.json" first,
43
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.
44
67
  * @param cwd Optional. The current working directory from which to search for the "tsconfig.json" file.
45
68
  * The type of `cwd` is `string`.
46
69
  * @returns A `Promise` that resolves to the TSConfig result object.
@@ -71,4 +94,4 @@ declare const writeTsConfig: (tsConfig: TsConfigJson, options?: WriteJsonOptions
71
94
  declare const writeTsConfigSync: (tsConfig: TsConfigJson, options?: WriteJsonOptions & {
72
95
  cwd?: URL | string;
73
96
  }) => void;
74
- export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
97
+ export { type Options as FindTsConfigOptions, type Options$1 as ReadTsConfigOptions, type TsConfigJsonResolved, type TsConfigResult, configDirectoryPlaceholder, findTsConfig, findTsConfigSync, implicitBaseUrlSymbol, readTsConfig, writeTsConfig, writeTsConfigSync };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{findTsConfig as f,findTsConfigSync as r}from"./packem_shared/findTsConfig-C2Rhk1nd.js";import{implicitBaseUrlSymbol as e,readTsConfig as s}from"./packem_shared/implicitBaseUrlSymbol-BmYUUOd7.js";import{writeTsConfig as g,writeTsConfigSync as m}from"./packem_shared/writeTsConfig-0IO4xPZJ.js";export{f as findTsConfig,r as findTsConfigSync,e as implicitBaseUrlSymbol,s as readTsConfig,g as writeTsConfig,m as writeTsConfigSync};
1
+ import{findTsConfig as r,findTsConfigSync as f}from"./packem_shared/findTsConfig-WpIondtG.js";import{configDirectoryPlaceholder as n,implicitBaseUrlSymbol as t,readTsConfig as c}from"./packem_shared/configDirectoryPlaceholder-BX9y4RJS.js";import{writeTsConfig as s,writeTsConfigSync as l}from"./packem_shared/writeTsConfig-BrUFAEe9.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 V}from"node:module";import{isAccessibleSync as O,findUpSync as $,readFileSync as P}from"@visulima/fs";import{NotFoundError as N}from"@visulima/fs/error";import{join as d,resolve as y,isAbsolute as E,dirname as k,relative as x,normalize as R,toNamespacedPath as T}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 B=V(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 B(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=y(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 v=S(f,l,!1,s);if(v&&O(v))return v}}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(y(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),g=a.endsWith(".json");if(!g){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 v=S(u,"",!0,s);if(v&&O(v))return v}const f=d(a,j);if(O(f))return f}else if(g)return a}},Q=o=>{const i=y(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=[[4,Y],[5,Z],[6,oo]],to=/^v?(\d+)/,io=o=>{const i=to.exec(o);return i?Number(i[1]):void 0},so=(o,i)=>{const s=io(i);if(s===void 0)return;const r=new Set(Object.keys(o));for(const[e,m]of eo)e<=s&&m(o,r)},ro=o=>A(P(o,{buffer:!1})),no=o=>o.replaceAll("\\","/"),b=o=>{const i=T(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)||"./"},lo=(o,i,s)=>{const r=x(o,i);if(!r)return s;const e=s.startsWith("./")?s.slice(2):s;return`${r}/${e}`},co=(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:lo(i,m,p)))}return t},_=(o,i,s=new Set,r=new Map)=>{let e;try{e=ro(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[uo]=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 N(`No such file or directory, for '${c}' found.`);const a=co(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 g={...a,...e,compilerOptions:{...a.compilerOptions,...e.compilerOptions}};a.watchOptions&&(g.watchOptions={...a.watchOptions,...e.watchOptions}),e=g}}if(e.compilerOptions){const{compilerOptions:t}=e;for(const l of["baseUrl","rootDir"]){const n=t[l];if(n&&!n.startsWith(h)){const c=y(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=>no(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(y(m,l)))),t.excludeFiles&&(t.excludeFiles=t.excludeFiles.map(l=>R(y(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)))},po=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],L=o=>o==="es2022"||o==="es2023"||o==="es2024"||o==="es2025"||o==="esnext",mo=(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","true"].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","true"].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","true"].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","true"].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)),String(i?.tscCompatible)==="6.0"){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},ao=(o,i)=>{const s=o?.typescriptVersion;if(!(s===!1||s===void 0))return s==="auto"?Q(i):s},h="${configDir}",uo=Symbol("implicitBaseUrl"),bo=(o,i)=>{const s=y(o),r=_(s,i),e=k(s),m=ao(i,e);m&&r.compilerOptions&&so(r.compilerOptions,m);const{compilerOptions:t}=r;if(t){for(const n of po){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 mo(r,i)};export{h as configDirectoryPlaceholder,uo as implicitBaseUrlSymbol,bo 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-BX9y4RJS.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};
@@ -0,0 +1 @@
1
+ import{writeJson as w,writeJsonSync as e}from"@visulima/fs";import{toPath as c}from"@visulima/fs/utils";import{join as r}from"@visulima/path";const a=async(o,s={})=>{const{cwd:n,...t}=s,i=c(n??process.cwd());await w(r(i,"tsconfig.json"),o,t)},d=(o,s={})=>{const{cwd:n,...t}=s,i=c(n??process.cwd());e(r(i,"tsconfig.json"),o,t)};export{a as writeTsConfig,d as writeTsConfigSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/tsconfig",
3
- "version": "3.0.0-alpha.30",
3
+ "version": "3.0.0-alpha.32",
4
4
  "description": "Find and/or parse the tsconfig.json file from a directory path.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -48,8 +48,8 @@
48
48
  "CHANGELOG.md"
49
49
  ],
50
50
  "dependencies": {
51
- "@visulima/fs": "5.0.0-alpha.31",
52
- "@visulima/path": "3.0.0-alpha.12",
51
+ "@visulima/fs": "5.0.0-alpha.33",
52
+ "@visulima/path": "3.0.0-alpha.13",
53
53
  "jsonc-parser": "^3.3.1",
54
54
  "resolve-pkg-maps": "^1.0.0"
55
55
  },
@@ -1 +0,0 @@
1
- var y=Object.defineProperty;var s=(c,o)=>y(c,"name",{value:o,configurable:!0});import{findUp as f,findUpSync as a}from"@visulima/fs";import{NotFoundError as p}from"@visulima/fs/error";import{readTsConfig as g}from"./implicitBaseUrlSymbol-BmYUUOd7.js";var d=Object.defineProperty,l=s((c,o)=>d(c,"name",{value:o,configurable:!0}),"r");const h=new Map,C=l(async(c,o={})=>{const r=o.configFileName??"tsconfig.json";let i=await f(r,{...c&&{cwd:c},type:"file"});if(i??=await f("jsconfig.json",{...c&&{cwd:c},type:"file"}),!i)throw new p(`No such file or directory, for '${r}' or 'jsconfig.json' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:h,t=`${i}::${String(o.tscCompatible)}::${String(o.typescriptVersion)}`;if(o.cache&&n.has(t))return n.get(t);const e={config:g(i,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:i};return o.cache&&n.set(t,e),e},"findTsConfig"),b=l((c,o={})=>{const r=o.configFileName??"tsconfig.json";let i=a(r,{...c&&{cwd:c},type:"file"});if(i??=a("jsconfig.json",{...c&&{cwd:c},type:"file"}),!i)throw new p(`No such file or directory, for '${r}' or 'jsconfig.json' found.`);const n=o.cache&&typeof o.cache!="boolean"?o.cache:h,t=`${i}::${String(o.tscCompatible)}::${String(o.typescriptVersion)}`;if(o.cache&&n.has(t))return n.get(t);const e={config:g(i,{tscCompatible:o.tscCompatible,typescriptVersion:o.typescriptVersion}),path:i};return o.cache&&n.set(t,e),e},"findTsConfigSync");export{C as findTsConfig,b as findTsConfigSync};
@@ -1 +0,0 @@
1
- var q=Object.defineProperty;var v=(e,o)=>q(e,"name",{value:o,configurable:!0});import{createRequire as z}from"node:module";import{readFileSync as E,isAccessibleSync as h,findUpSync as W}from"@visulima/fs";import{NotFoundError as H}from"@visulima/fs/error";import{join as d,resolve as b,isAbsolute as V,toNamespacedPath as K,relative as C,normalize as k,dirname as R}from"@visulima/path";import{isRelative as Q}from"@visulima/path/utils";import{parse as J}from"jsonc-parser";import{resolveExports as X}from"resolve-pkg-maps";const G=z(import.meta.url),D=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,U=v(e=>{if(typeof D<"u"&&D.versions&&D.versions.node){const[o,s]=D.versions.node.split(".").map(Number);if(o>22||o===22&&s>=3||o===20&&s>=16)return D.getBuiltinModule(e)}return G(e)},"__cjs_getBuiltinModule"),{statSync:P}=U("node:fs"),_=U("node:module");var Y=Object.defineProperty,S=v((e,o)=>Y(e,"name",{value:o,configurable:!0}),"d$1");const Z=S(e=>J(E(e,{buffer:!1})),"readJsonc"),ee=S(()=>{const{findPnpApi:e}=_;return e?.(process.cwd())},"getPnpApi"),F=S((e,o,s,r)=>{const t=`resolveFromPackageJsonPath:${e}:${o}:${s?"yes":"no"}`;if(r?.has(t))return r.get(t);const a=Z(e);if(!a)return;let i=o||"tsconfig.json";if(!s&&a.exports)try{const[l]=X(a.exports,o,["require","types"]);i=l}catch{return!1}else!o&&a.tsconfig&&(i=a.tsconfig);return i=d(e,"..",i),r?.set(t,i),i},"resolveFromPackageJsonPath"),$="package.json",I="tsconfig.json",oe=S((e,o,s)=>{let r=e;if(e===".."&&(r=d(r,I)),e.startsWith(".")&&(r=b(o,r)),V(r)){if(h(r)){if(P(r).isFile())return r}else if(!r.endsWith(".json")){const u=`${r}.json`;if(h(u))return u}return}const[t="",...a]=e.split("/"),i=t.startsWith("@")?`${t}/${String(a.shift())}`:t,l=a.join("/"),n=ee();if(n){const{resolveRequest:u}=n;try{if(i===e){const f=u(d(i,$),o);if(f){const g=F(f,l,!1,s);if(g&&h(g))return g}}else{let f;try{f=u(e,o,{extensions:[".json"]})}catch{f=u(d(e,I),o)}if(f)return f}}catch{}}const c=W(u=>{const f=d(b(u),"node_modules",i);if(h(f))return d("node_modules",i)},{cwd:o,type:"directory"});if(!c||!P(c).isDirectory())return;const p=d(c,$);if(h(p)){const u=F(p,l,!1,s);if(u===!1)return;if(u&&h(u)&&P(u).isFile())return u}const m=d(c,l),w=m.endsWith(".json");if(!w){const u=`${m}.json`;if(h(u))return u}if(h(m)){if(P(m).isDirectory()){const u=d(m,$);if(h(u)){const g=F(u,"",!0,s);if(g&&h(g))return g}const f=d(m,I);if(h(f))return f}else if(w)return m}},"resolveExtendsPath");var te=Object.defineProperty,ie=v((e,o)=>te(e,"name",{value:o,configurable:!0}),"i");const se=ie((e=process.cwd())=>{const{findPnpApi:o}=_;return o?o(e):void 0},"getPnpApi");var re=Object.defineProperty,ne=v((e,o)=>re(e,"name",{value:o,configurable:!0}),"o$2");const le=ne(e=>{const o=b(e);let s;const r=se(o);if(r)try{s=r.resolveRequest("typescript/package.json",o)??void 0}catch{}if(s??=W(t=>d(t,"node_modules","typescript","package.json"),{cwd:o,type:"file"}),!!s)try{const t=J(E(s,{buffer:!1}));if(typeof t?.version=="string")return t.version}catch{}},"detectTypeScriptVersion");var ce=Object.defineProperty,pe=v((e,o)=>ce(e,"name",{value:o,configurable:!0}),"n$1");const ae=new Set(["node16","node18","node20","nodenext"]),M=pe(e=>e!==void 0&&ae.has(e),"moduleDictatesTarget");var me=Object.defineProperty,ue=v((e,o)=>me(e,"name",{value:o,configurable:!0}),"o$1");const de=ue((e,o)=>{!o.has("target")&&!M(e.module)&&(e.target="es3")},"applyV4Defaults");var fe=Object.defineProperty,Oe=v((e,o)=>fe(e,"name",{value:o,configurable:!0}),"o");const ve=Oe((e,o)=>{!o.has("target")&&!M(e.module)&&(e.target="es5")},"applyV5Defaults");var he=Object.defineProperty,ye=v((e,o)=>he(e,"name",{value:o,configurable:!0}),"e");const ge=ye((e,o)=>{o.has("strict")||(e.strict=!0),o.has("target")||(e.target="es2025"),o.has("module")||(e.module="es2022"),o.has("moduleResolution")||(e.moduleResolution="bundler"),o.has("rootDir")||(e.rootDir="."),o.has("types")||(e.types=[]),o.has("noUncheckedSideEffectImports")||(e.noUncheckedSideEffectImports=!0),o.has("libReplacement")||(e.libReplacement=!1),o.has("alwaysStrict")||(e.alwaysStrict=!0)},"applyV6Defaults");var be=Object.defineProperty,B=v((e,o)=>be(e,"name",{value:o,configurable:!0}),"n");const we=[[4,de],[5,ve],[6,ge]],De=/^v?(\d+)/,xe=B(e=>{const o=De.exec(e);return o?Number(o[1]):void 0},"parseMajor"),Ce=B((e,o)=>{const s=xe(o);if(s===void 0)return;const r=new Set(Object.keys(e));for(const[t,a]of we)t<=s&&a(e,r)},"applyVersionDefaults");var Pe=Object.defineProperty,O=v((e,o)=>Pe(e,"name",{value:o,configurable:!0}),"d");const je=O(e=>J(E(e,{buffer:!1})),"readJsonc"),ke=O(e=>e.replaceAll("\\","/"),"slash"),x=O(e=>{const o=K(e);return Q(o)?o:`./${o}`},"normalizePath"),A=["files","include","exclude"],T=O((e,o,s)=>{const r=d(o,s),t=C(e,r);return k(t)||"./"},"resolveAndRelativize"),Re=O((e,o,s)=>{const r=C(e,o);if(!r)return s;const t=s.startsWith("./")?s.slice(2):s;return`${r}/${t}`},"prefixPattern"),Se=O((e,o,s,r,t)=>{if(s.has(e))throw new Error(`Circularity detected while resolving configuration: ${e}`);s.add(e);const a=R(e),i=N(e,r,s,t);delete i.references;const{compilerOptions:l}=i;if(l){const{baseUrl:n}=l;n&&!n.startsWith(y)&&(l.baseUrl=T(o,a,n));const{outDir:c}=l;c&&!c.startsWith(y)&&(l.outDir=T(o,a,c))}for(const n of A){const c=i[n];c&&(i[n]=c.map(p=>p.startsWith(y)||V(p)?p:Re(o,a,p)))}return i},"resolveExtends"),N=O((e,o,s=new Set,r=new Map)=>{let t;try{t=je(e)??{}}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}if(typeof t!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);const a=R(e);if(t.compilerOptions){const{compilerOptions:i}=t;i.paths&&!i.baseUrl&&(i[Le]=a)}if(t.extends){const i=Array.isArray(t.extends)?t.extends:[t.extends];delete t.extends;const l=i.toReversed();for(let n=0;n<l.length;n++){const c=l[n],p=oe(c,a,r);if(!p)throw new H(`No such file or directory, for '${c}' found.`);const m=Se(p,a,new Set(s),o,r);m.compilerOptions?.rootDir!==void 0&&!m.compilerOptions.rootDir.startsWith(y)&&(m.compilerOptions.rootDir=d(R(p),m.compilerOptions.rootDir));const w={...m,...t,compilerOptions:{...m.compilerOptions,...t.compilerOptions}};m.watchOptions&&(w.watchOptions={...m.watchOptions,...t.watchOptions}),t=w}}if(t.compilerOptions){const{compilerOptions:i}=t;for(const l of["baseUrl","rootDir"]){const n=i[l];if(n&&!n.startsWith(y)){const c=b(a,n);i[l]=x(C(a,c))}}for(const l of["outDir","declarationDir"]){let n=i[l];n&&(Array.isArray(t.exclude)||(t.exclude=["outDir","declarationDir"].map(c=>{const p=i[c];if(p)return p.startsWith(y)||V(p)?p:d(a,p)}).filter(Boolean)),n.startsWith(y)||(n=x(n)),i[l]=n)}}else t.compilerOptions={};if(t.include&&(t.include=t.include.map(i=>ke(i))),t.files&&(t.files=t.files.map(i=>i.startsWith(y)?i:x(i))),t.watchOptions){const{watchOptions:i}=t;i.excludeDirectories&&(i.excludeDirectories=i.excludeDirectories.map(l=>k(b(a,l)))),i.excludeFiles&&(i.excludeFiles=i.excludeFiles.map(l=>k(b(a,l)))),i.watchFile&&(i.watchFile=i.watchFile.toLowerCase()),i.watchDirectory&&(i.watchDirectory=i.watchDirectory.toLowerCase()),i.fallbackPolling&&(i.fallbackPolling=i.fallbackPolling.toLowerCase())}if(t.compilerOptions.lib&&(t.compilerOptions.lib=t.compilerOptions.lib.map(i=>i.toLowerCase())),t.compilerOptions.module){let i=t.compilerOptions.module.toLowerCase();i==="es2015"&&(i="es6"),t.compilerOptions.module=i}if(t.compilerOptions.target){let i=t.compilerOptions.target.toLowerCase();i==="es2015"&&(i="es6"),t.compilerOptions.target=i}if(t.compilerOptions.moduleResolution){let i=t.compilerOptions.moduleResolution.toLowerCase();i==="node"&&(i="node10"),t.compilerOptions.moduleResolution=i}return t.compilerOptions.jsx&&(t.compilerOptions.jsx=t.compilerOptions.jsx.toLowerCase()),t.compilerOptions.moduleDetection&&(t.compilerOptions.moduleDetection=t.compilerOptions.moduleDetection.toLowerCase()),t.compilerOptions.importsNotUsedAsValues&&(t.compilerOptions.importsNotUsedAsValues=t.compilerOptions.importsNotUsedAsValues.toLowerCase()),t.compilerOptions.newLine&&(t.compilerOptions.newLine=t.compilerOptions.newLine.toLowerCase()),t},"internalParseTsConfig"),j=O((e,o)=>{if(e.startsWith(y))return k(d(o,e.slice(y.length)))},"interpolateConfigDirectory"),Fe=["outDir","declarationDir","outFile","rootDir","baseUrl","tsBuildInfoFile"],L=O(e=>e==="es2022"||e==="es2023"||e==="es2024"||e==="es2025"||e==="esnext","targetImpliesUseDefineForClassFields"),$e=O((e,o)=>{if(e.compilerOptions===void 0)return e;if(e.compilerOptions.rewriteRelativeImportExtensions&&(e.compilerOptions.allowImportingTsExtensions??=!0),e.compilerOptions.composite&&(e.compilerOptions.declaration??=!0,e.compilerOptions.incremental??=!0),e.compilerOptions.checkJs&&(e.compilerOptions.allowJs??=!0),e.compilerOptions.verbatimModuleSyntax&&(e.compilerOptions.isolatedModules??=!0,e.compilerOptions.preserveConstEnums??=!0),["5.4","5.5","5.6","5.7","5.8","5.9","true"].includes(String(o?.tscCompatible))){if(e.compilerOptions.esModuleInterop===void 0&&(e.compilerOptions.module==="node16"||e.compilerOptions.module==="node18"||e.compilerOptions.module==="node20"||e.compilerOptions.module==="nodenext"||e.compilerOptions.module==="preserve")&&(e.compilerOptions.esModuleInterop=!0),e.compilerOptions.moduleDetection===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.moduleDetection="force"),e.compilerOptions.moduleResolution===void 0){let s="classic";if(e.compilerOptions.module!==void 0)switch(e.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"&&(e.compilerOptions.moduleResolution=s)}if(e.compilerOptions.moduleResolution==="bundler"&&(e.compilerOptions.resolveJsonModule??=!0),e.compilerOptions.module&&["node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.resolveJsonModule??=!0),(e.compilerOptions.esModuleInterop||e.compilerOptions.module==="system"||e.compilerOptions.moduleResolution==="bundler")&&e.compilerOptions.allowSyntheticDefaultImports===void 0&&(e.compilerOptions.allowSyntheticDefaultImports=!0),["5.7","5.8","5.9","true"].includes(String(o?.tscCompatible))&&e.compilerOptions.moduleResolution){let s=!1;["bundler","node16","nodenext"].includes(e.compilerOptions.moduleResolution.toLocaleLowerCase())&&(s=!0),e.compilerOptions.resolvePackageJsonExports===void 0&&s&&(e.compilerOptions.resolvePackageJsonExports=!0),e.compilerOptions.resolvePackageJsonImports===void 0&&s&&(e.compilerOptions.resolvePackageJsonImports=!0)}if(e.compilerOptions.target===void 0){let s="es5";switch(e.compilerOptions.module){case"node16":case"node18":{s="es2022";break}case"node20":{s="es2023";break}case"nodenext":{s="esnext";break}}s!=="es5"&&(e.compilerOptions.target=s)}e.compilerOptions.useDefineForClassFields===void 0&&e.compilerOptions.target&&L(e.compilerOptions.target)&&(e.compilerOptions.useDefineForClassFields=!0)}if(["5.6","5.7","5.8","5.9","true"].includes(String(o?.tscCompatible))&&e.compilerOptions.strict&&e.compilerOptions.strictBuiltinIteratorReturn===void 0&&(e.compilerOptions.strictBuiltinIteratorReturn=!0),["5.4","5.5","5.6","5.7","5.8","5.9","true"].includes(String(o?.tscCompatible))&&(e.compilerOptions.strict&&(e.compilerOptions.noImplicitAny=e.compilerOptions.noImplicitAny??!0,e.compilerOptions.noImplicitThis=e.compilerOptions.noImplicitThis??!0,e.compilerOptions.strictNullChecks=e.compilerOptions.strictNullChecks??!0,e.compilerOptions.strictFunctionTypes=e.compilerOptions.strictFunctionTypes??!0,e.compilerOptions.strictBindCallApply=e.compilerOptions.strictBindCallApply??!0,e.compilerOptions.strictPropertyInitialization=e.compilerOptions.strictPropertyInitialization??!0,e.compilerOptions.alwaysStrict=e.compilerOptions.alwaysStrict??!0),e.compilerOptions.useDefineForClassFields===void 0&&e.compilerOptions.target&&L(e.compilerOptions.target)&&(e.compilerOptions.useDefineForClassFields=!0),e.compilerOptions.strict&&e.compilerOptions.useUnknownInCatchVariables===void 0&&(e.compilerOptions.useUnknownInCatchVariables=!0),e.compilerOptions.isolatedModules&&(e.compilerOptions.preserveConstEnums=e.compilerOptions.preserveConstEnums??!0)),String(o?.tscCompatible)==="6.0"){if(e.compilerOptions.moduleDetection===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&(e.compilerOptions.moduleDetection="force"),e.compilerOptions.moduleResolution===void 0&&e.compilerOptions.module){const s=e.compilerOptions.module.toLocaleLowerCase();s==="node16"||s==="node18"||s==="node20"?e.compilerOptions.moduleResolution="node16":s==="nodenext"&&(e.compilerOptions.moduleResolution="nodenext")}if(e.compilerOptions.useDefineForClassFields===void 0&&e.compilerOptions.module&&["node16","node18","node20","nodenext"].includes(e.compilerOptions.module)&&e.compilerOptions.target&&!L(e.compilerOptions.target)&&(e.compilerOptions.useDefineForClassFields=!1),e.compilerOptions.isolatedModules&&e.compilerOptions.preserveConstEnums===void 0&&(e.compilerOptions.preserveConstEnums=!0),e.compilerOptions.resolveJsonModule===void 0){const s=e.compilerOptions.module,r=e.compilerOptions.moduleResolution?.toLocaleLowerCase();!(s!==void 0&&["node20","nodenext"].includes(s)||r==="bundler")&&r&&(e.compilerOptions.resolveJsonModule=!1)}if(e.compilerOptions.moduleResolution){const s=e.compilerOptions.moduleResolution.toLocaleLowerCase();["bundler","node16","nodenext"].includes(s)||(e.compilerOptions.resolvePackageJsonExports??=!1,e.compilerOptions.resolvePackageJsonImports??=!1)}}return e.compileOnSave===!1&&delete e.compileOnSave,e},"tsCompatibleWrapper"),Ie=O((e,o)=>{const s=e?.typescriptVersion;if(!(s===!1||s===void 0))return s==="auto"?le(o):s},"resolveTypeScriptVersion"),y="${configDir}",Le=Symbol("implicitBaseUrl"),Me=O((e,o)=>{const s=b(e),r=N(s,o),t=R(s),a=Ie(o,t);a&&r.compilerOptions&&Ce(r.compilerOptions,a);const{compilerOptions:i}=r;if(i){for(const n of Fe){const c=i[n];if(c){const p=j(c,t);i[n]=p?x(C(t,p)):c}}for(const n of["rootDirs","typeRoots"]){const c=i[n];c&&(i[n]=c.map(p=>{const m=j(p,t);return m?x(C(t,m)):p}))}const{paths:l}=i;if(l){const n=Object.keys(l);for(let c=0;c<n.length;c++){const p=n[c];l[p]=l[p].map(m=>j(m,t)??m)}}i.outDir&&(i.outDir=i.outDir.replace(y,""))}for(let l=0;l<A.length;l++){const n=A[l],c=r[n];c&&(r[n]=c.map(p=>j(p,t)??p))}return $e(r,o)},"readTsConfig");export{y as configDirectoryPlaceholder,Le as implicitBaseUrlSymbol,Me as readTsConfig};
@@ -1 +0,0 @@
1
- var w=Object.defineProperty;var s=(o,n)=>w(o,"name",{value:n,configurable:!0});import{writeJson as a,writeJsonSync as p}from"@visulima/fs";import{toPath as c}from"@visulima/fs/utils";import{join as e}from"@visulima/path";var g=Object.defineProperty,f=s((o,n)=>g(o,"name",{value:n,configurable:!0}),"r");const C=f(async(o,n={})=>{const{cwd:r,...i}=n,t=c(r??process.cwd());await a(e(t,"tsconfig.json"),o,i)},"writeTsConfig"),T=f((o,n={})=>{const{cwd:r,...i}=n,t=c(r??process.cwd());p(e(t,"tsconfig.json"),o,i)},"writeTsConfigSync");export{C as writeTsConfig,T as writeTsConfigSync};