No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Mode SSR get error in first run

    CLI
    2
    7
    827
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rainer9202 last edited by rainer9202

      I have a quasar project where i add ssr mode but i get the error:

      import Splide from ‘./components/Splide’;
      Cannot use import statement outside a module

      Splide is in node_modules folder…
      The project work fine in spa and pwa mode…

      beets 1 Reply Last reply Reply Quote 0
      • beets
        beets @rainer9202 last edited by

        @rainer9202 said in Mode SSR get error in first run:

        import Splide from ‘./components/Splide’;

        Where is this code? In src-ssr or somewhere in src ?

        R 1 Reply Last reply Reply Quote 0
        • R
          rainer9202 @beets last edited by rainer9202

          @beets Splide is a carousel component that I use on a page and the error appears in the node_modules file of the package

           import Splide from './components/Splide'; <--- here the error appears !!!
           
           import SplideSlide from './components/SplideSlide';
             
           export default {
             	install( Vue, options ) {
                		Vue.component( Splide.name, Splide );
              		Vue.component( SplideSlide.name, SplideSlide );
                  }
           
           };
           export { Splide, SplideSlide };
          beets 1 Reply Last reply Reply Quote 0
          • beets
            beets @rainer9202 last edited by

            @rainer9202 you may need to transpile it via quasar.conf.js : https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build

            build: {
            transpileDependencies: [/splide/]
            }
            

            I’m on mobile so I can’t look into the package, but if that still doesn’t work I’d probably initialize splide in a client only boot file and wrap it in q-no-ssr tag.

            1 Reply Last reply Reply Quote 0
            • beets
              beets last edited by

              On desktop now and looked at the component, you can probably just do this in your boot file:

              import Splide from '@splidejs/vue-splide/src/js/components/Splide'
              import SplideSlide from '@splidejs/vue-splide/src/js/components/SplideSlide'
              export default ({ Vue }) => {
                Vue.component('splide', Splide)
                Vue.component('splide-slide', SplideSlide)
              }
              

              The problem I’m guessing is that the author didn’t transpile the code to es5, so either the transpileDependencies or the above code should work.

              R 1 Reply Last reply Reply Quote 0
              • R
                rainer9202 @beets last edited by

                @beets i call the splide component in a another page, don’t in a boot file.

                beets 1 Reply Last reply Reply Quote 0
                • beets
                  beets @rainer9202 last edited by beets

                  @rainer9202 Try this then:

                  import Splide from '@splidejs/vue-splide/src/js/components/Splide'
                  import SplideSlide from '@splidejs/vue-splide/src/js/components/SplideSlide'
                  export default {
                    // ...
                    components: {
                      Splide,
                      SplideSlide,
                    }
                  }
                  
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post