-
-
Notifications
You must be signed in to change notification settings - Fork 904
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
feat: deprecate deep requires #361
Conversation
ctavan
commented
Jan 28, 2020
•
edited
Loading
edited
- Add test that covers the fact that deep requiring still works.
@broofa while comparing the docs of the current v3.4.x and the new master I realized that now that I ship all transpiled sources in
no longer works. I remember from my analysis in the tc39 repo that lots of libraries are actually using the deep import style, after all it was the recommended way of importing the uuid module for years… I feel somewhat bad about introducing this breaking change:
Restoring the old directory structure in the npm package is certainly doable although with a bit more effort than just packaging the How do you feel about this one? |
Note to self: I should then probably also add a test case which covers this… I just found this issue by coincidence, there should be a regression test if we want to continue to support this style of import. |
26b5a73
to
a72e1eb
Compare
@broofa I have thought about this one again and I believe now is not the time to introduce a breaking change in how this library can be imported/required. Instead, I decided to remain backwards-compatible with deep requiring the algorithm versions but emit a deprecation warning when people do that. It looks something like this:
Edit:
I should have RTFM: https://nodejs.org/api/util.html#util_util_deprecate_fn_msg_code
|
a72e1eb
to
6bbdc54
Compare
6bbdc54
to
9aafa1c
Compare
BREAKING CHANGE: Explicitly note that deep imports of the different uuid version functions are deprecated and no longer encouraged and that ECMAScript module named imports should be used instead. Emit a deprecation warning for people who deep-require the different algorithm variants.
9aafa1c
to
20aa82b
Compare
@broofa I have now added a test case which asserts that deep imports now produce a |
No strong opinions, just a couple observations:
On that last item, one approach we haven't really discussed is breaking this up into separate modules, ala lodash's "lodash/array", "lodash/core", etc. E.g. |
When I initially picked up the modernization of this library it was because more and more people were specifically asking for ESModule support. So my main intention was to put out a new major release that makes the requested switch to ESModules so that Typescript and Webpack/rollup users can benefit from that. Dropping support for default insecure RNGs seems like a long-overdue leftover that, given the widespread support for I think we can provide what has been asked for by many users (ESModules) without having to break any existing usage of this library. After that we can still think of more radical approaches to evolve the API of this library, but I would prefer to deliver ESModules without any significant other changes to the API surface. Does that sound reasonable?
I think these days ESModules and named exports are the way to go. When you compare to lodash the per-method packages like
So I'm confident that promoting the modern import { v4 as uuidv4 } from 'uuid'; style syntax is as good as we can get with JS in 2020. The only thing that would come to my mind is renaming the imports, e.g. import { uuidv4 } from 'uuid'; However then we should probably go into the discussion of export names again. Shouldn't it then maybe rather be import { randomUUID, timeUUID, nameUUID3, nameUUID5 } from 'uuid'; ? I would prefer to leave that discussion for a later time. |
I'm considering to rewrite the entire README to use |
That all sounds good to me. Re: RunMD and ES6 imports, RunMD was a weekend project of mine (inspired by the need to keep |