๐Ÿ“˜default export

JS โŸฉ module โŸฉ ES โŸฉ export โŸฉ export default

export default is used if only one variable is being exported from a file, also used to create a fallback value for a file or module.

unlike CommonJS, default export in ES module cannot be destructuredโ—๏ธ ๐Ÿ‘‰ example๏ผšes module

// "default export" cannot be destructured
import { name } from './default_export.js';    // โ›” error
//       ^^^^
// โ›” SyntaxError: 
//    The requested module './default_export.js' 
//    does not provide an export named 'name'

Last updated