jechav / tiny-slider-react

wrapper of tiny-slider plugin for react.
https://tiny-slider-react-tests.netlify.app/
47 stars 27 forks source link

Unexpected string when importing the slider #3

Closed Bobeta closed 5 years ago

Bobeta commented 6 years ago

Tried with the sample code from the demo, but I get the following error:

Uncaught SyntaxError: Unexpected string - commons.js:54025

/***/ "./node_modules/ventura-slider/src/tiny-slider.module.js":
/***/ (function(module, exports) {

    // Format: ES MODULE
    // Version: 2.5.2

    // helper functions
    import './helpers/keys';
    import './helpers/childNode.remove';
jechav commented 6 years ago

@Bobeta hi, this seems to be something related with the configuration of your project, otherwise could be related to the library itself, so you should open a issue in the original plugin https://github.com/ganlanyuan/tiny-slider

sebvilhelm commented 6 years ago

@jechav The issue happens in this fork of tiny-slider that this package uses: https://github.com/jechav/tiny-slider

The newest version of tiny-slider seems to have fixed the issue, which could be related to missing export in ./helpers/keys. The ./helpers/keys looks to be inlined in the latest version of ´tiny-slider`.

@Bobeta Are you using SSR of some kind? I'm guessing the issue is Node.js or Webpack complaining about ES Modules.

CyrilQuandalle commented 6 years ago

hi, Any news about this issue ? FYI I'm doing SSR with NextJs

sebvilhelm commented 6 years ago

@CyrilQuandalle I ended up writing my own wrapper for tiny-slider

CyrilQuandalle commented 6 years ago

Hi @VilhelmNielsen, Thank you for your answer. On my side I ended up coding my own slider from scratch 😉

Bobeta commented 6 years ago

@VilhelmNielsen Could you share it with us? 👍

sebvilhelm commented 6 years ago

@Bobeta Here's a fairly simplified version, it should work: https://gist.github.com/VilhelmNielsen/2b87c4dd00b9e2e074ab346c2c2f80fb

jplew commented 5 years ago

@VilhelmNielsen's wrapper works well for me. Thanks! The only way I could get it to work server-side with Next.js was to import it dynamically though:

import dynamic from 'next/dynamic'

const Slider = dynamic(() => import('~/components/Slider'),
  {
    ssr: false,
  },
)
...

        <Slider>
          <img src="/static/image1.png" />
          <img src="/static/image2.png" />
          <img src="/static/image3.png" />
        </Slider>
jechav commented 5 years ago

@Bobeta Now the original library is compiled so shouldn't be any problem.