withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.62k stars 2.47k forks source link

"module is not defined" Error when evaluating SSR module #11777

Closed zhaohuanyuu closed 2 months ago

zhaohuanyuu commented 2 months ago

Astro Info

Astro                    v4.14.2
Node                     v22.6.0
System                   macOS (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/markdoc

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Problem Description

  1. The original issue #11395 has been temporarily resolved by using dependency overrides (#1453)
  2. However, when import the default configuration of prism(@astrojs/markdown-remark), the commonjs require is not defined appeared again
  3. So I used a similar method to override cssesc to continue to move forward
  4. Then other commonjs dependency errors appeared: For example:
...other commonjs dependency error

astro:vite Error when evaluating SSR module /markdoc.config.mjs:
  astro:vite |- ReferenceError: module is not defined
  astro:vite     at eval (/astro-production/node_modules/.pnpm/debug@4.3.6/node_modules/debug/src/index.js:11:2)

astro:vite Error when evaluating SSR module /astro-production/src/content/blog/01-post.mdoc:
astro:vite |- ReferenceError: module is not defined
astro:vite at eval (/astro-production/node_modules/.pnpm/debug@4.3.6/node_modules/debug/src/index.js:11:2)

Problem reproduction

  1. override cssesc for module is not defined error
  2. override prismjs for require is not defined error

What's the expected result?

Causes and solutions to the problem

Link to Minimal Reproducible Example

https://stackblitz.com/edit/withastro-astro-qmm8xt?file=astro.config.mjs

Participation

zhaohuanyuu commented 2 months ago

Duplicate submission