Splidejs / svelte-splide

Svelte component for the Splide slider/carousel.
https://splidejs.com/
MIT License
82 stars 9 forks source link

Module parse failed: Unexpected token when running with Storybook #5

Closed cordellia-SO5 closed 2 years ago

cordellia-SO5 commented 2 years ago

Checks

Version

0.1.18

Description

Pretty much the exact same issue from react-splide but this is showing up when I run Storybook. https://github.com/Splidejs/react-splide/issues/30

ERROR in ./node_modules/@splidejs/svelte-splide/components/Splide/Splide.svelte 574:9
Module parse failed: Unexpected token (574:9)
File was processed with these loaders:
 * ./node_modules/@storybook/svelte/dist/cjs/server/svelte-docgen-loader.js
 * ./node_modules/svelte-loader/index.js
You may need an additional loader to handle the result of these loaders.
| 
|       function go(control) {
>               splide?.go(control);
|       }

Reproduction Link

No response

Steps to Reproduce

  1. Install current svelte-splide version
  2. Install storybook
  3. Run storybook pointing to component using svelte-splide (storybook is using Webpack 4)

Expected Behaviour

Would not error.

NaotoshiFujita commented 2 years ago

As you see the solution in the thread, use webpack 5 instead. Stroybook officially supports it. https://storybook.js.org/blog/storybook-for-webpack-5/