Bug: `native` platform exports are pointing to the incorrect files when also building `node`
j3tan opened this issue · 5 comments
j3tan commented
version: 3.x
Test Repo: https://github.com/j3tan/packemon-native-web-package
native
exports
look like:
{
"exports": {
"./mobile": {
"react-native": {
"types": "./lib/native/mobile/index.d.ts", <==== This is incorrect
"default": "./lib/native/mobile.js" <==== This is incorrect
},
"default": "./lib/native/mobile.js" <==== This is incorrect
},
}
}
but the file structure looks like:
lib/
├── mobile/
│ ├── mobile.js
│ ├── mobile.js.map
├── native/
│ ├── index.d.ts
│ ├── index.d.ts.map
{
"packemon": [
{ <== Removing this target fixes the issue
"bundle": true,
"format": "lib",
"platform": "node"
},
{
"bundle": true,
"format": "esm",
"platform": "browser",
"inputs": {
"web": "src/web/index.ts"
}
},
{
"bundle": true,
"format": "lib",
"platform": "native",
"inputs": {
"mobile": "src/mobile/index.ts"
}
}
]
}
My guess is a conflict when building 2 format lib
targets?
j3tan commented
I can confirm that using native
platform without subpaths works fine.
milesj commented
wespickett commented
I think the issue is that there is no fallback "types" field exported, so if a package is being built for npm publishing, the types
for an import to the /types
path will not be found. Once that "default"/fallback "types" field was added in I was able to build successfully
I created a PR with a fix: #194
wespickett commented