Skip to content

Instantly share code, notes, and snippets.

@tiger8888
Forked from brianneisler/cheat-sheet.js
Created February 20, 2019 02:14
Show Gist options
  • Save tiger8888/0354cd6da955ddec8806e0d020cc07e0 to your computer and use it in GitHub Desktop.
Save tiger8888/0354cd6da955ddec8806e0d020cc07e0 to your computer and use it in GitHub Desktop.
Cheat sheet - es6 import/export mixed with require/modules.exports
require('./module.js') // { a: 1 }
import module from './module.js' // undefined
import { a } from './module.js' // 1
require('./module2.js') // { default: { a: 1 }, b: 2 }
import module2 from './module2.js' // { a: 1}
import { b } from './module2.js' // 2
require('./module3.js') // { default: { a: 1 }, b: 2 }
import module3 from './module2.js' // { a: 1}
import { b } from './module2.js' // 2
// module.js
module.exports = {
a: 1
}
// module2.js
module.exports = {
'default': {
a: 1
},
b: 2
}
// module3.js
export default { a: 1 }
const b = 2
export b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment