-
Notifications
You must be signed in to change notification settings - Fork 772
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
Cannot find module 'fs-extra/esm' or its corresponding type declarations.ts(2307) #979
Comments
The fact that the first line worked in v10.1.0 indicates your typescript transpiler is doing some kind of extra compatibility layer here, which somehow was broken in v11. I'm not a typescript guy, so I can't say offhand what's gone wrong here. Are you running the latest version of TS? If all else fails, a minimal example repo will probably be useful here. |
@RyanZim I just had a quick skim through https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html and found this:
Based on that, this should work: {
"main": "./lib/index.js",
"module": "./lib/esm.mjs",
"exports": {
"import": "./lib/esm.mjs",
"require": "./lib/index.js"
}
} In other words, removing Update: Just double checked, and those changes resolve the issue with TypeScript. (Background: mdn/yari#7697) |
This is fixed in TypeScript v4.7: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#package-json-exports-imports-and-self-referencing |
Furthermore, your proposed change would be a breaking change; since the ESM version is not compatible with the regular version of fs-extra, we can't just ship it to all |
We're on TypeScript 4.9.
Not sure why you just close my draft PR, but okay. 🤷 |
FWIW I only found two packages among a long list of dependencies that we're using that export as PS: The polite way would have been to add a review to my PR and ask me to revert the changes to the |
You may have read it already, but just to make it abundantly clear, I don't use TS, so perhaps I'm misunderstanding, but from the TS v4.7 release notes, it looks like they added support for
Sorry, didn't notice it was a draft PR. Didn't mean to offend, feel free to open a new one. Is |
Based on a quick look through the For example: https://github.com/WebReflection/flatted/blob/2ffe0c8f513b86d51159460a1a91561df9ba60fe/package.json#L54-L62 |
Bundler tools, like Rollup and Webpack use it. See this StackOverflow post for more information. |
FWIW Note that using edit: And that's the important bit from that TypeScript blog post cited above:
|
Yeah, this is shorthand notation: https://nodejs.org/api/packages.html#exports-sugar I'm curious if changing it to an object with only |
This is still a problem as of v11.1.1 & Typescript 5.1.0-dev.20230417. Can't use this library b/c of this issue. |
@btakita Importing |
|
Both importing from fs-extra and fs-extra/esm doesn't work anymore in v11.0.0. I tried the following lines in my fs.ts file:
The top line does work in v10.1.0. Am I doing something wrong?
fs-extra
version: v11.0.0The text was updated successfully, but these errors were encountered: