postcss/postcss-import — pull request #15 by iamvdo (2014-12-23 15:14:04+00:00)
Title: Add a test for relative import without from option

This PR adds a test that fails. I found that it could be a `resolve` package issue, so that's why I do that. It's a start.

I found that the problem appears (at least) when a path starts with `../` because `resolve` doesn't use `paths` array in that case, it tries to resolve with `basedir` and fails.

Try replacing this test in `lib/sync.js` from `resolve` package (line 21-29):
```javascript
if (/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[\\\/])/.test(x)) {
var res = y;
for (var i = opts.paths.length - 1; i >= 0; i--) {
if (path.resolve(y, opts.paths[i])) {
res = path.resolve(y, opts.paths[i]);
break;
}
};
res = path.resolve(res, x);
if (x === '..') res += '/';
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
if (m) return m;
} else {
var n = loadNodeModulesSync(x, y);
if (n) return n;
}
```

Still don't know if it's a bug in resolve, or if it's a feature. Any thought ?

(ref #14)