Webpack:无法解构 'undefined' 或 'null' 的 属性 `curry`

Webpack: Cannot destructure property `curry` of 'undefined' or 'null'

在为浏览器使用 webpack 和 babel-loader 编译我的应用程序后,在 main 函数启动之前立即出现以下错误:

Uncaught TypeError: Cannot destructure property `curry` of 'undefined' or 'null'.
    at Object../node_modules/@qzdio/f/lib/combinators/sync.js (index-c1596672f4.js:formatted:268)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../node_modules/@qzdio/f/lib/combinators/index.js (index-c1596672f4.js:formatted:251)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../node_modules/@qzdio/f/lib/index.js (index-c1596672f4.js:formatted:723)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../dist/graph/visualizer/src/index.js (index-c1596672f4.js:formatted:9)
    at n (runtime-74c3f0da77.js:formatted:10)
    at window.webpackJsonp (runtime-74c3f0da77.js:formatted:26)
    at index-c1596672f4.js:formatted:1

错误代码是以下内容的 ES5 转译:

import R from 'ramda';
const { curry } = R;

// I :: a -> a
const I = (x) => x;
...

上述代码来自依赖 ramda and bluebird 的私有函数库。该库在 Node.js 8.9.1.

下使用和工作

所使用的 webpack config 直接来自 philipwalton 的 webpack-esnext-boilerplate(非常适合作为 :D 的起点)

版本:

错误的来源是什么,如何解决?

干杯✨

您必须使用 import { curry } from 'ramda'。您可以看到 here rambda 如何导出它的模块。它不导出 ramda 模块本身,而是导出各个函数。

如果你想访问额外的方法,你可以使用这个,例如:

import { curry, addIndex, clone } from 'ramda'

如果你真的想要一个对象中的所有导出值,你可以执行以下操作

import * as R from 'ramda';
const { curry } = R;