Last active
October 18, 2020 08:51
-
-
Save pushkar100/d81b72a3f8978ba4bd3258d5d9d65b36 to your computer and use it in GitHub Desktop.
Tree shaking example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* ./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