Bruno Ochotorena
Bruno Ochotorena

Reputation: 51

How to import with ECMAScript (vanilla javascript) with modules es6

I read this post and i want use D3.js (v4+) using only import statement like this:

import { selection } from '../node modules/d3/build/d3.js';

But, because code output is UMD (or read this) and can't import because some globals is no defined, and ES6 can't resolve absolutive names in node_modules for example and vanilla don't suport import statement without extension like this:

import * as someFeature from './myAwesomeModule';

And this is pattern to import modules and each day is growing up like you see here.

How i can use import statement without any plugin today?

Upvotes: 5

Views: 1867

Answers (1)

Emma Lewis
Emma Lewis

Reputation: 402

You can import d3 like this:

import * as d3 from 'd3';

See more here: https://github.com/d3/d3/blob/master/README.md#installing

Upvotes: 1

Related Questions