esm: make extension-less errors in type:module actionable

PR-URL: https://github.com/nodejs/node/pull/42301
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Bradley Farias authored and GitHub committed 2022-03-15 00:59:32 +00:00
1 parent 6f8c983f90
commit a01302b8df
5 files changed
+35 -13

No files matched your search

+1 -1
View File
@@ -1091,7 +1091,7 @@ async function getPackageType(url) {
// required by the spec
// this simple truthy check for whether `url` contains a file extension will
// work for most projects but does not cover some edge-cases (such as
// extension-less files or a url ending in a trailing space)
// extensionless files or a url ending in a trailing space)
const isFilePath = !!extname(url);
// If it is a file path, get the directory it's in
const dir = isFilePath ?