node-env-resolver 6.1.1 → 6.2.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.
Files changed (2) hide show
  1. package/README.md +80 -9
  2. package/package.json +48 -6
package/README.md CHANGED
@@ -12,6 +12,41 @@ Type-safe environment variable resolution with zero dependencies and ultra-small
12
12
  npm install node-env-resolver
13
13
  ```
14
14
 
15
+ ### TypeScript Configuration
16
+
17
+ This package uses modern [package.json `exports`](https://nodejs.org/api/packages.html#exports) for subpath imports (like `node-env-resolver/resolvers`). Your `tsconfig.json` must use a modern module resolution strategy.
18
+
19
+ **What to change:**
20
+
21
+ If your `tsconfig.json` has:
22
+ ```json
23
+ {
24
+ "compilerOptions": {
25
+ "module": "CommonJS",
26
+ "moduleResolution": "node"
27
+ }
28
+ }
29
+ ```
30
+
31
+ **Change it to:**
32
+ ```json
33
+ {
34
+ "compilerOptions": {
35
+ "module": "NodeNext", // Changed from "CommonJS"
36
+ "moduleResolution": "NodeNext" // Changed from "node"
37
+ }
38
+ }
39
+ ```
40
+
41
+ **Alternative options:**
42
+ - For bundler projects (Vite, Webpack, etc.): Use `"moduleResolution": "bundler"` (you can keep `"module": "CommonJS"` or use `"ESNext"`)
43
+ - For Node.js projects: Use `"moduleResolution": "node16"` with `"module": "node16"`
44
+
45
+ **Required values:** `"node16"`, `"nodenext"`, or `"bundler"`
46
+ **Not supported:** `"node"` (legacy resolution doesn't understand exports)
47
+
48
+ If you see module resolution errors, see the [Troubleshooting](#troubleshooting) section below.
49
+
15
50
  ## Quick start (uses process.env)
16
51
 
17
52
  ```ts
