Skip to content

Commit

Permalink
Tweak importOrRequireResolve to simplify slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Dec 14, 2024
1 parent f7db4ee commit c637999
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions markdownlint-cli2.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,9 @@ const importOrRequireResolve = async (dirOrDirs, id, noRequire) => {
}
// Try to load via import(...)
try {
// eslint-disable-next-line n/no-unsupported-features/node-builtins
const isURL = !pathDefault.isAbsolute(expandId) && URL.canParse(expandId);
const urlString = (
isURL ? new URL(expandId) : pathToFileURL(pathDefault.resolve(dirs[0], expandId))
).toString();
const url = URL.parse(expandId) || pathToFileURL(pathDefault.resolve(dirs[0], expandId));
// eslint-disable-next-line no-inline-comments
const module = await import(/* webpackIgnore: true */ urlString);
const module = await import(/* webpackIgnore: true */ url);
return module.default;
} catch (error) {
errors.push(error);
Expand Down

0 comments on commit c637999

Please sign in to comment.