-
Notifications
You must be signed in to change notification settings - Fork 313
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
Bring back module entry in package.json #70
Conversation
Unfortunately that module change caused the library to become unusable for most people. var Promise = require(‘promise-polyfill’); no longer works. Only ES6 modules work. Happy to accept a PR that handles both, but this PR will not be accepted as is. I value backwards compatibility very highly. |
Honestly I don't see why this could have break usage for most people, I've created a sample repository https://github.com/Andarist/promise-polyfill-example which uses this PR as You can check it out that I easily use
Sure thing, me too. I just believe this field was removed based on some wrong assumptions. |
module in package.json is used by browserify and webpack. If you have an ES6 file at module, everyone that is not using newer webpack or Babel will have an error. They need to do something like require(‘promise-polyfill’).default which isn’t ideal and not a breaking change specified in version 7. |
#67 issue was the cause of the change. Let me know if you have a better way to fix it. Happy to fix it a better way. |
from #67 it is not clear to me what the exact problem was, it certainly doesn't look that It indeed seems "break" webpack2+ (webpack1 is not module-aware so it wouldnt even try to use this field) WHEN somebody uses I understand that you don't want to break things right now, so I'd advise to just release promise-polyfill@8 with You'll do whatever you consider appropriate ofc, but I think this article is relevant https://medium.com/@mikeal/stop-supporting-old-releases-70cfa0e04b0c so I'd encourage you to go with the proposed approach (releasing v8). |
I am a little torn on this one. I completely agree that it would be awesome to support ES6 and require together. I don’t agree with the dropping the support of older releases. This library is kind of the exact opposite. It is meant specifically to support older browsers. It is completely useless for newer browsers/node. I prefer keeping the current behavior, unless I get an overwhelming number of people wanting ES6 imports. There isn’t any benefit for defaulting to ES6 currently is there? Tree shaking doesn’t really apply to this library. |
I just want to start with a note that I'm not a native english speaker and while I can express my thoughts, doing it in a polite, pleasant, way is often really hard. I realize that many times my words may sound harsh, but I have no intention of being that way. Always just discussing with an open mind. Let's go back to the topic though 😄
Sidenote: ambiguity can be eliminated in favor of using The latter case (using require in modern bundlers) is not that often seen in the wild and should be discouraged, because users of that "style" are losing by using this combination. I've refactored dozens of libraries to es modules and it's the first time I've encountered this problem and this truly leads me to the conclusion that there are not many users of modern bundlers using require calls and even if they do then they are already accustomed to adding
Im all in as to supporting older browsers, problem arises when supporting legacy style (using require) in modern build tooling. This is a different thing.
Problem with this is that most people dont care, dont notice small things adding up. Only a minority investigates dependencies and tries to improve them for majority of users.
Tree shaking applies to this and every other library. Even if there is nothing to be tree-shaken off from the library, there is still an issue if library itself is tree-shakeable. I'ce prepared illustration of the problem for other library, but it's applicable to any other. You can read more about it here and see example repository here. There is also an issue of "scope hoisting" (webpack does this optimization only for es modules libraries) which won't be done if you distribute cjs format only. This is matter of few bytes being added (and runtime startup cost increasing) to consumers' bundles, it is somewhat microoptimization, especially if we consider a single library ( If you have any questions regarding mentioned stuff, please let me know so I can explain in more detail. |
I will add this to version 8, along with a couple other breaking changes. |
What I believe should be done to avoid cjs/esm interop problems is to use |
Updated version 8 with module reference. Will update with new version of NPM soon. f13a09f |
Published version as beta. npm install promise-polyfill@beta |
Not sure why this commit has removed it.
jsnext:main
andmodule
are the same field (meaning that their goal is the same).jsnext:main
was renamed tomodule
and latter is more standard, some tools understands both of them, some need additional configuration to pick upjsnext:main
at all and some already even have droppedjsnext:main
support.To sum it up -
jsnext:main
is older and considered being a legacy field.module
is the one that should prevail, although packages might have both to support wider range of tools and their various versions.