Skip to content

Vite define variables break app (500) when <style> tag is present #2583

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

Closed
arxpoetica opened this issue Oct 11, 2021 · 1 comment
Closed

Comments

@arxpoetica
Copy link
Member

Describe the bug

In a basic Kit set up, when using Vite define static replacement globals, if a <style> tag is present in the file where the global is used, a 500 is returned and the app breaks on npm run dev.

Reproduction

Reproduction here:

https://github.com/arxpoetica/sveltekit-6qwj7g
https://stackblitz.com/edit/sveltekit-6qwj7g?file=src%2Froutes%2Findex.svelte

To reproduce:

git clone https://github.com/arxpoetica/sveltekit-6qwj7g.git
cd sveltekit-6qwj7g
npm install
npm run dev

Logs

7:09:31 PM [vite-plugin-svelte] /Users/robert/Documents/@workspace/svelte-project/bugs/sveltekit-6qwj7g/src/routes/index.svelte:1:18 '__TESTING__' is not defined. Consider adding a <script> block with 'export let __TESTING__' to declare a prop
7:09:31 PM [vite-plugin-svelte] /Users/robert/Documents/@workspace/svelte-project/bugs/sveltekit-6qwj7g/src/routes/index.svelte:2:6 '__TESTING__' is not defined. Consider adding a <script> block with 'export let __TESTING__' to declare a prop
Parse failure: Unexpected token (6:120)
Contents of line 6: 	map: "{\"version\":3,\"file\":\"index.svelte\",\"sources\":[\"index.svelte\"],\"sourcesContent\":[\"<div>{console.log("testing")}</div>\\n<div>{"testing"}</div>\\n\\n<style>\\n\\tdiv {\\n\\t\\tcolor: red;\\n\\t}\\n *{}</style>\\n\"],\"names\":[],\"mappings\":\"AAIC,GAAG,eAAC,CAAC,AACJ,KAAK,CAAE,GAAG,AACX,CAAC,AACD,eAAC,EAAE\"}"
Error: Parse failure: Unexpected token (6:120)
Contents of line 6: 	map: "{\"version\":3,\"file\":\"index.svelte\",\"sources\":[\"index.svelte\"],\"sourcesContent\":[\"<div>{console.log("testing")}</div>\\n<div>{"testing"}</div>\\n\\n<style>\\n\\tdiv {\\n\\t\\tcolor: red;\\n\\t}\\n *{}</style>\\n\"],\"names\":[],\"mappings\":\"AAIC,GAAG,eAAC,CAAC,AACJ,KAAK,CAAE,GAAG,AACX,CAAC,AACD,eAAC,EAAE\"}"
    at ssrTransform (/Users/robert/Documents/@workspace/svelte-project/bugs/sveltekit-6qwj7g/node_modules/vite/dist/node/chunks/dep-55830a1a.js:55904:15)
    at doTransform (/Users/robert/Documents/@workspace/svelte-project/bugs/sveltekit-6qwj7g/node_modules/vite/dist/node/chunks/dep-55830a1a.js:56746:48)

System Info

System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 1.08 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.3.0 - ~/.volta/tools/image/node/16.3.0/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 7.15.1 - ~/.volta/tools/image/node/16.3.0/bin/npm
  Browsers:
    Chrome: 94.0.4606.71
    Edge: 81.0.416.53
    Firefox: 86.0.1
    Firefox Nightly: 76.0a1
    Safari: 14.0.3
  npmPackages:
    @sveltejs/kit: 1.0.0-next.180 => 1.0.0-next.180
    svelte: 3.43.1 => 3.43.1

Severity

serious, but I can work around it

Additional Information

No response

@benmccann
Copy link
Member

Duplicate of #720

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

No branches or pull requests

2 participants