decaporg / decaporg/decap-cms

bug: deps - `clean-stack 5.3.0+` is not browser friendly - triggers `Module build failed: UnhandledSchemeError: Reading from "node:url"`

Open
#7,616 3 comments 5 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

## Background

This issue is extracted [from a comment on an other issue](https://github.com/decaporg/decap-cms/issues/7375#issuecomment-3338505578) that explain several problem of decap and it's dependencies.

## Problem

If you opt for using decap via npm install , opposed to cdn, and your bundler is webpack (next.js uses it), you get this error in the browser runtime on page load of the cms page

```
Module build failed: UnhandledSchemeError: Reading from "node:url" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:url
./node_modules/.pnpm/clean-stack@5.3.0/node_modules/clean-stack/index.js
./node_modules/.pnpm/decap-cms-core@3.8.1_@emotion+react@11.14.0_@types+react@18.3.24_react@18.3.1__@emotion_a50ca47a6744b7ce5e4028262924054d/node_modules/decap-cms-core/dist/esm/components/UI/ErrorBoundary.js
...
```
The reason is:
- decap uses `clean-stack` under the hood
- clean-stack is a library built with focus on server usage (node)
- clean-stack purpose [is not being a browser friendly lib](https://github.com/sindresorhus/clean-stack/issues/6#issuecomment-430338876)
- clean-stack 5.3.0+ introduced new code that uses `node:url`, and this is not present in browser
Here is the code addition that breaks webpack https://github.com/sindresorhus/clean-stack/commit/7eb47b8f69eb02133b4a6c24c31f73a3bf82ee55

## Potential Solution

Short-term:
- fix `clean-stack` at `5.2.0` for now (latest version without node:url addition)

Long-term:
- switch to a different library that has the goal of being browser-friendly

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.