简体   繁体   中英

Rollup: “Import of non-existent export” when importing function from Lodash

I have a small library that's bundled as a UMD module using Rollup. I am trying to import a function from Lodash into my library, but I am getting an error.

I try to import the function like this:

import { partition } from 'lodash';

And I get this error:

(!) Import of non-existent export
src/main.js
1: import { partition } from 'lodash';

This is my rollup configuration:

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

export default {
  input: 'src/main.js',
  output: {
    file: 'dist/browser-metrics.js',
    name: 'BrowserMetrics',
    format: 'umd'
  },
  plugins: [
    resolve(),
    babel({
      exclude: 'node_modules/**'
    })
  ]
};

Any idea what I'm doing wrong?

install and use lodash-es module with es6 import/export functionality

npm install lodash-es

then

import { partition } from 'lodash-es';

or

import partition from 'lodash-es/partition';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM