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

Syntax Error when using 'target: server' with Nuxt.js #97

Closed
rylax opened this issue Aug 1, 2021 · 5 comments
Closed

Syntax Error when using 'target: server' with Nuxt.js #97

rylax opened this issue Aug 1, 2021 · 5 comments

Comments

@rylax
Copy link

rylax commented Aug 1, 2021

Issue related to: #82

When using server-side Nuxt.js with:

mode: 'universal'
target: 'server'

with component registration:

<script>
import VueFuse from 'vue-fuse'

export default {
  components: {
    VueFuse,
  },
}
</script>

I get the syntax error "Unexpected token '<'"

The problem seems to be associated with SSR. Tried out rendering only client-side:

mode: 'spa'
target: 'static'

and this strangely works. Any reason why target: 'server' seems to break and what we can do about it?

@shayneo
Copy link
Owner

shayneo commented Aug 10, 2021

I think the problem is that the module ships the raw .vue file as opposed to a compiled js version. This was my overly simple technique to supporting both Vue2 and Vue3. To get this to work I think I'd need to leverage something like vue-demi, which might take me a while to get around to.

Until then, I HIGHLY recommend taking a look at the source-code, as you can easily drop Fuse.js into your project directly and build your own fuzzy search functionality. This package doesn't do anything special, just a convenience wrapper around Fuse.

@scottyzen
Copy link

I had the same issue but got it to work by wrapping the client-only component around it.

<client-only>
    <VueFuse />
</client-only>

Any the import the VueFuse component like this.

export default {
    components: {
        VueFuse: () => import('vue-fuse')
    }
}

@shayneo
Copy link
Owner

shayneo commented Oct 13, 2021

Closing as I just released 4.x, which takes this in a different direction

@shayneo shayneo closed this as completed Oct 13, 2021
@rylax
Copy link
Author

rylax commented Nov 18, 2021

  VueFuse: () => import('vue-fuse')

While this approach did work for me in the end, I have just noticed that it created a huge memory leak. Trying to find a workaround now.

@hacknug
Copy link

hacknug commented Nov 24, 2021

  VueFuse: () => import('vue-fuse')

While this approach did work for me in the end, I have just noticed that it created a huge memory leak. Trying to find a workaround now.

Have you tried importing the component on a client-only plugin? That usually solves all the similar issues I encounter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants