Skip to content

Commit 89024c4

Browse files
committed
Update migration info, close nodeca#770
1 parent f1e45cd commit 89024c4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

docs/migrate_v4_to_v5.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ CommonJS keeps working through destructuring:
3939
const { load, dump } = require('js-yaml')
4040
```
4141

42+
If you want to keep the old namespace-style calls, import the ESM namespace
43+
instead:
44+
45+
```js
46+
import * as yaml from 'js-yaml'
47+
48+
yaml.load(source)
49+
yaml.dump(data)
50+
```
51+
52+
js-yaml v5 does not provide an ESM default export by design. Prefer named
53+
exports for new code, or use the namespace import above when migrating code that
54+
expects `yaml.load()` / `yaml.dump()`.
55+
4256
Exports are now flat. The `types` namespace, the `Type` class and
4357
`DEFAULT_SCHEMA` are gone, and internal `js-yaml/lib/...` imports no longer
4458
resolve. If you used any of those, read on.

0 commit comments

Comments
 (0)