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

feat: add runtime/sveltekit-support #48

Closed
wants to merge 9 commits into from
Closed

feat: add runtime/sveltekit-support #48

wants to merge 9 commits into from

Conversation

ryoppippi
Copy link
Contributor

@ryoppippi ryoppippi commented Jul 26, 2024

fixes: #3
fixes: #2

I added runtime import.
This allows this plugin to be used with SvelteKit.

@ryoppippi ryoppippi requested a review from prisis as a code owner July 26, 2024 21:08
Copy link
Contributor

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.

Copy link
Contributor

github-actions bot commented Jul 26, 2024

Thank you for following the naming conventions! 🙏

Copy link

socket-security bot commented Jul 26, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

@ryoppippi
Copy link
Contributor Author

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)
So you can change however you like

Copy link

socket-security bot commented Jul 26, 2024

👍 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.

View full report↗︎

@ryoppippi ryoppippi marked this pull request as draft July 26, 2024 21:29
@ryoppippi ryoppippi marked this pull request as ready for review July 26, 2024 21:35

export const handle: Handle = async ({ event, resolve }) => {
const response = await resolve(event, {
transformPageChunk: ({ html }) => html.replace("</head>", `${head}</head>`),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +219 to +242
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,
}),
};
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryoppippi ryoppippi changed the title add runtime add runtime/sveltekit-support Jul 26, 2024
@ryoppippi ryoppippi marked this pull request as draft July 26, 2024 21:38
@ryoppippi ryoppippi marked this pull request as ready for review July 26, 2024 22:02
@ryoppippi
Copy link
Contributor Author

@prisis please modify as you want

@ryoppippi ryoppippi changed the title add runtime/sveltekit-support feat: add runtime/sveltekit-support Jul 26, 2024
@@ -1,5 +1,5 @@
import adapter from "@sveltejs/adapter-auto";
import { vitePreprocess } from "@sveltejs/kit/vite";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryoppippi
Copy link
Contributor Author

The problem is that the favicon doesn't show up on dev mode

@ryoppippi ryoppippi closed this Jul 28, 2024
@prisis
Copy link
Member

prisis commented Jul 29, 2024

I would not close it, its still a good feature

@ryoppippi
Copy link
Contributor Author

Wait i cannot reopen this

@prisis
Copy link
Member

prisis commented Jul 30, 2024

Because you deleted your branch 😅 will try the next days to restore it :)

Copy link
Contributor

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.
Please note this issue tracker is not a help forum. We recommend using our GitHub Discussions tab for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a virtual import for the generated tags
2 participants