Skip to content

feat: add Svelte support#101

Open
colinaaa wants to merge 2 commits intov4from
feat/svelte-support
Open

feat: add Svelte support#101
colinaaa wants to merge 2 commits intov4from
feat/svelte-support

Conversation

@colinaaa
Copy link
Copy Markdown
Collaborator

Summary

  • Update transform regex to include .svelte files.
  • Inject utility imports inside the <script> tag of Svelte components.
  • Add test case for Svelte support.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7d17043b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

src/index.ts Outdated
const importStr = `import "${pathToFileURL(VIRTUAL_UTILITIES_ID)}?${params.toString()}";\n`;

if (resourcePath.endsWith('.svelte')) {
const scriptMatch = code.match(/<script[^>]*>/);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restrict Svelte injection to top-level script blocks

Using code.match(/<script[^>]*>/) picks the first <script> tag anywhere in the component, including markup tags like <svelte:head><script src=...></script></svelte:head>. In that case the added import is inserted into an HTML script element instead of Svelte’s top-level component script, so the virtual utilities module is not imported into the module graph (and may also produce invalid inline script code). This breaks Tailwind utility extraction for components that contain non-top-level script tags.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant