Shopify CLI: Generate metafile for bundle size analyzer

Currently, when an extension exceeds the size limit, Shopify CLI fails early without providing much feedback on what’s contributing to the bundle size.

Since extensions are built with esbuild under the hood, it would be great to have the metafile option enabled. This would allow us to analyze the extension’s bundle size using the esbuild Bundle Size Analyzer (esbuild - Bundle Size Analyzer), making it much easier to identify and address what’s driving the size up.

Thank you for considering this!

Shopify CLI uses esbuild for this, we just invoke it ourselves to generate and analyze the meta.json.

npx esbuild src/Modal.tsx --bundle --minify \
  --metafile=meta.json \
  --outfile=bundle.js \
  --format=esm \
  --platform=browser \
  --tree-shaking=true \
  --target=es2015

npx esbuild-visualizer --metadata meta.json --open