From edb9054d5924004acbd65453bca1783fa770eccf Mon Sep 17 00:00:00 2001 From: William Hilton Date: Wed, 12 Jul 2017 16:38:28 -0400 Subject: [PATCH 1/2] Use "module" in addition to "jsnext:main" This change (probably) fixes my cryptic error ``` Error: 'default' is not exported by node_modules\rollup-plugin-alias\dist\rollup-plugin-alias.js ``` which I assume means it is loading `rollup-plugin-alias\dist\rollup-plugin-alias.js` instead of `rollup-plugin-alias\dist\rollup-plugin-alias.es2015js`, which I assume is because `rollup-plugin-node-resolve` uses the default options `module: true, main: true, jsnext: false`. I think this PR is very minimal and will not have any adverse effects or break compatibility, but you never know. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 388034d..9c673c9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.3.1", "description": "Resolves aliases with Rollup", "main": "dist/rollup-plugin-alias.js", + "module": "dist/rollup-plugin-alias.es2015.js", "jsnext:main": "dist/rollup-plugin-alias.es2015.js", "scripts": { "prebuild": "rimraf dist", From d892094ca59b0700458b3639b04c33b497e1754c Mon Sep 17 00:00:00 2001 From: Anike Arni Date: Thu, 27 Jul 2017 17:30:44 -0300 Subject: [PATCH 2/2] Fix aliasing that matches entry file --- src/index.js | 2 +- test/index.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index d789813..702dfdd 100644 --- a/src/index.js +++ b/src/index.js @@ -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; } diff --git a/test/index.js b/test/index.js index 01cecb9..e0c947e 100644 --- a/test/index.js +++ b/test/index.js @@ -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',