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

[WIP] Update Vendored vite #2466

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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