-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add runtime/sveltekit-support #48
Conversation
It looks like this is your first pull request. 🎉 Thank you for your contribution! One of the project maintainers will triage and assign the pull request for review. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct. |
Thank you for following the naming conventions! 🙏 |
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected] |
idk how to fix my pr for your preference(like name, pr name or so, it is hard for contributors to follow these rules... I think) |
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
This reverts commit 4fda52e.
|
||
export const handle: Handle = async ({ event, resolve }) => { | ||
const response = await resolve(event, { | ||
transformPageChunk: ({ html }) => html.replace("</head>", `${head}</head>`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const statements = findStaticImports(code).filter((index) => index.specifier === runtimePackageName); | ||
if (statements.length === 0) { | ||
return undefined; | ||
} | ||
|
||
statements.forEach((index) => { | ||
const im = parseStaticImport(index); | ||
const html = parsedHtml.map((tag) => tag.fragment).join(""); | ||
const generatedCode = `const ${im.defaultImport ?? im.imports} = ${genString(html)};`; | ||
s.overwrite(im.start, im.end, generatedCode); | ||
}); | ||
|
||
if (!s.hasChanged()) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
code: s.toString(), | ||
map: s.generateMap({ | ||
includeContent: true, | ||
source: id, | ||
}), | ||
}; | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on this code: https://github.com/unjs/magic-regexp/blob/main/src/transform.ts
@prisis please modify as you want |
@@ -1,5 +1,5 @@ | |||
import adapter from "@sveltejs/adapter-auto"; | |||
import { vitePreprocess } from "@sveltejs/kit/vite"; | |||
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the favicon doesn't show up on dev mode |
I would not close it, its still a good feature |
Wait i cannot reopen this |
Because you deleted your branch 😅 will try the next days to restore it :) |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
fixes: #3
fixes: #2
I added runtime import.
This allows this plugin to be used with SvelteKit.