mixmaxhq / rollup-plugin-root-import

Add the ability to import modules by the root path, like Meteor
MIT License
38 stars 2 forks source link

Default settings do not resolve imports absolutely #1

Open skeggse opened 8 years ago

skeggse commented 8 years ago

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;
}
arxpoetica commented 7 years ago

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

tellypath commented 6 years ago

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`,