slidevjs / slidev

Presentation Slides for Developers
https://sli.dev
MIT License
33.45k stars 1.37k forks source link

@slidev/client tried to access @unocss/preset-mini, but it isn't declared in its dependencies #1803

Closed shigma closed 3 months ago

shigma commented 3 months ago

Describe the bug

@slidev/client is not isolate-safe.

Minimal reproduction

Steps to reproduce the behavior:

  1. Using Yarn PnP as package manager:
yarn set version 4.4.0
yarn config set nodeLinker pnp
  1. Install dependencies:
yarn add @slidev/cli @slidev/theme-default @slidev/theme-seriph @types/node sass typescript serve -D
  1. Create slides.md:
---
theme: seriph
background: null
class: text-center
highlighter: shiki
transition: fade-out
css: unocss
mdc: true
---
  1. Run yarn slidev:
Error: @slidev/client tried to access @unocss/preset-mini, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: @unocss/preset-mini (via "@unocss/preset-mini/utils")
Required by: @slidev/client@npm:0.49.24 (via /Users/shigma/.yarn/berry/cache/@slidev-client-npm-0.49.24-eede43ec37-10c0.zip/node_modules/@slidev/client/)

Require stack:
- /Users/shigma/.yarn/berry/cache/@slidev-client-npm-0.49.24-eede43ec37-10c0.zip/node_modules/@slidev/client/uno.config.ts
    at require$$0.Module._resolveFilename (/Users/shigma/coding/temp/sd/.pnp.cjs:15471:13)
    at Function.resolve (node:internal/modules/helpers:190:19)
    at _resolve (/Users/shigma/.yarn/berry/cache/jiti-npm-1.21.6-0bb76563a3-10c0.zip/node_modules/jiti/dist/jiti.js:1:241814)
    at jiti (/Users/shigma/.yarn/berry/cache/jiti-npm-1.21.6-0bb76563a3-10c0.zip/node_modules/jiti/dist/jiti.js:1:244531)
    at /Users/shigma/.yarn/berry/cache/@slidev-client-npm-0.49.24-eede43ec37-10c0.zip/node_modules/@slidev/client/uno.config.ts:12:14
    at evalModule (/Users/shigma/.yarn/berry/cache/jiti-npm-1.21.6-0bb76563a3-10c0.zip/node_modules/jiti/dist/jiti.js:1:247313)
    at jiti (/Users/shigma/.yarn/berry/cache/jiti-npm-1.21.6-0bb76563a3-10c0.zip/node_modules/jiti/dist/jiti.js:1:245241)
    at loadModule (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:7226:10)
    at file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9536:22
    at Array.map (<anonymous>)
    at loadFileConfigs (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9533:7)
    at setupUnocss (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9541:8)
    at createUnocssPlugin (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9557:14)
    at ViteSlidevPlugin (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9655:5)
    at resolveViteConfigs (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-KX2WMXVC.js:9725:20)
    at createServer (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/chunk-OIWUVYNO.js:11:30)
    at initServer (file:///Users/shigma/coding/temp/sd/.yarn/__virtual__/@slidev-cli-virtual-3d9bf5e200/4/.yarn/berry/cache/@slidev-cli-npm-0.49.24-6077a90192-10c0.zip/node_modules/@slidev/cli/dist/cli.js:140:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.15.0

Environment

KermanX commented 3 months ago

Slidev has many custom resolving strategies. which makes it quite hard to support Yarn PNP. Sorry for the inconvenience.

shigma commented 3 months ago

Thanks for your quick response.

Is it possible to directly require unocss instead of @unocss/preset-mini?

KermanX commented 3 months ago

Is it possible to directly require unocss instead of @unocss/preset-mini?

I am afraid that there may be tons of other problems like this one. PR welcome if you are willing to work on this😊.

antfu commented 3 months ago

I would honestly recommend not using Yarn PnP in general; it's hacky and introduces too much extra work to the entire ecosystem, where I am unsure if it ever provides any benefits.