Skip to content

Commit 7ad5057

Browse files
authored
fix(node-resolve): error thrown with empty entry (#1893)
* Fix error thrown with empty entry while using node-resolve plugin * Clean up test syntax * Formatting
1 parent e2e33ce commit 7ad5057

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/node-resolve/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export function nodeResolve(opts = {}) {
152152

153153
const importSpecifierList = [importee];
154154

155-
if (importer === undefined && !importee[0].match(/^\.?\.?\//)) {
155+
if (importer === undefined && importee[0] && !importee[0].match(/^\.?\.?\//)) {
156156
// For module graph roots (i.e. when importer is undefined), we
157157
// need to handle 'path fragments` like `foo/bar` that are commonly
158158
// found in rollup config files. If importee doesn't look like a

packages/node-resolve/test/test.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,15 @@ test('allow other plugins to take over resolution', async (t) => {
743743
]
744744
});
745745
});
746+
747+
test('error message for invalid entry', async (t) => {
748+
const error = await t.throwsAsync(() =>
749+
rollup({
750+
input: '',
751+
onwarn: failOnWarn(t),
752+
plugins: [nodeResolve()]
753+
})
754+
);
755+
756+
t.is(error.message, `Could not resolve entry module "".`);
757+
});

0 commit comments

Comments
 (0)