Skip to content

Commit 74b0175

Browse files
committed
docs: document native Node.js ESM pitfalls
1 parent 94e2f3e commit 74b0175

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,27 @@ you find one, please).
365365

366366
## Upgrading From uuid\@7
367367

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.
371+
Importing it in a Node.js ES Module consequently imported the CommonJS source
372+
with a default export. This is no longer supported as this module now only
373+
provides named exports.
374+
375+
Instead of doing:
376+
377+
```javascript
378+
import uuid from 'uuid';
379+
uuid.v4();
380+
```
381+
382+
you will now have to use the named exports:
383+
384+
```javascript
385+
import { v4 as uuidv4 } from 'uuid';
386+
uuidv4();
387+
```
388+
368389
### Deep Requires No Longer Supported
369390

370391
Deep requires, [which have been deprecated in uuid\@7](#deep-requires-now-deprecated) are now no

README_js.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,27 @@ you find one, please).
355355

356356
## Upgrading From uuid\@7
357357

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.
361+
Importing it in a Node.js ES Module consequently imported the CommonJS source
362+
with a default export. This is no longer supported as this module now only
363+
provides named exports.
364+
365+
Instead of doing:
366+
367+
```javascript
368+
import uuid from 'uuid';
369+
uuid.v4();
370+
```
371+
372+
you will now have to use the named exports:
373+
374+
```javascript
375+
import { v4 as uuidv4 } from 'uuid';
376+
uuidv4();
377+
```
378+
358379
### Deep Requires No Longer Supported
359380

360381
Deep requires, [which have been deprecated in uuid\@7](#deep-requires-now-deprecated) are now no

0 commit comments

Comments
 (0)