Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few issues with decap-cms-app @ 3.5.0 #7375

Open
dragons-library opened this issue Jan 16, 2025 · 2 comments
Open

few issues with decap-cms-app @ 3.5.0 #7375

dragons-library opened this issue Jan 16, 2025 · 2 comments
Labels
pinned type: bug code to address defects in shipped code

Comments

@dragons-library
Copy link

I just bumped decap-cms-app @ 3.5.0 (from 3.4.0).

After the esm fixes, there are a few lingering things that prevent it from fully functioning.

Note: with the below fixes / workarounds, I have decap-cms-app working in Next.js with React 19.

1. can't resolve 'slate-hyperscript'

decap-cms-app does not declare a dependency / peerDependency on slate-hyperscript, so it fails to resolve (nested dependency from decap-cms-core).

Error

Module not found: Can't resolve 'slate-hyperscript'
   5 | });
   6 | exports.default = void 0;
>  7 | var _slateHyperscript = require("slate-hyperscript");

Workaround

npm i slate-hyperscript

Proposed Fix

Adding slate-hyperscript to decap-cms-app/package.json#peerDependencies should probably work, but peerDeps are notoriously problematic.

2. [email protected] is not browser friendly

[email protected] imports os, which is a node module (node:os), and not resolved in browser-land. This was fixed and released in [email protected].

Error

os is not defined
ReferenceError: os is not defined at [project]/node_modules/decap-cms-app/node_modules/clean-stack/index.js

Workaround

add a local override to bump [email protected] to your package.json:

  "overrides": {
    "clean-stack": "5.2.0"
  }

Proposed Fix

bump clean-stack@^5.2.0 in decap-cms-core

3. Next.js app fails to resolve css

  • ol/ol.css
  • codemirror/lib/codemirror.css
  • codemirror/theme/material.css

Error (with turbopack)

Module [project]/node_modules/ol/ol.css [client] (css) was instantiated because it was required from module [project]/node_modules/decap-cms-widget-map/dist/esm/withMapControl.js [client] (ecmascript), but the module factory is not available. It might have been deleted in an HMR update.

Error (without turbopack):

./node_modules/codemirror/lib/codemirror.css
Global CSS cannot be imported from within node_modules.
Read more: https://nextjs.org/docs/messages/css-npm
Location: node_modules/decap-cms-widget-code/dist/esm/CodeControl.js

Workaround

patch-package and remove the css imports from the packages (see attachments), and manually import them directly in my app:

import 'ol/ol.css';
import 'codemirror/lib/codemirror.css';
import 'codemirror/theme/material.css';

Workaround

The esm build output should probably inline the CSS, as there isn't an industry standard for resolving css imports.

4. [email protected] is not compatible with React 19

This isn't specifically related to the esm build changes, but this should help fix React compatibility issues. The current version of react-scroll-sync is not compatible with React 19.

Error

TypeError: this.context.unregisterPane is not a function at ScrollSyncPane.componentWillUnmount

Workaround

add a local override to bump [email protected] to your package.json:

  "overrides": {
    "react-scroll-sync": "0.11.2"
  },

Proposed Fix

bump react-scroll-sync@^0.11.2 in decap-cms-core

@dragons-library dragons-library added the type: bug code to address defects in shipped code label Jan 16, 2025
@martinjagodic
Copy link
Member

@dragons-library Thanks for raising these and providing the workarounds. These will be useful until we come up with a solution. Note that Decap + React 19 is not officially supported yet, so it's great that we can use your suggestions to make it work.

@dragons-library
Copy link
Author

Just for context, I think the first two are things that "broke" with the 3.5.0 release for anyone that started consuming the esm build of decap-cms-app. The 3rd item probably broke as well, but it might also be somewhat specific to Next.js' build pipeline, though I suspect it will impact anyone without a custom css import rule (I haven't tested this with Vite, parcel, etc).

The 4th item is definitely more specific to React 19 support.

If I have time over the next week or so, I'll try to put together a PR, but if anyone else has the bandwidth and wants to take a stab at it, the above details should be sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pinned type: bug code to address defects in shipped code
Projects
None yet
Development

No branches or pull requests

2 participants