We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
resolveModuleSpecifier
1 parent 39aed29 commit 12b183dCopy full SHA for 12b183d
src/utils.ts
@@ -2,6 +2,8 @@ import path from 'path'
2
import url from 'url'
3
import vm from 'vm'
4
5
+const VALID_PATH_REGEXP = /^[./\\]/
6
+
7
export const isInESModuleScope = (): boolean => {
8
try {
9
return module === undefined
@@ -38,7 +40,5 @@ export const getCallerDirname = (): string => {
38
40
39
41
export const resolveModuleSpecifier = (specifier: string, dirname: string): string => {
42
const specifierPath = fileURLToPath(specifier)
- return new RegExp(`^[.\\${path.sep}]`).test(specifierPath)
- ? path.resolve(dirname, specifierPath)
43
- : specifier
+ return VALID_PATH_REGEXP.test(specifierPath) ? path.resolve(dirname, specifierPath) : specifier
44
}
0 commit comments