[ci] format
This commit is contained in:
parent
37a7a8347c
commit
becdf3e923
3 changed files with 8 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
if (import.meta.hot) {
|
if (import.meta.hot) {
|
||||||
import.meta.hot.accept(mod => mod);
|
import.meta.hot.accept((mod) => mod);
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
async function updatePage() {
|
async function updatePage() {
|
||||||
const { default: diff } = await import('micromorph');
|
const { default: diff } = await import('micromorph');
|
||||||
|
@ -31,7 +31,7 @@ if (import.meta.hot) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasAstroUpdate) {
|
if (hasAstroUpdate) {
|
||||||
return updatePage()
|
return updatePage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
import.meta.hot.on('vite:beforeUpdate', async (event) => {
|
import.meta.hot.on('vite:beforeUpdate', async (event) => {
|
||||||
|
|
|
@ -84,8 +84,8 @@ export async function handleHotUpdate(ctx: HmrContext, config: AstroConfig, logg
|
||||||
|
|
||||||
// Bugfix: sometimes style URLs get normalized and end with `lang.css=`
|
// Bugfix: sometimes style URLs get normalized and end with `lang.css=`
|
||||||
// These will cause full reloads, so filter them out here
|
// These will cause full reloads, so filter them out here
|
||||||
const mods = ctx.modules.filter(m => !m.url.endsWith('='));
|
const mods = ctx.modules.filter((m) => !m.url.endsWith('='));
|
||||||
const isSelfAccepting = mods.every(m => m.isSelfAccepting || m.url.endsWith('.svelte'));
|
const isSelfAccepting = mods.every((m) => m.isSelfAccepting || m.url.endsWith('.svelte'));
|
||||||
|
|
||||||
const file = ctx.file.replace(config.root.pathname, '/');
|
const file = ctx.file.replace(config.root.pathname, '/');
|
||||||
if (isSelfAccepting) {
|
if (isSelfAccepting) {
|
||||||
|
@ -94,5 +94,5 @@ export async function handleHotUpdate(ctx: HmrContext, config: AstroConfig, logg
|
||||||
info(logging, 'astro', msg.reload({ file }));
|
info(logging, 'astro', msg.reload({ file }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mods
|
return mods;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,11 +175,11 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
|
||||||
// Add HMR handling in dev mode.
|
// Add HMR handling in dev mode.
|
||||||
if (!resolvedConfig.isProduction) {
|
if (!resolvedConfig.isProduction) {
|
||||||
// HACK: extract dependencies from metadata until compiler static extraction handles them
|
// HACK: extract dependencies from metadata until compiler static extraction handles them
|
||||||
const metadata = transformResult.code.split('$$createMetadata(')[1].split('});\n')[0]
|
const metadata = transformResult.code.split('$$createMetadata(')[1].split('});\n')[0];
|
||||||
const pattern = /specifier:\s*'([^']*)'/g;
|
const pattern = /specifier:\s*'([^']*)'/g;
|
||||||
const deps = new Set();
|
const deps = new Set();
|
||||||
let match;
|
let match;
|
||||||
while (match = pattern.exec(metadata)?.[1]) {
|
while ((match = pattern.exec(metadata)?.[1])) {
|
||||||
deps.add(match);
|
deps.add(match);
|
||||||
}
|
}
|
||||||
// // import.meta.hot.accept(["${id}", "${Array.from(deps).join('","')}"], (...mods) => mods);
|
// // import.meta.hot.accept(["${id}", "${Array.from(deps).join('","')}"], (...mods) => mods);
|
||||||
|
@ -255,7 +255,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleHotUpdate(context) {
|
async handleHotUpdate(context) {
|
||||||
|
|
Loading…
Reference in a new issue