Skip to content

Instantly share code, notes, and snippets.

@pushkar100
Last active October 18, 2020 09:22
Show Gist options
  • Save pushkar100/fd95bd3547a34ecf1ceba63a387b44a4 to your computer and use it in GitHub Desktop.
Save pushkar100/fd95bd3547a34ecf1ceba63a387b44a4 to your computer and use it in GitHub Desktop.
Chunk exports without partial split
// (A) What happens when you try to load dynamic chunks:
/* ./utilities.js */
export const add = (a, b) => a + b
export const subtract = (a, b) => a - b
export const multiply = (a, b) => a * b
export const divide = (a, b) => a / b
const power = (a, b) => Math.pow(a, b)
export default power
/* ./main.js */
import('./utilities.js')
.then(module => {
console.log(module.add)
// We require ONLY module.add
// BUT...
// The module contains every export!
// i.e It also contains module.subtract, module.multiply,
// module.divide, & module.default
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment