Skip to content

Commit e6be3a3

Browse files
authored
Use process.argv[1] as a fallback for new NodePackageImporter() (#275)
Closes #274
1 parent 32a8dfe commit e6be3a3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/src/importer-registry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// MIT-style license that can be found in the LICENSE file or at
33
// https://opensource.org/licenses/MIT.
44

5+
import {createRequire} from 'module';
56
import * as p from 'path';
67
import {URL} from 'url';
78
import {inspect} from 'util';
@@ -21,6 +22,10 @@ export class NodePackageImporter {
2122
? p.resolve(entryPointDirectory)
2223
: require.main?.filename
2324
? p.dirname(require.main.filename)
25+
: // TODO: Find a way to use `import.meta.main` once
26+
// https://github.com/nodejs/node/issues/49440 is done.
27+
process.argv[1]
28+
? createRequire(process.argv[1]).resolve(process.argv[1])
2429
: undefined;
2530
if (!entryPointDirectory) {
2631
throw new Error(

0 commit comments

Comments
 (0)