-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate .d.mts
types for imports
#2472
Comments
In v1.5.0 the exports changed to put the From: "types": "./src/types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./src/types.d.ts",
"import": "./dist/floating-ui.core.mjs",
"module": "./dist/floating-ui.core.esm.js",
"default": "./dist/floating-ui.core.umd.js"
}
}, To: "types": "./src/types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./src/types.d.mts",
"default": "./dist/floating-ui.core.mjs"
},
"types": "./src/types.d.ts",
"module": "./dist/floating-ui.core.esm.js",
"default": "./dist/floating-ui.core.umd.js"
}
}, Which However, it looks like Are the types wrong? fails to resolve the types from ESM. I don't really understand how to fix this correctly. |
Seems like the issue is the |
Ok so I think adding the extensions to the For now, I'll simply revert the |
In my point of view, maybe you need to first tsc with |
I'm working on a pull request to replace rollup with vite. |
.d.mts
types for imports
Just to confirm here @atomiks, this would be the ideal? "types": "./src/types.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"import": {
"types": "./src/types.d.mts",
"default": "./dist/floating-ui.core.mjs"
},
"types": "./src/types.d.ts",
"module": "./dist/floating-ui.core.esm.js",
"default": "./dist/floating-ui.core.umd.js"
}
}, Seems like the generation of |
I did do that originally, but that's what led to this exact error in this issue :D Specifically: #2472 (comment) The CJS type defs don't need extensions in imports (and are compiled from the source without them), but ESM ones do. And yes, this part is set up to replace it with the "m" eventually even though it's unneeded currently: "import": {
"types": "./src/types.d.mts", // <----
"default": "./dist/floating-ui.core.mjs"
}, I also had trouble changing the |
I think I got a possible solution actually, if we flatten the types into a single file using something like api-extractor then there will be no relative import to worry about this: |
Describe the bug
Upgrading @floating-ui/dom from version 1.2.9 to 1.50 will give following errors:
To Reproduce
https://codesandbox.io/p/sandbox/fancy-moon-t5p4ps?file=%2Fpackage.json%3A12%2C1-12%2C31
Steps to reproduce the behavior:
yarn build
Expected behavior
No errors.
Screenshots
If applicable, add screenshots to help explain your problem.
Context:
The text was updated successfully, but these errors were encountered: