decaporg / decaporg/decap-cms

ESM build of `decap-cms-widget-richtext` includes invalid imports

Open
#7,796 1 comment 0 reactions 0 assignees View on GitHub
area: extensions/widgets/richtext type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**
When using `decap-cms-app` in an Astro/Vite app, there are issues due incorrect import statements in the `decap-cms-widget-richtext`.

For example I get:

```
✘ [ERROR] No matching export in "node_modules/.pnpm/unist-util-visit-parents@6.0.2/node_modules/unist-util-visit-parents/index.js" for import "default"

node_modules/.pnpm/decap-cms-widget-richtext@3.2.1_@emotion+react@11.14.0_@types+react@19.2.14_react@19.2.5__@em_hhy545oktf22w3cpgrsx7kwr6i/node_modules/decap-cms-widget-richtext/dist/esm/serializers/remarkAssertParents.js:2:7:
2 │ import visitParents from 'unist-util-visit-parents';
╵ ~~~~~~~~~~~~
```

`visitParents` is [a named export of `unist-util-visit-parents`](https://npmx.dev/package-code/unist-util-visit-parents/v/6.0.2/index.js#L2), not a default export so the resolution fails here:

https://github.com/decaporg/decap-cms/blob/6ef2f9bdf81ce9df55642fe1414e5e687cff95fd/packages/decap-cms-widget-richtext/src/serializers/remarkAssertParents.js#L2

The same issue is present for the import of `mdastDefinitions` here:

https://github.com/decaporg/decap-cms/blob/6ef2f9bdf81ce9df55642fe1414e5e687cff95fd/packages/decap-cms-widget-richtext/src/serializers/remarkSquashReferences.js#L3

**Expected behavior**

The imports should be correct

**Applicable Versions:**

- Decap CMS version: `"decap-cms-app": "^3.12.2"`
- OS: macOS
- Browser version: Firefox 150
- Node.JS version: 24.15

**CMS configuration**
This happens with any config, even when not using the rich text widget

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.