Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Fix aliasing that matches entry file #29

Merged
merged 2 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default function alias(options = {}) {
// First match is supposed to be the correct one
const toReplace = aliasKeys.find(key => matches(key, importeeId));

if (!toReplace) {
if (!toReplace || !importerId) {
return null;
}

Expand Down
10 changes: 10 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ test('Absolute local aliasing', t => {
t.is(resolved4, '/par/a/di/se.js');
});

test('Leaves entry file untouched if matches alias', t => {
const result = alias({
abacaxi: './abacaxi',
});

const resolved = result.resolveId('abacaxi/entry.js', undefined);

t.is(resolved, null);
});

test('Test for the resolve property', t => {
const result = alias({
ember: './folder/hipster',
Expand Down