prismicio / prismic-next

Helpers to integrate Prismic into Next.js apps
https://prismic.io/docs/technologies/nextjs
Apache License 2.0
57 stars 7 forks source link

fix: support tree-shaking #36

Closed angeloashmore closed 2 years ago

angeloashmore commented 2 years ago

Types of changes

Description

This PR adds support for tree-shaking. Only used chunks (i.e. components, functions) from @prismicio/next are included in a Next.js app's JavaScript bundle.

Without this PR, @prismicio/next's full bundle and its dependencies would be included in a Next.js app's JavaScript bundle.

To accomplish this, Rollup's preserveModules option was enabled. This effectively disables bundling (at least in this package's case), preserving the source files (i.e. chunks). This allows Next.js's bundler to properly remove whole unused chunks from its output.

As part of this change, siroc was replaced by unbuild as a build tool. unbuild results in better build output.

Fixes #35

Checklist:

🦤

codecov-commenter commented 2 years ago

Codecov Report

Merging #36 (b3f73dc) into main (38d1b24) will not change coverage. The diff coverage is n/a.

:exclamation: Current head b3f73dc differs from pull request most recent head 783cb35. Consider uploading reports for the commit 783cb35 to get more accurate results

@@            Coverage Diff            @@
##              main       #36   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          665       665           
  Branches        33        33           
=========================================
  Hits           665       665           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.