Skip to content
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

Proposal: Separate submodules for different UUID versions #154

Closed
broofa opened this issue Nov 23, 2016 · 6 comments
Closed

Proposal: Separate submodules for different UUID versions #154

broofa opened this issue Nov 23, 2016 · 6 comments
Assignees

Comments

@broofa
Copy link
Member

broofa commented Nov 23, 2016

I expect it's rare for someone using this library to want both v1() and v4() support. 99% of the time they'll only care about one flavor. Thus, I think it would make sense to separate the code for the different versions into separate submodules. So, for example ...

var uuid = require('uuid/v1'); // returns v1() for timestamp-based UUIDs
var uuid = require('uuid/v4'); // returns v4() for random UUIDs

One immediate benefit is that if you don't use v1(), you don't need to deploy the v1() code, which is ~75% of the code in this module.

Another benefit is that it becomes straight-forward to add support for v3() and v5() UUIDs, which has occasionally been requested, but that I resisted in the original node-uuid library because it required shipping JS code to do MD5 / SHA hashes. But now that uuid puts the burden for packaging on the user, it'd be straight-forward to implement those versions as well (and provide the requisite md5.js/md5-browser.js or sha.js/sha-browser.js modules as needed for node/browser support).

Thoughts? Is this a reasonable direction to take this library?

@broofa broofa changed the title Proposal: Separate submodules for different versions of UUID code Proposal: Separate submodules for different UUID versions Nov 23, 2016
@defunctzombie
Copy link
Collaborator

👍 from me. No maintenance burden on our end to split the code out into the separate files.

Eventually this won't even be needed with the various "tree shaking" and optimization features going into rollup and webpack bundlers. They will be able to remove functions from the bundle which are not used.

broofa added a commit to broofa/node-uuid that referenced this issue Nov 24, 2016
broofa added a commit to broofa/node-uuid that referenced this issue Nov 26, 2016
broofa added a commit that referenced this issue Nov 26, 2016
uuid versions into separate modules, per #154
@broofa broofa closed this as completed Nov 27, 2016
@reintroducing
Copy link

I just ran a yarn install with uuid 3.0 and am using the code from the readme:

import {v4} from 'uuid/v4';
...
// later using v4() to generate the uuid

Seeing this in terminal:
ERROR in ./core/js/ui/TextInput.jsx
Module not found: Error: Cannot resolve module 'uuid/v4' in /Users/przybylski/retrofit/dev/code/front-end/core/js/ui
@ ./core/js/ui/TextInput.jsx 19:9-27

Any idea why this would be happening?

@reintroducing
Copy link

Hmm, looks like yarn is still pulling the version that has uuid.js in the code hence why this isn't working. Any way you can publish a new version to npm to fix this?

@broofa
Copy link
Member Author

broofa commented Nov 28, 2016

@defunctzombie - based on your comments on #159, I'll let you publish this.

@broofa broofa reopened this Nov 28, 2016
@broofa broofa assigned broofa and defunctzombie and unassigned broofa Nov 28, 2016
@defunctzombie
Copy link
Collaborator

Released in v3.0.1

@ganqqwerty
Copy link

@defunctzombie Does it mean that the uuid library is tree-shakeable? Do you need to declare anything within the sideEffects section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants