d3-geo-projection & ES6 imports

47 views
Skip to first unread message

Dan DeLorenzo

unread,
Sep 13, 2017, 2:54:47 PM9/13/17
to d3-js
I've started using ES6 imports in my projects and Id like to import d3-geo-projection in such a way that I can call the extra projections as I always have, as in:

var proj = d3.geoAitoff();


And I'd like to avoid rolling my own bundle.

I have tried 

import * as d3 from 'd3';
import 'd3-geo-projection';

and I tried

import * as d3 from 'd3';
import {geoAitoff} from 'd3-geo-projection';

neither results in being able to call var proj = d3.geoAitoff();


Can anyone advise on how this should be done?

sandeep edara

unread,
Sep 14, 2017, 3:55:44 PM9/14/17
to d3-js
Hi Dan,

Since you dont have a bundler, try this :

var proj = require('d3-geo-projection');
var {geoAitoff} = proj;

Regards,
Sandeep.

sandeep edara

unread,
Sep 14, 2017, 4:09:37 PM9/14/17
to d3-js
Hi Dan,

The reason this isnt working seems to be the "modules" implementation in node.js
as of v6.2.2 the status seems to be "in progress".


For brevity you may even do this 

var {geoAitoff} = require('d3-geo-projection');


Regards,

Sandeep.

Reply all
Reply to author
Forward
0 new messages