Last active
October 18, 2020 08:45
-
-
Save pushkar100/22461524f3c41d6935d7bd99b27821e5 to your computer and use it in GitHub Desktop.
Chunk exports with partial split
This file contains 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
// (B) What you need to manually do to import only A from the dynamic chunk: | |
/* ./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 | |
/* NEW MODULE NEEDS TO BE CREATED: ./utilities-add.js */ | |
export { add } from './utilities' | |
/* ./main.js */ | |
import('./utilities-add.js') | |
.then(module => { | |
console.log(module.add) | |
// Only module.add is available and not the other exports! | |
// The chunk that is created too will be smaller | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment