简体   繁体   中英

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?

You can import d3 like this:

import * as d3 from 'd3';

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM