BugHunterUK
BugHunterUK

Reputation: 8948

Rollup: Unresolved Dependencies

I'm having issues using npm packages with rollup (specifically lodash).

I'm getting an unresolved dependencies error. I have installed both rollup-plugin-node-resolve and rollup-plugin-commonjs and configured according to the docs. It's possible I could have missed something obvious.

Error

[~/Projects/rollup] yarn run build
yarn run v1.2.1
$ rollup -c

src/main.js → ./build/app.js...
(!) Unresolved dependencies
https://github.com/rollup/rollup/wiki/Troubleshooting#treating-module-as-external-dependency
loadash (imported by src/main.js)
(!) Missing global variable name
Use options.globals to specify browser global variable names corresponding to external modules
loadash (guessing 'loadash')
created ./build/app.js in 47ms
✨ Done in 0.93s.

src/main.js

import { map } from 'loadash';
console.log('Test');

rollup.config.js

import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';

export default {
  input: 'src/main.js',
  output: {
    file: './build/app.js',
    format: 'iife'
  },
  plugins: [
    resolve({
      jsnext: true,
      main: true,
      browser: true,
    }),
    commonjs()
  ]
};

What am I doing wrong?

Upvotes: 4

Views: 5748

Answers (1)

Rich Harris
Rich Harris

Reputation: 29605

It's called lodash, not loadash!

Upvotes: 7

Related Questions