Conversation
There was a problem hiding this comment.
💡 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[^>]*>/); |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
.sveltefiles.<script>tag of Svelte components.