d4rkr00t / prosemirror-dev-tools

Developer Tools for ProseMirror
319 stars 37 forks source link

Error: regeneratorRuntime is not defined #105

Closed benrbray closed 4 years ago

benrbray commented 4 years ago

This project looks great! Unfortunately prosemirror-dev-tools seems to have trouble tracking changes with my setup. Any advice would be appreciated! MWE below. I'm using TypeScript and bundling with Parcel.

Error: regeneratorRuntime is not defined

parcel index.html

I get the following error, which seems to be an issue with React, but I'm not familiar enough with React to be able to diagnose the issue.

editor.js:378 Uncaught ReferenceError: regeneratorRuntime is not defined
    at editor.js:378
    at EditorView.handler [as dispatch] (subscribe-on-updates.js:7)
    at readDOMChange (domchange.js:215)
    at DOMObserver.handleDOMChange (input.js:33)
    at DOMObserver.flush (domobserver.js:176)
    at MutationObserver.DOMObserver.observer (domobserver.js:50)

Minimal Working Example

index.ts

import applyDevTools from "prosemirror-dev-tools";
import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import { schema } from "prosemirror-schema-basic";

window.onload = function(){
    const view = new EditorView(document.getElementById("root") as HTMLElement, {
        state: EditorState.create({ schema })
    });

    applyDevTools(view);
}

index.html

<!doctype html>

<html>
    <head>
        <title>WriteMe</title>
        <link rel="stylesheet" href="node_modules/prosemirror-view/style/prosemirror.css">
        <link rel="stylesheet" href="style/editor.less">
        <script src="./src/devtools.ts"></script>
    </head>
<body>
    <div id="root">this is root</div>
</body>
</html>

package.json

{
  "main": "index.js",
  "dependencies": {
    "core-js": "^3.6.5",
    "prosemirror-commands": "^1.1.4",
    "prosemirror-example-setup": "^1.1.2",
    "prosemirror-gapcursor": "^1.1.5",
    "prosemirror-history": "^1.1.3",
    "prosemirror-inputrules": "^1.1.2",
    "prosemirror-keymap": "^1.1.4",
    "prosemirror-menu": "^1.1.4",
    "prosemirror-model": "^1.10.0",
    "prosemirror-schema-basic": "^1.1.2",
    "prosemirror-schema-list": "^1.1.2",
    "prosemirror-state": "^1.3.3",
    "prosemirror-transform": "^1.2.5",
    "prosemirror-view": "^1.14.11"
  },
  "devDependencies": {
    "@types/katex": "^0.11.0",
    "@types/prosemirror-commands": "^1.0.1",
    "@types/prosemirror-gapcursor": "^1.0.1",
    "@types/prosemirror-history": "^1.0.1",
    "@types/prosemirror-inputrules": "^1.0.2",
    "@types/prosemirror-keymap": "^1.0.2",
    "@types/prosemirror-model": "^1.7.2",
    "@types/prosemirror-schema-basic": "^1.0.1",
    "@types/prosemirror-state": "^1.2.4",
    "@types/prosemirror-transform": "^1.1.1",
    "@types/prosemirror-view": "^1.11.4",
    "@types/prosemirror-dev-tools": "^2.1.0",
    "@types/prosemirror-menu": "^1.0.2",
    "less": "^3.11.1",
    "prosemirror-dev-tools": "^3.0.0",
    "react": "^16.8.0",
    "react-dom": "^16.8.0",
    "regenerator-runtime": "^0.13.5"
  }
}
pocke commented 4 years ago

I have the same problem since v3.0.0. v2.1.1 works well for me.

I guess the cause is https://github.com/d4rkr00t/prosemirror-dev-tools/pull/102.

regeneratorRuntime needs babel's polyfill, I guess. So if a user doesn't use babel, this plugin doesn't work.

d4rkr00t commented 4 years ago

It's happening because we use async here to make diffing work in a webworker: https://github.com/d4rkr00t/prosemirror-dev-tools/pull/101/files#diff-90d13460b68f557fc5831101651565e0R201

d4rkr00t commented 4 years ago

Should be fixed in 3.0.1

pocke commented 4 years ago

Thank you! I've confirmed the problem is fixed in v3.0.1.

But I got another problem with IE11. nanoid v3, which this package depends on, doesn't support IE11. https://github.com/ai/nanoid/blob/master/CHANGELOG.md#30

So if this package supports IE11, could you relax the nanoid version to allow nanoid v2?

d4rkr00t commented 4 years ago

Yeah, sounds reasonable, can you open up a PR? Or i can have a look a bit later, today/this week :)

pocke commented 4 years ago

Thanks for the quick response!

I'll try opening a PR. :ok_person: