-
-
Notifications
You must be signed in to change notification settings - Fork 37.1k
Utility method for exposing Node’s type resolution #49446
Copy link
Copy link
Closed as not planned
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Description
Activity
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues requesting new Node.js features.Issues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.Issues and PRs marked stale due to inactivity and scheduled for automatic closure.
Split off from nodejs/modules#389 (comment). I think it would be useful to have a function that returns how Node would try to interpret a file, in particular whether Node would try to parse a path to a
.jsfile as CommonJS or as ESM. This would spare tools from needing to reimplement Node’s “find the nearest parentpackage.jsonand see if it has a"type"field” algorithm.Whether the file would be interpreted successfully as that type is irrelevant; it could be a zero-byte file for all this API cares. One use case for this is for tools loading
.jsconfig files to know whether to try to load the files viarequireorimport().