-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
"exports" config #20
Comments
Repeating my comment from another issue: If in fact every single possible require path in v2.1 is available in v2.2, then it’s not breaking. This includes: is-promise Adding exports is intended (by the node modules group) to be a breaking change in almost every case. Adding ESM after that is what’s not supposed to have to be breaking. |
I'm still running into issues with 2.2.1: "No Valid Exports main found for <path_to_module>" when I try running I won't pretend to understand what the underlying issue is but I can confirm I'm on 2.2.1 at this point. |
@rapdash mrm doesn't look like it has is-promise as a dependency |
@rapdash What's the output of |
@ljharb all those require paths are available. |
Yarn Why gives me
|
@ForbesLindesay not in latest master - each of them would need to be an explicit key in the exports object. CJS resolution doesn’t apply to export paths. |
Ah, now I understand, not having |
@ljharb I get that technically, adding |
@ForbesLindesay Is that last message directed at me a typo or are you actually saying that |
I'm tried reinstall create-react-app with: |
2.2.2 removes "exports" so should fix this. @rapdash sorry, meant to say mrm doesn't depend on is-promise. Can you tell me if 2.2.2 fixes your problem. |
Everything reachable is part of the public api imo. Either way, try requiring your package in node v13.0 and v13.1 and also v13.2. It takes a much more complex exports object to avoid breakage. If you’re insistent on not reverting and saving it for a v3, I’ll be happy to make a PR in a few hours that exhaustively preserves back compat for all node versions. |
@ForbesLindesay 2.2.2 did the trick! Thank you to everyone who moved so fast on this. |
@ljharb Yeah, I can certainly see your side of the argument; not sure I 100% agree, but point taken. Will certainly keep that in mind when I add ESM to my own packages. BTW, feels like a blog post/gist about migrating a package from CJS to dual CJS/ESM might be useful to the community, if you're ever in the writing mood. 😀 |
@ForbesLindesay You're probably on it, but just in case you're not, https://github.com/then/is-promise/releases should have release notes for the new versions to note the removal of ESM support. |
@ljharb I've reverted the "exports" bit as a temporary fix. Not being able to add an esm export as a non-breaking change is a pretty big pain point. This could have been resolved with a simple flag to indicate whether all files were importable. Until the situation improves significantly. I will abandon any attempts to support es modules. |
Note that you can import CJS, so the only reason anyone ever needs to take any steps to support ESM is if they’d have named exports, in which case that’s a simple wrapper .mjs file. Adding “exports” is a good idea separate from ESM - it’s just not trivially nonbreaking. I’m still happy to add it for you in a PR in a few hours, if you’re interested. |
If adding |
In the far-distant future, I do forsee tooling that will only work with ESM, that will allow some cool static analysis optimization stuff, but that's way out there. |
I agree with @RyanZim, ljharb I think a blog post explaining how to deal with ESM properly would be a benediction to everyone distributing packages for node. I've read quite a lot, and even after that, I am not sure what is the appropriate way to deal this properly. |
@ljharb it would be much better, if you have the time, to update the node.js documentation to add a clear warning about the possible breaking change, preferably before the long, incredibly detailed section on the "Dual Package Hazard". If @eemeli's suggestion is accurate, perhaps a note about it could be added as an example. I read the documentation, and then made this change thinking it was pretty safe, that's the problem that needs fixing. This package can stay as is because I don't want to risk another release at this time. |
This is exactly the kind of thing I had in mind. For example, I'm not sure how well Rollup handles CommonJS modules, it certainly didn't when it was first released. |
@ForbesLindesay Can you unpublish |
@fisker done |
This fixed it |
just wanted to add my 2c here, this was my call as requested -
this fixed it for me |
@RyanZim given dynamic import, and how rarely dynamic/conditional requires are used, i don't think that's true, since you can already do identical static analysis right now with CJS and ESM. |
macOS Catalina 10.15.3 Unknown error: Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /usr/local/lib/node_modules/@angular/cli/node_modules/is-promise/package.json |
@sapatech it looks like you still have the outdated |
Still have the issue @ForbesLindesay
|
@gnorbsl It must be some kind of caching in angular then, since there is no |
I have the same issue creating a new vue js project. I just installed the latest vue js client
I tried nodejs version: v14.0.0 |
If package authors don't explicitly include all previously supported entry points introducing package.exports will be a Semver-Major change. Add a warning about this behavior and offer two potential solutions for module authors. Refs: then/is-promise#20
I've gone ahead and opened a docs change for exports FWIW the section just about the explicit note does mention that the interface will be broken, but I totally agree we should make this clearer / more obvious. A couple of people have gotten bit by the Apologies that you got bit by this and thank you for taking new technology for a spin. other may disagree but I think that adding a @RyanZim I can understand where you are coming from debating what parts of the interface are part of the "Contract" of an App. While introducing exports could technically be considered Semver-Minor I think practically there is no way to do it without the carve out I've mentioned before. Folks relying on internals sucks as a maintainer... but if you break someones workflow it is broken. I think that one could definitely have ground to stand on to say "we never supported this and if we broke you I'm sorry but thems the breaks"... but it is also easy to just revert the change and reland in a major, which is what it seems is happening here. Anyway, happy to debate Semver some other time, I don't even agree with myself half the time ¯_(ツ)_/¯ |
For problems with build failures due to caching, I sometimes have to do:
Please try that if you are still experiencing problems, even if you are 100% sure that you have only v2.2.2 installed. |
Ran into this issue when building an angular project after installing firebase via If you have the same issue, manually installing is-promise@2.2.2 fixed it for me via previous output of
|
The static analysis thing is commonly mentioned, but as of yet I've seen exactly zero credible arguments as to how ESM code would be more statically analyzable. It's still the same code, just using different import/export syntax; top-level requires are equally statically analyzable, and dynamic requires are just as unanalyzable as dynamic Really the only reason why tooling would "only work with ESM", is because it's currently the hip thing, the introduction of it has caused an (IMO completely unnecessary and undesirable) ecosystem split, and the author doesn't want to support two module syntaxes; not because of any actual technical reason. (And I say this as someone who's working on a fair bit of static analysis tooling.) |
@joepie91 This is mostly true. There aren't any real issues that prevent statically analysing CommonJS, but it definitely requires two implementations, so there are going to be tools going forwards that don't support it. If you are still having problems with this, you just need to clear your npm (or yarn) cache. |
Please comment on this issue if you are still experiencing issues wen upgrading to 2.2.1
The text was updated successfully, but these errors were encountered: