harlan-zw / nuxt-delay-hydration

Delayed hydration for progressively enhanced apps. Reduced blocking time and improved Google Lighthouse scores. ⚡️
MIT License
371 stars 22 forks source link

Unexpected token 'return' #51

Closed remihuigen closed 4 months ago

remihuigen commented 4 months ago

Describe the bug Getting an error in both dev and production mode Unexpected token 'return' for routes that use delay hydration. Routes that do not (i.e. { delayHydration: false } in routeRules) show no error.

Screenshots Screenshot 2024-07-18 at 18 42 12

// at veelgestelde-vragen/:111:48253
const hydrationPromise = Promise.race(triggers.map(t => t.p)).finally(() => { triggers.forEach(t => t.c()) }) return hydrationPromise; })();

Additional context Issue was introduced with version 1.3.4.

// nuxt.config.ts

delayHydration: {
    mode: 'init',
    // enables nuxt-delay-hydration in dev mode for testing 
    debug: isDev,
    hydrateOnEvents: [ 'scroll', 'keydown', 'click', 'wheel' ],
    replayClick: true,
    postIdleTimeout: {
        mobile: 5000,
        desktop: 3000
    },
  }
// package.json
{
  "dependencies": {
    "vue": "^3.4.27",
    "vue-router": "^4.3.2"
  },
  "engines": {
    "node": "^18.19.0"
  },
  "devDependencies": {
    "@iconify-json/mdi": "^1.1.67",
    "@nuxt/image": "^1.7.0",
    "@nuxt/ui": "^2.17.0",
    "@nuxtjs/apollo": "^5.0.0-alpha.14",
    "@nuxtjs/device": "^3.1.1",
    "@nuxtjs/fontaine": "^0.4.2",
    "@nuxtjs/google-fonts": "^3.2.0",
    "@nuxtjs/html-validator": "^1.8.2",
    "@nuxtjs/plausible": "^1.0.0",
    "@nuxtjs/seo": "^2.0.0-rc.15",
    "@pinia-plugin-persistedstate/nuxt": "^1.2.0",
    "@pinia/nuxt": "^0.5.1",
    "@types/node-fetch": "^2.6.11",
    "@vue/apollo-composable": "^4.0.2",
    "@vueuse/nuxt": "^10.10.0",
    "autoprefixer": "^10.4.19",
    "mitt": "^3.0.1",
    "node-fetch": "^3.3.2",
    "nuxt": "^3.12.3",
    "nuxt-delay-hydration": "^1.3.4",
    "pinia": "^2.1.7",
    "tailwindcss-debug-screens": "^2.2.1",
    "vue-screen": "^2.4.0"
  }
}
nicolaswalcker commented 4 months ago

Same problem here. image delayHydration: { mode: 'init', debug: false, },

konstantin-karlovich-unbiased-co-uk commented 4 months ago

Same problem

harlan-zw commented 4 months ago

Hi, thanks for reporting this bug. Can you please try v1.3.5 if you'd like to continue using the module and let me know if you have any further issues.

christine927t commented 3 months ago

@harlan-zw Thanks for the quick fix!