-
Notifications
You must be signed in to change notification settings - Fork 2
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
prioritize import specigier over packagejson exported type #68
prioritize import specigier over packagejson exported type #68
Conversation
@@ -318,7 +318,9 @@ const esmparse = (spec, specifier, opts = {}) => { | |||
// if dynamic 'spectype', lookup 'commonjs' or 'module' | |||
// according to package.json | |||
specname = specname === spectype | |||
? getspectypenamedexportdefault(opts.packagejsontype) | |||
? isDirPathRe.test(specifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whole logic looks a bit... suspicious for me - it's a kind of mix of 'how to resolve exact import' (exports field logic) and 'how to detect module type - CJS or ESM' (type field). but, if it works - let's merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree :/
"specifier" here is basically a path such as opanai/path.js "path.js", a subpath such as opanai#subpath or a keyword-specifier such as "import" or "node" https://github.com/iambumblehead/resolvewithplus/blob/main/resolvewithplus.js#L517 pspecifier ? './' + pspecifier : specimport |
esm is ... very difficult |
Thx for explanation - now that code looks clear. BTW, ESM and resolution logic... they are simple, BUT if you can image the whole possible scenarios at once :) |
iambumblehead/esmock#321