Skip to content

Instantly share code, notes, and snippets.

@frehner
Last active March 16, 2023 20:20
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 frehner/bacbeb07b309b35d83d58f3cb5130da1 to your computer and use it in GitHub Desktop.
Save frehner/bacbeb07b309b35d83d58f3cb5130da1 to your computer and use it in GitHub Desktop.
Dot notation with treeshaking
// we change our library to have multiple entry points. Note that this has a large effect on our package.json, bundler settings, etc.
// in our library. file: "src/CartLine"
export {CartLine, CartLineQuantityAdjustButton} from 'index.js'
// in a dev's project
import * as CartLine from '@shopify/hydrogen/CartLine'
// the importer/dev writes a façade file that does it on their side of things: (both files in the dev’s project)
// file: "src/CartLine"
export {CartLine, CartLineQuantityAdjustButton} from '@shopify/hydrogen'
// file "src/routes/SomeRoute"
import * as CartLine from '~/CartLine'
// we just don't care about treeshaking at all :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment