Skip to content

Commit f3ff661

Browse files
author
lili.21
committed
fix: handle virtual module
fix gajus#307
1 parent eb008aa commit f3ff661

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@ export default ({
119119

120120
const getTargetResourcePath = (path: *, stats: *) => {
121121
const targetFileDirectoryPath = dirname(stats.file.opts.filename);
122+
try {
123+
if (path.node.source.value.startsWith('.')) {
124+
return resolve(targetFileDirectoryPath, path.node.source.value);
125+
}
122126

123-
if (path.node.source.value.startsWith('.')) {
127+
return require.resolve(path.node.source.value);
128+
} catch (_) {
129+
// virtual module
124130
return resolve(targetFileDirectoryPath, path.node.source.value);
125131
}
126-
127-
return require.resolve(path.node.source.value);
132+
128133
};
129134

130135
const isFilenameExcluded = (filename, exclude) => {

0 commit comments

Comments
 (0)