nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 627 forks source link

Nitro `service-worker` preset broken on StackBlitz/PNPM #1451

Open qin-guan opened 2 years ago

qin-guan commented 2 years ago

Environment

Reproduction

https://stackblitz.com/edit/github-6kcvvz?file=nuxt.config.ts

Describe the bug

Using Nuxt Content with the service-worker preset on StackBlitz throws the error below during build. The error also occurs when using PNPM locally. Using Yarn resolves the issue.

Additional context

Discovered while investigating https://github.com/nuxt/content/issues/1365

Logs

WARN  Could not resolve import "parse5/lib/parser/index.js" in /home/projects/github-6kcvvz/node_modules/hast-util-raw/lib/index.js using exports defined in /home/projects/github-6kcvvz/node_modules/parse5/package.json.

 ERROR  Rollup error: Cannot resolve "parse5/lib/parser/index.js" from "/home/projects/github-6kcvvz/node_modules/hast-util-raw/lib/index.js" and externals are not allowed!

 ERROR  Cannot resolve "parse5/lib/parser/index.js" from "/home/projects/github-6kcvvz/node_modules/hast-util-raw/lib/index.js" and externals are not allowed!

  at Object.resolveId (node_modules/nitropack/dist/shared/nitro.8d0213e3.mjs:1073:17)
  at async resolveId (node_modules/rollup/dist/es/shared/rollup.js:21759:26)
  at async ModuleLoader.resolveId (node_modules/rollup/dist/es/shared/rollup.js:22059:19)
  at async Object.resolveId (node_modules/@rollup/plugin-commonjs/dist/es/index.js:589:10)
  at async resolveId (node_modules/rollup/dist/es/shared/rollup.js:21759:26)
  at async ModuleLoader.resolveId (node_modules/rollup/dist/es/shared/rollup.js:22059:19)
  at async eval (node_modules/rollup/dist/es/shared/rollup.js:22342:42)
  at async Promise.all (index 0)
pi0 commented 2 years ago

Hi @qin-guan. I would suggest to track the issue via https://github.com/nuxt/content/issues/1438. There seem multiple incompatibility issues with Content and Worker* targets.

qin-guan commented 2 years ago

Ah, I didn’t notice that. The two issues don’t seem too related though 😅 since this seems specific to PNPM/Turbo Package Manager. I cannot reproduce it with Yarn or NPM.