Skip to content

Instantly share code, notes, and snippets.

@simlrh
Created January 26, 2017 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simlrh/9b17aa98f4a9f0a44208ac40d10ea5c1 to your computer and use it in GitHub Desktop.
Save simlrh/9b17aa98f4a9f0a44208ac40d10ea5c1 to your computer and use it in GitHub Desktop.
Tree shaking example
import { d, e, f } from "./def.js";
// a is used
export const a = d + " is part of a";
// b is unused
export const b = e + " is part of b";
// c is unused
export const c = f + " is part of c";
export const d = "d";
export const e = "e";
export const f = "f";
/*
* d, e and f will all be marked as "used" because they are imported into abc.js
* but e and f will never be used because the variables that rely on them are unused.
* Assuming I am able to detect this situation (it's a specific kind of module),
* is it possible to tell webpack that these exports are actually unused?
*/
import { a } from "./abc.js";
document.write(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment