Skip to content

Commit

Permalink
Invalidate based on modulePath (#2086)
Browse files Browse the repository at this point in the history
* Invalidate based on modulePath

* Adds a changeset
  • Loading branch information
matthewp committed Dec 2, 2021
1 parent 0b2650d commit 2a2eaad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-parents-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes invalidation of proxy module (inline script modules)
11 changes: 4 additions & 7 deletions packages/astro/vendor/vite/dist/node/chunks/dep-35df7f96.js
Original file line number Diff line number Diff line change
Expand Up @@ -56984,7 +56984,10 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
addToHTMLProxyCache(config, url, scriptModuleIndex, contents);
const modulePath = `${config.base + htmlPath.slice(1)}?html-proxy&index=${scriptModuleIndex}.js`;
// invalidate the module so the newly cached contents will be served
server === null || server === void 0 ? void 0 : server.moduleGraph.invalidateId(config.root + modulePath);
const module = server === null || server === void 0 ? void 0 : server.moduleGraph.getModuleById(modulePath);
if (module) {
server === null || server === void 0 ? void 0 : server.moduleGraph.invalidateModule(module);
}
s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${modulePath}"></script>`);
}
}
Expand Down Expand Up @@ -57115,12 +57118,6 @@ class ModuleGraph {
mod.ssrTransformResult = null;
invalidateSSRModule(mod, seen);
}
invalidateId(id) {
const mod = this.idToModuleMap.get(id);
if (mod) {
this.invalidateModule(mod);
}
}
invalidateAll() {
const seen = new Set();
this.idToModuleMap.forEach((mod) => {
Expand Down

0 comments on commit 2a2eaad

Please sign in to comment.