@@ -1662,32 +1697,68 @@ if (policyViolations.length > 0) {
1662
1697
 
1663
1698
  ## Troubleshooting
1664
1699
 
1665
- ### TypeScript: Cannot find module 'node-env-resolver/validators'
1700
+ ### TypeScript: Cannot find module 'node-env-resolver/resolvers' or 'node-env-resolver/validators'
1666
1701
 
1667
- If you're using `moduleResolution: "bundler"` in your `tsconfig.json` and TypeScript can't resolve subpath exports like `node-env-resolver/validators`, this is a known TypeScript limitation (see [TypeScript issue #55337](https://github.com/microsoft/TypeScript/issues/55337)).
1702
+ This package uses modern [package.json `exports`](https://nodejs.org/api/packages.html#exports) for subpath exports (like `node-env-resolver/resolvers`). TypeScript requires a modern module resolution strategy to understand these exports.
1668
1703
 
1669
- **Workaround options:**
1704
+ **If you see this error:**
1705
+ ```
1706
+ Cannot find module 'node-env-resolver/resolvers' or its corresponding type declarations.
1707
+ There are types at '.../node_modules/node-env-resolver/dist/resolvers.d.ts',
1708
+ but this result could not be resolved under your current 'moduleResolution' setting.
1709
+ Consider updating to 'node16', 'nodenext', or 'bundler'.
1710
+ ```
1711
+
1712
+ **Solution:** Update your `tsconfig.json` to use a modern module resolution strategy.
1670
1713
 
1671
- 1. **Use `moduleResolution: "NodeNext"`** (recommended for most projects):
1714
+ **Example - if your config currently has:**
1672
1715
  ```json
1673
1716
  {
1674
1717
  "compilerOptions": {
1675
- "moduleResolution": "NodeNext",
1676
- "module": "NodeNext"
1718
+ "module": "CommonJS",
1719
+ "moduleResolution": "node"
1677
1720
  }
1678
1721
  }
1679
1722
  ```
1680
1723
 
1681
- 2. **Use `moduleResolution: "Node"`** (legacy but widely supported):
1724
+ **Change to one of these options:**
1725
+
1726
+ 1. **`moduleResolution: "NodeNext"`** (recommended for most Node.js projects):
1682
1727
  ```json
1683
1728
  {
1684
1729
  "compilerOptions": {
1685
- "moduleResolution": "Node"
1730
+ "module": "NodeNext", // Changed from "CommonJS"
1731
+ "moduleResolution": "NodeNext" // Changed from "node"
1686
1732
  }
1687
1733
  }
1688
1734
  ```
1689
1735
 
1690
- **Note:** The runtime will work correctly regardless of TypeScript's resolution mode. This is purely a TypeScript type-checking issue, not a runtime problem.
1736
+ 2. **`moduleResolution: "bundler"`** (for bundler-based projects like Vite, Webpack, etc.):
1737
+ ```json
1738
+ {
1739
+ "compilerOptions": {
1740
+ "module": "CommonJS", // Can keep this or use "ESNext"
1741
+ "moduleResolution": "bundler" // Changed from "node"
1742
+ }
1743
+ }
1744
+ ```
1745
+
1746
+ 3. **`moduleResolution: "node16"`** (alternative to NodeNext):
1747
+ ```json
1748
+ {
1749
+ "compilerOptions": {
1750
+ "module": "node16", // Changed from "CommonJS"
1751
+ "moduleResolution": "node16" // Changed from "node"
1752
+ }
1753
+ }
1754
+ ```
1755
+
1756
+ **Why this is required:**
1757
+ - The legacy `moduleResolution: "node"` strategy doesn't understand package.json `exports` field
1758
+ - Modern resolution strategies (`node16`, `nodenext`, `bundler`) properly support subpath exports
1759
+ - This is a TypeScript configuration requirement, not a runtime issue - your code will run correctly regardless
1760
+
1761
+ **Note:** The runtime will work correctly regardless of TypeScript's resolution mode. This is purely a TypeScript type-checking issue.
1691
1762
 
1692
1763
  ## Error messages
1693
1764
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-env-resolver",
3
- "version": "6.1.1",
3
+ "version": "6.2.1",
4
4
  "description": "Type-safe environment variable resolver with async resolvers - lightweight, tree-shakeable, no dependencies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -79,6 +79,43 @@
79
79
  "default": "./dist/types.js"
80
80
  }
81
81
  },
82
+ "typesVersions": {
83
+ "*": {
84
+ "resolvers": [
85
+ "./dist/resolvers.d.ts"
86
+ ],
87
+ "validators": [
88
+ "./dist/validators.d.ts"
89
+ ],
90
+ "utils": [
91
+ "./dist/utils.d.ts"
92
+ ],
93
+ "builder": [
94
+ "./dist/builder.d.ts"
95
+ ],
96
+ "zod": [
97
+ "./dist/zod.d.ts"
98
+ ],
99
+ "valibot": [
100
+ "./dist/valibot.d.ts"
101
+ ],
102
+ "web": [
103
+ "./dist/web.d.ts"
104
+ ],
105
+ "cli": [
106
+ "./dist/cli.d.ts"
107
+ ],
108
+ "audit": [
109
+ "./dist/audit.d.ts"
110
+ ],
111
+ "resolver": [
112
+ "./dist/resolver.d.ts"
113
+ ],
114
+ "types": [
115
+ "./dist/types.d.ts"
116
+ ]
117
+ }
118
+ },
82
119
  "files": [
83
120
  "dist",
84
121
  "README.md"
@@ -113,6 +150,11 @@
113
150
  "url": "https://jagreehal.com"
114
151
  },
115
152
  "license": "MIT",
153
+ "repository": {
154
+ "type": "git",
155
+ "url": "https://github.com/jagreehal/node-env-resolver.git",
156
+ "directory": "packages/node-env-resolver"
157
+ },
116
158
  "sideEffects": false,
117
159
  "publishConfig": {
118
160
  "access": "public"
@@ -122,15 +164,15 @@
122
164
  },
123
165
  "devDependencies": {
124
166
  "@eslint/js": "^9.39.1",
125
- "@types/node": "^24.10.1",
126
- "@typescript-eslint/eslint-plugin": "^8.48.0",
127
- "@typescript-eslint/parser": "^8.48.0",
167
+ "@types/node": "^25.0.0",
168
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
169
+ "@typescript-eslint/parser": "^8.49.0",
128
170
  "eslint": "^9.39.1",
129
171
  "eslint-config-prettier": "^10.1.8",
130
172
  "eslint-plugin-import-zod": "^1.2.1",
131
- "prettier": "^3.6.2",
173
+ "prettier": "^3.7.4",
132
174
  "tsup": "^8.5.1",
133
175
  "typescript": "^5.9.3",
134
- "vitest": "^4.0.14"
176
+ "vitest": "^4.0.15"
135
177
  }
136
178
  }