Skip to content
Advertisement

Tag: es6-modules

Does ES6 import/export need “.js” extension?

I installed chrome beta – Version 60.0.3112.24 (Official Build) beta (64-bit) In chrome://flags/ I enabled ‘Experimental Web Platform features’ (see https://jakearchibald.com/2017/es-modules-in-browsers) I then tried: where index.js has a line like: This refer to an existing file drawImage.js what I get in the console is error in If I change the export and add “.js” extension it works fine. Is this

Destructuring a default export object

Can I destructure a default export object on import? Given the following export syntax (export default) is the following import syntax valid JS? I ask because it DOES work on my system, but I’ve been told it should NOT work according to the spec. Answer Can I destructure a default export object on import? No. You can only destructure an

Re-export default in ES 6 modules

In ES6, is it possible to shorten the following code. I have an App.js file and an index.js. index.js Something like this index.js Answer If you use proposal-export-default-from Babel plugin (which is a part of stage-1 preset), you’ll be able to re-export default using the following code: For more information see the ECMAScript proposal. Another way (without this plugin) is:

Advertisement