2

I'm rather new to React and now trying to fix an error that occurs at runtime due to a new version of prosemirror.model in our artifactory. The new version is 1.18.1, the old version that works was 1.16.1.

Loading the page gives the following error in console:

Uncaught TypeError: prosemirror_model__WEBPACK_IMPORTED_MODULE_0__.Schema is not a constructor
    at Module.../../components/src/20-molecules/rte/config/schema.js (schema.js:122:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module.../../components/src/20-molecules/rte/index.js (editor.css?e9c4:45:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module.../../components/src/index.js (index.js:1:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module../src/containers/edit/edit.js (index.scss?46f0:45:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module../src/containers/edit/index.js (edit.js:600:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module../src/App.js (types.js:3:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Module../src/index.js (i18n.js:74:1)
    at __webpack_require__ (bootstrap:781:1)
    at fn (bootstrap:149:1)
    at Object.0 (url.js:251:1)
    at __webpack_require__ (bootstrap:781:1)
    at checkDeferredModules (bootstrap:45:1)
    at Array.webpackJsonpCallback [as push] (bootstrap:32:1)
    at main.chunk.js:1:57

Code line that breaks:

export const schema = new Schema({ nodes, marks });

I've tried to find the code to create the Schema instance without constructor, but couldn't identify it. Even the prosemirror guide and code themselves use the constructor to create a Schema object, so I'm quite confused about this. Anyone an idea how to solve this?

Bartjo77
  • 21
  • 2
  • The line of code looks correct. Have you tried logging the value of `Schema` to see what it is? – Marijn Jun 17 '22 at 07:56
  • @Marijn I logged it and ```Schema``` is undefined. btw imported through: ```import { Schema } from 'prosemirror-model';``` – Bartjo77 Jun 17 '22 at 08:24
  • That's the right way to import it. Something in your building/bundling process might be broken. Do other imports work? – Marijn Jun 17 '22 at 14:16
  • Build is running fine. The issue could actually more be related to ordered-map, since an upgrade there was the start of the issues we have. v1.1.5 was working, v2.0.0 not, so we put 1.1.5 in the resolutions. Don't know if that helps, we don't have other issues with build/bundling or imports. – Bartjo77 Jun 20 '22 at 14:12
  • I get this error as well after upgrading, but only in test, not when I invoke PM via `yarn start` – wbharding Sep 21 '22 at 15:15

0 Answers0