rollup-plugin-root-import icon indicating copy to clipboard operation
rollup-plugin-root-import copied to clipboard

Default settings do not resolve imports absolutely

Open skeggse opened this issue 8 years ago • 2 comments

When the entry is specified relative to the rollup configuration, subsequent imports will be resolved relative to the unresolved entry, rather than being resolved in absolute terms.

// :: rollup config
import {rollup} from 'rollup';
import rootImport from 'rollup-plugin-root-import';

rollup.rollup({
  entry: 'src/index.js',
  plugins: [rootImport()]
}).then((bundle) => {
  // ...
});

// :: src/index.js
// We'd like this to resolve to /full/path/to/src/utils/other.js, but it
// resolves to src/utils/other.js instead.
import {trivial} from '/utils/other.js';

export default trivial(1, 2);

// :: src/utils/other.js
export function trivial(a, b) {
  return a + b;
}

skeggse avatar Jul 28 '16 20:07 skeggse

Possibly related? https://github.com/kei-ito/rollup-plugin-glob-import/issues/1

arxpoetica avatar Sep 09 '17 21:09 arxpoetica

Any resolution for this issue? I'm being hit by this since subsequent rollup plugins have strict assumptions wrt. the paths of included files and doesn't process all the files that it needs to.

Edit: explicitly setting the root like in the README example seems to make it work for me, eg.

root: `${__dirname}/common/src`,

tellypath avatar Oct 31 '17 14:10 tellypath