summaryrefslogtreecommitdiff
path: root/.changeset
diff options
context:
space:
mode:
authorGravatar ottomated <31470743+ottomated@users.noreply.github.com> 2023-07-20 12:03:40 -0400
committerGravatar GitHub <noreply@github.com> 2023-07-20 12:03:40 -0400
commit3a6e42e190421c2e172d5c408c0a7592653fccef (patch)
tree39d51bef70dbb9231dc5a1f7ace1ad0e225bff8b /.changeset
parent7a26a52e190b476fc8091a10b5c803d7139a4162 (diff)
downloadastro-3a6e42e190421c2e172d5c408c0a7592653fccef.tar.gz
astro-3a6e42e190421c2e172d5c408c0a7592653fccef.tar.zst
astro-3a6e42e190421c2e172d5c408c0a7592653fccef.zip
Determine hoisted scripts via AST analysis (#7707)
* initial hacky * plural importNames and exportNames * extract into function * Add test * fix issue with another component importing our tracked component * fix dynamic imports * changeset * add mdx to checklist * mdx exports Content * remove unused var * Update packages/astro/test/hoisted-imports.test.js Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update packages/astro/src/core/build/plugins/plugin-analyzer.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update packages/astro/src/core/build/plugins/plugin-analyzer.ts Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> * Update real-drinks-melt.md * Update .changeset/real-drinks-melt.md Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> * Update .changeset/real-drinks-melt.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> * Update .changeset/real-drinks-melt.md * Update .changeset/real-drinks-melt.md Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Matthew Phillips <matthew@skypack.dev> Co-authored-by: Matthew Phillips <matthew@matthewphillips.info> Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com> Co-authored-by: Yan Thomas <61414485+Yan-Thomas@users.noreply.github.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to '.changeset')
-rw-r--r--.changeset/real-drinks-melt.md30
1 files changed, 30 insertions, 0 deletions
diff --git a/.changeset/real-drinks-melt.md b/.changeset/real-drinks-melt.md
new file mode 100644
index 000000000..648ef1d91
--- /dev/null
+++ b/.changeset/real-drinks-melt.md
@@ -0,0 +1,30 @@
+---
+'astro': minor
+---
+
+Improved hoisted script bundling
+
+Astro's static analysis to determine which `<script>` tags to bundle together just got a little smarter!
+
+Astro create bundles that optimize script usage between pages and place them in the head of the document so that they are downloaded as early as possible. One limitation to Astro's existing approach has been that you could not dynamically use hoisted scripts. Each page received the same, all-inclusive bundle whether or not every script was needed on that page.
+
+Now, Astro has improved the static analysis to take into account the actual imports used.
+
+For example, Astro would previously bundle the `<script>`s from both the `<Tab>` and `<Accordian>` component for the following library that re-exports multiple components:
+
+__@matthewp/my-astro-lib__
+
+```js
+export { default as Tabs } from './Tabs.astro';
+export { default as Accordion } from './Accordion.astro';
+```
+
+Now, when an Astro page only uses a single component, Astro will send only the necessary script to the page. A page that only imports the `<Accordian>` component will not receive any `<Tab>` component's scripts:
+
+```astro
+---
+import { Accordion } from '@matthewp/my-astro-lib';
+---
+```
+
+You should now see more efficient performance with Astro now supporting this common library re-export pattern.