Skip to content
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

Causes parsing error and breaks build #115

Closed
scottdotweb opened this issue Dec 22, 2019 · 6 comments
Closed

Causes parsing error and breaks build #115

scottdotweb opened this issue Dec 22, 2019 · 6 comments

Comments

@scottdotweb
Copy link

Adding svelte-loader to my Webpack configuration is causing my build to fail with the following:

ERROR in ./src/client/svelte/views/App.svelte
Module build failed (from ./node_modules/svelte-loader/index.js):
Error: ParseError: Cannot have an {:else} block outside an {#if ...} or {#each ...} block (29:16)
27: const file = "src/client/svelte/views/App.svelte";
28: 
29: // (26:0) {:else}
                    ^
30: function create_else_block(ctx) {
31:   let current;
    at /home/scott/code/music/node_modules/svelte-loader/index.js:181:12
 @ ./src/client/svelte/client.js 5:0-36 7:16-19
 @ multi ./src/client/svelte/client.js

The report of a parsing error is incorrect and will not occur if I remove the new configuration. I am building in development mode and not using HMR.

The configuration I added is:

{
  test: /\.svelte$/,
  exclude: /node_modules/,
  use: {
    loader: 'svelte-loader',
    options: {
      preprocess: require('svelte-preprocess')({}),
    },
  },
},

Installed versions from package.json:

"svelte": "^3.16.4",
"svelte-loader": "^2.13.6",
"svelte-preprocess": "^3.3.0",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
@antony
Copy link
Member

antony commented Dec 22, 2019

Can we see what App.svelte contains?

@scottdotweb
Copy link
Author

Hi @antony, this is the whole thing.

<script>
    import Head        from '../parts/Head.svelte'
    import HomeLink    from '../parts/HomeLink.svelte'

    import AllSongs    from './AllSongs.svelte'
    import Artist      from './Artist.svelte'
    import Home        from './Home.svelte'
    import Player      from './Player.svelte'
    import Search      from './Search.svelte'

    export let artistId
    export let route
    export let searchString
</script>

<Head />

<HomeLink route={route} />

{#if route === 'allSongs'}
    <AllSongs />
{:else if route === 'artist'}
    <Artist artistId={artistId} />
{:else if route === 'player'}
    <Player />
{:else if route === 'search'}
    <Search />
{:else if route === 'searchArtist' }
    <Search searchType="artist" searchString={searchString} />
{:else}
    <Home />
{/if}

@webdagger
Copy link

Are you perhaps using SCSS with Svelte? I am using Svelte + Sapper + Storybook.
Storybook seems to be the one raising the errors.

@rodrigomatosrj
Copy link

I´m facing the same issue with sveltekit, SASS + storybook. Is there a solution ?

@scottdotweb
Copy link
Author

Just a note as the issue author to say this particular project of mine has been on the shelf for a while and I forgot about this issue. Should I pick it up again in the near future, I'll see if I can still reproduce it and get any more idea of what's going on, but for now can't contribute any more info.

@mcuppi
Copy link

mcuppi commented Jun 2, 2022

@dummdidumm; This should be probably be marked as a question and closed. There isn't enough information here to determine if this issue was due to svelte-loader. Additionally, the author seems to have moved on.

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

6 participants