簡體   English   中英

webpack 4和d3 es6導入不起作用

[英]webpack 4 and d3 es6 imports not working

我正在嘗試使用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);

我不確定這是否是相關症狀,但是當我嘗試import selection as d3sel from 'd3-selection'; 我從webpack收到一個錯誤消息,關於無法執行該語句。

我的package.json文件如下所示:

"devDependencies": {
  "d3-selection": "^1.3.0",
  "webpack": "^4.10.2",
  "webpack-cli": "^3.0.2"
}

也許選擇不是默認導出?

嘗試

import { selection } from 'd3-selection';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM