Skip to content

Commit

Permalink
feat: remove deep requires (#426)
Browse files Browse the repository at this point in the history
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();
```
  • Loading branch information
ctavan authored Apr 29, 2020
1 parent 57d7597 commit daf72b8
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 92 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,33 @@ import { v4 as uuidv4 } from 'uuid';
Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if
you find one, please).

## Upgrading From uuid\@7

### Only Named Exports Supported When Using with Node.js ESM

uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in
Node.js ESM consequently imported the CommonJS source with a default export. This library now comes
with true Node.js ESM support and only provides named exports.

Instead of doing:

```javascript
import uuid from 'uuid';
uuid.v4();
```

you will now have to use the named exports:

```javascript
import { v4 as uuidv4 } from 'uuid';
uuidv4();
```

### Deep Requires No Longer Supported

Deep requires like `require('uuid/v4')` [which have been deprecated in
uuid\@7](#deep-requires-now-deprecated) are no longer supported.

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
27 changes: 27 additions & 0 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,33 @@ import { v4 as uuidv4 } from 'uuid';
Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if
you find one, please).

## Upgrading From uuid\@7

### Only Named Exports Supported When Using with Node.js ESM

uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in
Node.js ESM consequently imported the CommonJS source with a default export. This library now comes
with true Node.js ESM support and only provides named exports.

Instead of doing:

```javascript
import uuid from 'uuid';
uuid.v4();
```

you will now have to use the named exports:

```javascript
import { v4 as uuidv4 } from 'uuid';
uuidv4();
```

### Deep Requires No Longer Supported

Deep requires like `require('uuid/v4')` [which have been deprecated in
uuid\@7](#deep-requires-now-deprecated) are no longer supported.

## Upgrading From uuid\@3

"_Wait... what happened to uuid\@4 - uuid\@6?!?_"
Expand Down
20 changes: 0 additions & 20 deletions deprecate.js

This file was deleted.

5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
"CONTRIBUTING.md",
"LICENSE.md",
"README.md",
"deprecate.js",
"dist",
"v1.js",
"v3.js",
"v4.js",
"v5.js",
"wrapper.mjs"
],
"devDependencies": {
Expand Down
35 changes: 0 additions & 35 deletions test/unit/deep-require-deprecation.test.js

This file was deleted.

8 changes: 0 additions & 8 deletions v1.js

This file was deleted.

8 changes: 0 additions & 8 deletions v3.js

This file was deleted.

8 changes: 0 additions & 8 deletions v4.js

This file was deleted.

8 changes: 0 additions & 8 deletions v5.js

This file was deleted.

0 comments on commit daf72b8

Please sign in to comment.