mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-08 08:44:37 +08:00
probeNodeFileImportRefusal resolved a relative or absolute specifier as a filesystem path, so a percent escape, a query or a fragment became part of the path: "./a%20b.mjs" was looked up as "a%20b.mjs", and "./x.mjs?v=1" of an existing file rejected. It now resolves the specifier as a URL against the importer's file URL, as Node's ESM resolution does: the message names the decoded path without the query or fragment, and the error's url is the resolved URL with them. A path ending in "/", an encoded "/" or "\" and a malformed escape, which Node refuses with other errors, keep the current lowering. An absolute specifier that CommonJS resolution finds (for example a file named without its extension) gets Node's "Did you mean to import" hint. Node resolves the hint of a relative specifier against the process's working directory, so relative specifiers get none. npm-file-import.test.ts compares the probe with Node's import() rejections for 29 specifiers, and the dynamic-import-not-found corpus program covers an escaped specifier with a query and fragment.