-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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 that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale
Description
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 .js
file as CommonJS or as ESM. This would spare tools from needing to reimplement Node’s “find the nearest parent package.json
and 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 .js
config files to know whether to try to load the files via require
or import()
.
ExE-Boss, AlicanC, niieani, G-Rath, alexey-detr and 4 more
Metadata
Metadata
Assignees
Labels
esmIssues and PRs related to the ECMAScript Modules implementation.Issues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.stale