From 06823fbf1c2e763a5bf76c3990ca98fbbcd98691 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 14 May 2024 14:05:49 +0800 Subject: updated node_modules --- node_modules/lilconfig/readme.md | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'node_modules/lilconfig/readme.md') diff --git a/node_modules/lilconfig/readme.md b/node_modules/lilconfig/readme.md index ac42df08..99c42623 100644 --- a/node_modules/lilconfig/readme.md +++ b/node_modules/lilconfig/readme.md @@ -42,6 +42,10 @@ lilconfigSync( */ ``` +## ESM + +ESM configs can be loaded with **async API only**. Specifically `js` files in projects with `"type": "module"` in `package.json` or `mjs` files. + ## Difference to `cosmiconfig` Lilconfig does not intend to be 100% compatible with `cosmiconfig` but tries to mimic it where possible. The key difference is **no** support for yaml files out of the box(`lilconfig` attempts to parse files with no extension as JSON instead of YAML). You can still add the support for YAML files by providing a loader, see an [example](#yaml-loader) below. @@ -87,29 +91,6 @@ lilconfig('myapp', options) }); ``` -### ESM loader - -Lilconfig v2 does not support ESM modules out of the box. However, you can support it with a custom a loader. Note that this will only work with the async `lilconfig` function and won't work with the sync `lilconfigSync`. - -```js -import {lilconfig} from 'lilconfig'; - -const loadEsm = filepath => import(filepath); - -lilconfig('myapp', { - loaders: { - '.js': loadEsm, - '.mjs': loadEsm, - } -}) - .search() - .then(result => { - result // {config, filepath} - - result.config.default // if config uses `export default` - }); -``` - ## Version correlation - lilconig v1 → cosmiconfig v6 -- cgit v1.2.3