汇总:未解决的依赖关系

Rollup: Unresolved Dependencies

我在使用带汇总的 npm 包(特别是 lodash)时遇到问题。

我收到未解决的依赖项错误。我已经安装了 rollup-plugin-node-resolverollup-plugin-commonjs 并根据文档进行了配置。我可能错过了一些明显的东西。

错误

[~/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()
  ]
};

我做错了什么?

lodash,不是loadash