sveltejs / sveltejs/kit

Not able to use unplugin-macros with svelte kit

Open
#14,547 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

vite
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

unplugin-macros works with vite-plugin-svelte but not with sveltekit.

Reproduction

demo with vite-plugin-svelte: https://stackblitz.com/edit/vitejs-vite-jnfp883g
demo with sveltekit: https://stackblitz.com/edit/sveltejs-kit-template-default-varswkuh

run pnpm build and search for console.log in the build files: you should find a random number with console.log() instead of getRandom()

console.log(.8932386624955339)
as getRandom() is run during compilation.
console.log(_l())

Logs

System Info
stackblitz
Severity

annoyance

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked SvelteKit and vite-plugin-svelte StackBlitz reproductions, run pnpm build, and compare the generated files for the console.log output. Trace why getRandom() is compiled in the Vite reproduction but remains in the SvelteKit build; done means the SvelteKit build produces the same transformed output as the working reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.