I try to export a d3.map
dictionary using webpack:
import {map, select} from 'd3';
const positionSelect = position => {
select(position).node().getBoundingClientRect();
};
const dictionary = map();
dictionary.set('Pitcher', positionSelect('#pitcher'))
.set('Catcher', positionSelect('#catcher'))
.set('First Base', positionSelect('#firstbase'))
.set('Second Base', positionSelect('#secondbase'))
.set('Shortstop', positionSelect('#shortstop'))
.set('Third Base', positionSelect('#thirdbase'))
.set('Left Field', positionSelect('#leftfield'))
.set('Center Field', positionSelect('#centerfield'))
.set('Right Field', positionSelect('#rightfield'));
export dictionary;
I get this error:
Module build failed: SyntaxError: Unexpected token, expected { (19:7)
17 | .set('Right Field', positionSelect('#rightfield'));
18 |
19 | export dictionary;
| ^
20 |
Is there a syntax problem?
答案 0 :(得分:1)
export
声明的syntax不正确;你可以从字面上阅读错误信息。如果要导出先前使用命名导出声明的常量,则必须将其括在大括号中:
export { dictionary };
但是,您可以在声明常量时执行导出。在这种情况下,不得使用大括号:
export const dictionary = map();