-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.loadersIssues and PRs related to ES module loadersIssues and PRs related to ES module loadersstale
Description
- Version: 11.0
- Platform: macOS 10.14 (18A389)
- Subsystem: bootstrap,
--experimental-modules(only)
When using shebangs to specify --loader specifically for --experimental-modules a file could want to use a relative path to it's own loader file.
In this specific case, the module file is it's own loader, as if things are not already complicated enough.
#!/usr/bin/env node --experimental-modules --loader ./index.mjs
export function resolve(... args) {
// …
if (resolved.url === import.meta.url) resolve.url += '#initialize';
return resolved;
}
function bootstrap() {
// …
}
import.meta.url.endsWith('#initialize') && bootstrap();The issue is not related to modules down the road, it is strictly related to the current way relative --loader paths are resolved.
Executing this file from other paths other than it's own directory looks for ./index.mjs in the cwd and not the file's own directory.
I believe that Loader being a variable aspect of a shebang is at least problematic, more so risky, and simply not practical (I could be wrong).
Can we fix (or justify) this bug (or feature) please?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.loadersIssues and PRs related to ES module loadersIssues and PRs related to ES module loadersstale