Skip to content

Commit

Permalink
Update vite
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Jan 25, 2022
1 parent ee28c43 commit 37ab8ba
Show file tree
Hide file tree
Showing 25 changed files with 7,272 additions and 16,646 deletions.
30 changes: 11 additions & 19 deletions packages/astro/vendor/vite/dist/client/client.mjs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,15 @@ function warnFailedFetch(err, path) {
`This could be due to syntax errors or importing non-existent ` +
`modules. (see errors above)`);
}
function cleanUrl(pathname) {
const url = new URL(pathname, location.toString());
url.searchParams.delete('direct');
return url.pathname + url.search;
}
// Listen for messages
socket.addEventListener('message', async ({ data }) => {
handleMessage(JSON.parse(data));
});

/**
* This cleans up the query params and removes the `direct` param which is internal.
* Other query params are preserved.
*/
function cleanUrl(pathname) {
let url = new URL(pathname, location);
url.searchParams.delete('direct');
return url.pathname + url.search;
}
let isFirstUpdate = true;
async function handleMessage(payload) {
switch (payload.type) {
Expand Down Expand Up @@ -239,19 +234,18 @@ async function handleMessage(payload) {
else {
// css-update
// this is only sent when a css file referenced with <link> is updated
let { path, timestamp } = update;
let searchUrl = cleanUrl(path);
const { path, timestamp } = update;
const searchUrl = cleanUrl(path);
// can't use querySelector with `[href*=]` here since the link may be
// using relative paths so we need to use link.href to grab the full
// URL for the include check.
const el = [].slice.call(document.querySelectorAll(`link`)).find((e) => {
return cleanUrl(e.href).includes(searchUrl)
});
const el = Array.from(document.querySelectorAll('link')).find((e) => cleanUrl(e.href).includes(searchUrl));
if (el) {
const newPath = `${base}${path.slice(1)}${path.includes('?') ? '&' : '?'}t=${timestamp}`;
const newPath = `${base}${searchUrl.slice(1)}${searchUrl.includes('?') ? '&' : '?'}t=${timestamp}`;
el.href = new URL(newPath, el.href).href;
}
console.log(`[vite] css hot updated: ${path}`);
console.log(`[vite] css hot updated: ${searchUrl}`);
notifyListeners('vite:afterUpdate:css', el);
}
});
break;
Expand Down Expand Up @@ -389,8 +383,6 @@ function removeStyle(id) {
const style = sheetsMap.get(id);
if (style) {
if (style instanceof CSSStyleSheet) {
// @ts-ignore
document.adoptedStyleSheets.indexOf(style);
// @ts-ignore
document.adoptedStyleSheets = document.adoptedStyleSheets.filter((s) => s !== style);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/vendor/vite/dist/client/client.mjs.map
100755 → 100644

Large diffs are not rendered by default.

Empty file modified packages/astro/vendor/vite/dist/client/env.mjs
100755 → 100644
Empty file.
Empty file modified packages/astro/vendor/vite/dist/client/env.mjs.map
100755 → 100644
Empty file.
64 changes: 20 additions & 44 deletions ...dor/vite/dist/node/chunks/dep-dab866a6.js → ...dor/vite/dist/node/chunks/dep-0fc9d1dd.js
100755 → 100644

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

This file was deleted.

39 changes: 14 additions & 25 deletions ...dor/vite/dist/node/chunks/dep-a5b4350d.js → ...dor/vite/dist/node/chunks/dep-59e05bf6.js
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

This file was deleted.

Empty file modified packages/astro/vendor/vite/dist/node/chunks/dep-ac1b4bf9.js
100755 → 100644
Empty file.
Empty file modified packages/astro/vendor/vite/dist/node/chunks/dep-ac1b4bf9.js.map
100755 → 100644
Empty file.
Loading

0 comments on commit 37ab8ba

Please sign in to comment.