Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure hoisted scripts are deduplicated in build #3433

Merged
merged 2 commits into from
May 24, 2022

Conversation

natemoo-re
Copy link
Member

Changes

  • Currently, astro build generates an entry for every page with hoisted scripts. This effectively creates duplicate entry modules that all reference the same chunk.
  • This PR changes the hoisted script logic to use unique sets of hoisted scripts as entry points, rather than the pages.
    • If all pages reference the same set of hoisted scripts, the output is collapsed into a single entry point.
    • If pages reference different sets of hoisted scripts, the output will be intelligently chunked rather than emitted by page
Before After
Screen Shot 2022-05-24 at 11 13 57 AMScreen Shot 2022-05-24 at 11 14 16 AM Screen Shot 2022-05-24 at 11 12 59 AM Screen Shot 2022-05-24 at 11 13 13 AM

Testing

Not sure how to test this, any ideas?

Docs

N/A, internal change only

@changeset-bot
Copy link

changeset-bot bot commented May 24, 2022

🦋 Changeset detected

Latest commit: ee2a1bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label May 24, 2022
@natemoo-re natemoo-re force-pushed the fix/build-duplicate-hash branch from 59f9fdd to e71dbd9 Compare May 24, 2022 16:23
@natemoo-re natemoo-re self-assigned this May 24, 2022
@natemoo-re natemoo-re merged commit 4ca60e9 into main May 24, 2022
@natemoo-re natemoo-re deleted the fix/build-duplicate-hash branch May 24, 2022 19:39
@github-actions github-actions bot mentioned this pull request May 24, 2022
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
* fix(build): ensure hoisted scripts are deduplicated in build

* chore: add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants