Skip to content

Commit

Permalink
docs: document native Node.js ESM pitfalls
Browse files Browse the repository at this point in the history
  • Loading branch information
ctavan committed Apr 29, 2020
1 parent 94e2f3e commit 74b0175
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Expand Up @@ -365,6 +365,27 @@ 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 a Node.js ES Module consequently imported the CommonJS source
with a default export. This is no longer supported as this module now 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, [which have been deprecated in uuid\@7](#deep-requires-now-deprecated) are now no
Expand Down
21 changes: 21 additions & 0 deletions README_js.md
Expand Up @@ -355,6 +355,27 @@ 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 a Node.js ES Module consequently imported the CommonJS source
with a default export. This is no longer supported as this module now 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, [which have been deprecated in uuid\@7](#deep-requires-now-deprecated) are now no
Expand Down

0 comments on commit 74b0175

Please sign in to comment.