forked from mysticatea/eslint-plugin-node
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Closed
Description
When doing a self-import (at least for scoped packages) I get a n/no-missing-import
error. I'm doing it for my project tests files, and when debugging it, I've traced it down to
eslint-plugin-n/lib/converted-esm/import-meta-resolve.js
Lines 41 to 62 in 2ce285d
// node_modules/import-meta-resolve/lib/package-json-reader.js | |
var import_fs = __toESM(require("fs"), 1); | |
var import_path = __toESM(require("path"), 1); | |
var reader = { read }; | |
var package_json_reader_default = reader; | |
function read(jsonPath) { | |
return find(import_path.default.dirname(jsonPath)); | |
} | |
function find(dir) { | |
try { | |
const string = import_fs.default.readFileSync(import_path.default.toNamespacedPath(import_path.default.join(dir, "package.json")), "utf8"); | |
return { string }; | |
} catch (error) { | |
if (error.code === "ENOENT") { | |
const parent = import_path.default.dirname(dir); | |
if (dir !== parent) | |
return find(parent); | |
return { string: void 0 }; | |
} | |
throw error; | |
} | |
} |
package.json
file and returning its contend when called from const source = package_json_reader_default.read(path4).string; |
eslint-plugin-n/lib/converted-esm/import-meta-resolve.js
Lines 683 to 688 in 2ce285d
const packageConfig2 = getPackageConfig(packageJsonPath, specifier, base); | |
if (packageConfig2.exports !== void 0 && packageConfig2.exports !== null) | |
return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig2, base, conditions).resolved; | |
if (packageSubpath === ".") | |
return legacyMainResolve(packageJsonUrl, packageConfig2, base); | |
return new import_url2.URL(packageSubpath, packageJsonUrl); |
On the other hand, I've found that in fact this file is a transpiled one, probably generated with webpack or something like that, so it's ugly to work with it. Original import-meta-resolve exists, and it's updated from two months ago, so why don't use it instead using a big blob?
Metadata
Metadata
Assignees
Labels
No labels