chore: update to vite's hook filter (#3333)
Fixes https://github.com/denoland/fresh/issues/3331
This commit is contained in:
@@ -19,25 +19,32 @@ export function clientEntryPlugin(options: ResolvedFreshViteConfig): Plugin {
|
||||
configResolved(config) {
|
||||
clientEntry = pathWithRoot(options.clientEntry, config.root);
|
||||
},
|
||||
resolveId(id) {
|
||||
if (id === modName) {
|
||||
return `\0${modName}`;
|
||||
} else if (id === modNameUser) {
|
||||
return clientEntry;
|
||||
}
|
||||
resolveId: {
|
||||
filter: {
|
||||
id: /(fresh:client-entry|fresh:client-entry-user)/,
|
||||
},
|
||||
handler(id) {
|
||||
if (id === modName) {
|
||||
return `\0${modName}`;
|
||||
} else if (id === modNameUser) {
|
||||
return clientEntry;
|
||||
}
|
||||
},
|
||||
},
|
||||
async load(id) {
|
||||
if (id !== `\0${modName}`) return;
|
||||
load: {
|
||||
filter: {
|
||||
id: /\0fresh:client-entry/,
|
||||
},
|
||||
async handler() {
|
||||
let exists = false;
|
||||
try {
|
||||
const stat = await Deno.stat(clientEntry);
|
||||
exists = stat.isFile;
|
||||
} catch {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
let exists = false;
|
||||
try {
|
||||
const stat = await Deno.stat(clientEntry);
|
||||
exists = stat.isFile;
|
||||
} catch {
|
||||
exists = false;
|
||||
}
|
||||
|
||||
return `
|
||||
return `
|
||||
${isDev ? 'import "preact/debug"' : ""}
|
||||
export * from "fresh/runtime-client";
|
||||
${exists ? `import "fresh:client-entry-user";` : ""}
|
||||
@@ -52,6 +59,7 @@ if (import.meta.hot) {
|
||||
});
|
||||
}
|
||||
`;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user