Skip to content

Svelte preprocessor gives false message #4062

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
ghost opened this issue Feb 22, 2022 · 3 comments · Fixed by sveltejs/svelte-preprocess#487
Closed

Svelte preprocessor gives false message #4062

ghost opened this issue Feb 22, 2022 · 3 comments · Fixed by sveltejs/svelte-preprocess#487

Comments

@ghost
Copy link

ghost commented Feb 22, 2022

Describe the bug

I have the following code:

<svelte:head>
  {#if browser}
    <script src="/app.js"></script>
  {/if}
</svelte:head>

This code does work but I get the following message in my yarn dev terminal: [svelte-preprocess] The file "/app.js" was not found.

app.js is saved in the static directory.

Reproduction

Have the following code snippet in some .svelte file.

<script lang="ts">
  import { browser } from '$app/env';
</script>

<svelte:head>
  {#if browser}
    <script src="/app.js"></script>
  {/if}
</svelte:head>

Logs

yarn run v1.22.17
warning package.json: No license field
$ svelte-kit dev

  SvelteKit v1.0.0-next.260

  local:   http://localhost:3000
  network: not exposed
  network: not exposed

  Use --host to expose server to other devices on this network


[svelte-preprocess] The file  "/cookie.js" was not found.
[svelte-preprocess] The file  "/app.js" was not found.
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:70:0 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:86:4 A11y: <h1> element should have child content
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:102:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:103:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:104:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:121:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:125:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:129:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:133:0 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:150:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:165:6 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:179:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:182:0 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:195:8 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:202:35 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:209:0 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:224:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:227:0 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:230:4 A11y: <img> element should have an alt attribute
9:51:10 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:241:4 A11y: <img> element should have an alt attribute
[svelte-preprocess] The file  "/cookie.js" was not found.
[svelte-preprocess] The file  "/app.js" was not found.
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:70:0 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:86:4 A11y: <h1> element should have child content
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:102:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:103:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:104:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:121:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:125:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:129:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:133:0 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:150:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:165:6 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:179:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:182:0 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:195:8 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:202:35 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:209:0 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:224:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:227:0 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:230:4 A11y: <img> element should have an alt attribute
9:51:11 PM [vite-plugin-svelte] /home/chris/fnl/frontend/src/routes/index.svelte:241:4 A11y: <img> element should have an alt attribute

System Info

System:
    OS: Linux 5.15 Gentoo/Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz
    Memory: 13.39 GB / 15.57 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 17.5.0 - ~/.nvm/versions/node/v17.5.0/bin/node
    Yarn: 1.22.17 - /usr/bin/yarn
    npm: 8.4.1 - ~/.nvm/versions/node/v17.5.0/bin/npm
  Browsers:
    Chromium: 98.0.4758.102
    Firefox: 91.6.0esr
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.17
    @sveltejs/adapter-node: ^1.0.0-next.68 => 1.0.0-next.68
    @sveltejs/kit: next => 1.0.0-next.260
    svelte: ^3.46.0 => 3.46.4

Severity

annoyance

Additional Information

cookie.js is the exact same case.

@dominikg
Copy link
Member

from what i'm reading here it looks like svelte itself parses the extra <script> tag inside svelte:head and passes it to svelte-preprocess which then tries to load the src file as external content https://github.com/sveltejs/svelte-preprocess#external-files

cc @kaisermann

@kaisermann
Copy link
Member

Hey @PortStone 👋

This should fix it sveltejs/svelte-preprocess#487

@kaisermann
Copy link
Member

Fix released in v4.10.4

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 a pull request may close this issue.

3 participants