-
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 loading .mjs files with async API #46
Conversation
I noticed that tests fail on node v14/16/18 with a
I see a few of paths forward:
UPD: I falsly credited only // node script.js
const {lilconfig} = require('./dist/index.js');
const path = require('path');
async function main() {
const stopDir = __dirname;
const searchFrom = path.join(stopDir, 'src', 'spec', 'esm-project', 'foo', 'bar', 'baz');
const result = await lilconfig('esm', {stopDir}).search(searchFrom);
console.log(result); // {esm: true}
}
main(); At this point I am fine with keeping the main test suit, linter and build to run on the last node.js only and extracting a few main use cases to be tested with uvu on a matrix of older 14/16/18 nodejs versions. |
I think this PR is finally ready to land. If all goes well I will be releasing the new version this week |
Since I am not supporting any of the features that were added to cosmiconfig in v9, I won't be updating readme regarding these features. Finally merging |
…les with async api Co-authored-by: marekdedic <[email protected]>
…or an empty string input
This PR supersedes #45
We should be able to be able to load native esm modules with lilconfig. To do this a few changes have to be made
require
by separatingdefaultLoaders
anddefaultLoadersSync
.mjs
in search placesThe following is notes from while I was researching and implementing this
version compatibility
added mjs loading in cosmiconfig 8.2.0 see changelog, async api onlyPromise.resolve().then(() => require(x))
, workaroundAside: skeptical if we should make this change. Previous error message is subjectively clearer. Might revert the commit with these changes.
searcher.load()
Aside: not sure if this should be ported either. New error message from node itself is not helpful and will be hard to debug for end users