Skip to content

Instantly share code, notes, and snippets.

@pushkar100
Last active October 18, 2020 08:51
Show Gist options
  • Select an option

  • Save pushkar100/d81b72a3f8978ba4bd3258d5d9d65b36 to your computer and use it in GitHub Desktop.

Select an option

Save pushkar100/d81b72a3f8978ba4bd3258d5d9d65b36 to your computer and use it in GitHub Desktop.
Tree shaking example
/* ./simple-arithmetic.js */
export const add = (a, b) => a + b
export const subtract = (a, b) => a - b
/* ./complex-arithmetic.js */
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
/* ENTRY FILE: ./main.js */
import { add } from './simple-arithmetic'
import power from './complex-arithmetic'
add(1, 2)
power(2, 4)
/* SIMPLIFIED OUTPUT: Final bundle should ideally contain: */
const add = (a, b) => a + b
const power = (a, b) => Math.pow(a, b)
add(1, 2)
power(2, 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment