nuxt-modules / prismic

Easily connect your Nuxt.js application to your content hosted on Prismic

Home Page:https://prismic.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with escape-html that breaks project (nuxt3)

timb-103 opened this issue · comments

commented

Versions

  • nuxt: 3.0.0
  • @nuxtjs/prismic: 3.0.0-rc.2
  • node: v16.19.0

Reproduction

https://github.com/timb-103/nuxt-prismic-bug

Steps to reproduce

  1. npm install
  2. npm run dev

What is Expected?

It should work however we get this error if you look in the console:

index.js?v=bec4c9b5:4 Uncaught SyntaxError: The requested module '/_nuxt/node_modules/escape-html/index.js?v=bec4c9b5' does not provide an export named 'default' (at index.js?v=bec4c9b5:4:8)

When I click on this issue, it's showing this as the error:

import escapeHtml from '/_nuxt/node_modules/escape-html/index.js?v=cb5aefe0';

It breaks the project completely, for example if you click a link it will refresh the page instead of navigating.

If we stop the process, then do npm run dev for a second time - it works. So I'm not sure why it doesn't work the first time, but it's a bit annoying to keep doing.

If you want to reproduce the bug again after running npm run dev 2 times, you must delete node_modules, then do npm install then npm run dev again.

commented

Hey @timb-103, thank you so much for reporting this issue!

It's something I stumbled across in the past but I don't remember where... (long story short, it's related to Vite not optimizing a kind of old dependencies like escape-html)

In any case, back then, we pushed a fix (inlining escape-html) on a new major we're still working on. I just backported this fix to @prismicio/helpers@2.3.9, can you try running npm update @prismicio/helpers and trying again? (alternatively, you can delete node_modules and package-lock.json and install dependencies again)

Let me know if that works for you ☺️

Also, just letting you know that @nuxtjs/prismic@3 will soon be released as latest (out of RC) 🎉

commented

This has been fixed, see above message. Feel free to reopen if still experiencing issue!