-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support .js config files in "type": "module" projects? #29
Comments
Hi and thank you for the issue. Since this package attempts to mimic cosmiconfig, I would rather to wait for them to make a major release with support for ESM native node modules and drop nodejs v10. From my understanding it is not yet implemented as nodejs does not offer an API to clear cache for imported modules like From your diff I can see that there is currently an issue with lilconfig as loaders can be async for const loadESMDefault = p => import(p).then(x => x.default)
lilconfig('myapp', {
loaders: {
'.js': loadESMDefault,
'.mjs': loadESMDefault,
}
}).load('./path/to/esm/file.js') // Promise<config> Await is missing here and here. Let me know what you think about this. |
Thanks for the fast response and great idea splitting the patch. I created a pull request adding the |
fix: support async loaders with lilconfig.search (#29)
Nicely done. I've released a new version v2.0.5 with your fix, this should make it easier for people to consume ESM configs. |
Hi, it seems to me that osmiconfig now supports this looking at the changelog for version 8.2.0. Could we please reopen this? Happy to send a PR if necessary... |
Hi @marekdedic this sounds reasonable to me. Happy to review and merge your PR. I’ve reopened the issue. |
closed by #46 |
Hi there,
would you consider supporting
.js
files inside projects with"type": "module"
set? Otherwise is pretty hard to provide config files sometimes, because not every user oflilconfig
actually includes.cjs
as an allowed file extension.Currently I'm using the following patch, which should work for CommonJS and ECMAScript Modules since Node 12, so it would require a semver-major bump (or a fallback for Node 10):
The text was updated successfully, but these errors were encountered: