Skip to content

Commit daf72b8

Browse files
authored
feat: remove deep requires (#426)
BREAKING CHANGE: Deep requiring specific algorithms of this library like require('uuid/v4'), which has been deprecated in uuid@7, is no longer supported. Instead use the named exports that this module exports. For ECMAScript Modules (ESM): ```javascript import { v4 as uuidv4 } from 'uuid'; uuidv4(); ``` For CommonJS: ```javascript const { v4: uuidv4 } = require('uuid'); uuidv4(); ``` No longer supported is this: ```javascript const uuidv4 = require('uuid/v4'); // <== NO LONGER SUPPORTED! uuidv4(); ```
1 parent 57d7597 commit daf72b8

9 files changed

Lines changed: 54 additions & 92 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,33 @@ import { v4 as uuidv4 } from 'uuid';
363363
Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if
364364
you find one, please).
365365

366+
## Upgrading From uuid\@7
367+
368+
### Only Named Exports Supported When Using with Node.js ESM
369+
370+
uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in
371+
Node.js ESM consequently imported the CommonJS source with a default export. This library now comes
372+
with true Node.js ESM support and only provides named exports.
373+
374+
Instead of doing:
375+
376+
```javascript
377+
import uuid from 'uuid';
378+
uuid.v4();
379+
```
380+
381+
you will now have to use the named exports:
382+
383+
```javascript
384+
import { v4 as uuidv4 } from 'uuid';
385+
uuidv4();
386+
```
387+
388+
### Deep Requires No Longer Supported
389+
390+
Deep requires like `require('uuid/v4')` [which have been deprecated in
391+
uuid\@7](#deep-requires-now-deprecated) are no longer supported.
392+
366393
## Upgrading From uuid\@3
367394

368395
"_Wait... what happened to uuid\@4 - uuid\@6?!?_"

README_js.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,33 @@ import { v4 as uuidv4 } from 'uuid';
353353
Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if
354354
you find one, please).
355355

356+
## Upgrading From uuid\@7
357+
358+
### Only Named Exports Supported When Using with Node.js ESM
359+
360+
uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in
361+
Node.js ESM consequently imported the CommonJS source with a default export. This library now comes
362+
with true Node.js ESM support and only provides named exports.
363+
364+
Instead of doing:
365+
366+
```javascript
367+
import uuid from 'uuid';
368+
uuid.v4();
369+
```
370+
371+
you will now have to use the named exports:
372+
373+
```javascript
374+
import { v4 as uuidv4 } from 'uuid';
375+
uuidv4();
376+
```
377+
378+
### Deep Requires No Longer Supported
379+
380+
Deep requires like `require('uuid/v4')` [which have been deprecated in
381+
uuid\@7](#deep-requires-now-deprecated) are no longer supported.
382+
356383
## Upgrading From uuid\@3
357384

358385
"_Wait... what happened to uuid\@4 - uuid\@6?!?_"

deprecate.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@
3434
"CONTRIBUTING.md",
3535
"LICENSE.md",
3636
"README.md",
37-
"deprecate.js",
3837
"dist",
39-
"v1.js",
40-
"v3.js",
41-
"v4.js",
42-
"v5.js",
4338
"wrapper.mjs"
4439
],
4540
"devDependencies": {

test/unit/deep-require-deprecation.test.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

v1.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

v3.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

v4.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

v5.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)