Comparing version 2.0.4 to 2.0.5
@@ -108,3 +108,3 @@ "use strict"; | ||
if (fileName === 'package.json') { | ||
const pkg = loader(filepath, content); | ||
const pkg = await loader(filepath, content); | ||
const maybeConfig = getPackageProp(packageProp, pkg); | ||
@@ -127,3 +127,3 @@ if (maybeConfig != null) { | ||
validateLoader(loader, loaderKey); | ||
result.config = loader(filepath, content); | ||
result.config = await loader(filepath, content); | ||
} | ||
@@ -130,0 +130,0 @@ result.filepath = filepath; |
{ | ||
"name": "lilconfig", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"description": "A zero-dependency alternative to cosmiconfig", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -62,8 +62,10 @@ # Lilconfig ⚙️ | ||
## Loaders example | ||
## Loaders examples | ||
### Yaml loader | ||
If you need the YAML support you can provide your own loader | ||
```js | ||
import {lilconig} from 'lilconfig'; | ||
import {lilconfig} from 'lilconfig'; | ||
import yaml from 'yaml'; | ||
@@ -91,2 +93,25 @@ | ||
### 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 | ||
@@ -93,0 +118,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15386
119