Skip to content

Commit d8dd645

Browse files
authored
docs: moduleResolution paths
using NodeNext for moduleResolution only allows defined import paths
1 parent 50cac1d commit d8dd645

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,40 @@ CJS build contains `preserveModules` enabled and that creates bundle problems
7474
7575
- Useing a browser field and `preserveModules` don't copy files specified by this field, so it creates issues like https://github.com/TanStack/query/issues/3965
7676
77+
### `moduleResolution` `NodeNext` only allows defined import paths
78+
79+
When setting moduleResolution in our tsconfig to NodeNext. When this is enabled, the module resolution will only allow importing from paths that are defined within the exports config. Because only `types/index.d.ts` is available for import, it can cause these kinds of embedded imports to fail:
80+
81+
```javascript
82+
import("@stitches/react/types/css-util").CSS
83+
```
84+
85+
An alternative would be to ensure that all types are exported from the types/index.d.ts file.
86+
87+
> see https://github.com/stitchesjs/stitches/pull/1115#issue-1441336030
88+
89+
#### correct manifest
90+
91+
```diff
92+
"exports": {
93+
".": {
94+
"require": "./dist/index.cjs",
95+
"import": "./dist/index.mjs",
96+
"types": "./types/index.d.ts"
97+
},
98+
+ "./types/*": {
99+
+ "types": "./types/*.d.ts"
100+
},
101+
"./global": "./dist/index.global.js"
102+
},
103+
"files": [
104+
"dist/*.cjs",
105+
"dist/*.js",
106+
"dist/*.map",
107+
"dist/*.mjs",
108+
"types/*.d.ts"
109+
],
110+
```
77111
78112
## `load-esm.{ts,mts}`
79113

0 commit comments

Comments
 (0)