Ecmascript 6 ES6:如何将多个导入作为别名(导入{1,2}作为父级)

Ecmascript 6 ES6:如何将多个导入作为别名(导入{1,2}作为父级),ecmascript-6,turfjs,Ecmascript 6,Turfjs,我正在使用turf库,并导入如下内容: import*作为草皮从“@trub/trub”导入; const myCoords=turp.getCoords(…); const myNearestPoint=草皮最近点(…); 但是我只使用了很少的函数,并且希望减少捆绑包的大小,而不丢失地盘别名 所以我试过这个,但不起作用: 将{getCoords,nearesPoint}作为草皮从“@trub/trub”//不起作用 const myCoords=turp.getCoords(…); cons

我正在使用turf库,并导入如下内容:

import*作为草皮从“@trub/trub”导入;
const myCoords=turp.getCoords(…);
const myNearestPoint=草皮最近点(…);
但是我只使用了很少的函数,并且希望减少捆绑包的大小,而不丢失
地盘
别名

所以我试过这个,但不起作用:

将{getCoords,nearesPoint}作为草皮从“@trub/trub”//不起作用
const myCoords=turp.getCoords(…);
const myNearestPoint=草皮最近点(…);
有没有在一个别名中进行多个导入的想法


谢谢

导入它们后,可以将它们重新组合到对象中

import { getCoords, nearesPoint } from "@turf/turf";
const turf = { getCoords, nearesPoint };

如果要使用树抖动,则必须将
getCoords
用作函数。您可以在导入行之后说
constturp={getCoords,nearestPoint}
将它们合并回一个对象,但我认为这是一种不好的做法,只会增加不必要的复杂性。您可以使用以下选项:
import{getCoords as turp\u getCoords,nearesPoint as turp\u nearesPoint}从“@turp/turp”
然后像
const myCoords=turp_getCoords(…)一样使用它