我正在尝试使用 webpack4 来捆绑基于 d3 的客户端应用程序。然而,当代码被捆绑时,它会产生以下错误:
/* Cannot get final name for export "default" in "./node_modules/d3-selection/index.js"
(known exports: , known reexports: create creator local matcher mouse namespace namespaces
clientPoint select selectAll selection selector selectorAll style touch touches
window event customEvent) */
undefined.select('body')
.append('canvas')
.attr('id', 'mycanvas')
.attr('width', 640)
.attr('height', 480);
在我的来源中我有
import selection from 'd3-selection';
selection.select('body')
.append('canvas')
.attr('id', 'mycanvas')
.attr('width', 640)
.attr('height', 480);
我不确定这是否是相关症状,但是当我尝试从'd3-selection'导入选择为d3sel;
时,我从webpack收到一个关于无法pase的错误声明。
我的 package.json 文件如下所示:
"devDependencies": {
"d3-selection": "^1.3.0",
"webpack": "^4.10.2",
"webpack-cli": "^3.0.2"
}
最佳答案
也许选择不是默认导出?
尝试
import { selection } from 'd3-selection';
关于javascript - webpack 4 和 d3 es6 导入不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50689249/