0

I am building a CodeMirror-Yjs-editor. I followed the example in y-codemirror.next. But when I tried to rollup the JS, I got the error in the title.

I tried to change dependency version but still could not get it working. Please help.

Any help is appreciated.

Rollup command:

npm run dist

Error:

[!] RollupError: "default" is not exported by "node_modules/simple-peer/simplepeer.min.js", imported by "node_modules/y-webrtc/src/y-webrtc.js".
https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
node_modules/y-webrtc/src/y-webrtc.js (16:7)
14: 
15: import * as Y from 'yjs' // eslint-disable-line
16: import Peer from 'simple-peer/simplepeer.min.js'
           ^
17: 
18: import * as syncProtocol from 'y-protocols/sync'
    at error (/var/www/websocket_live/codemirror.next/node_modules/rollup/dist/shared/rollup.js:349:30)
    at Module.error (/var/www/websocket_live/codemirror.next/node_modules/rollup/dist/shared/rollup.js:15093:16)
    at Module.traceVariable (/var/www/websocket_live/codemirror.next/node_modules/rollup/dist/shared/rollup.js:15518:29)
... ...        

My package.json file:

{
  "name": "CodeMirror-Yjs-editor",
  "version": "1.0.0",
  "description": "",
  "main": "codemirror.js",
  "scripts": {
    "clean": "rm -rf dist",
    "dist": "npm run clean && rollup -c --bundleConfigAsCjs && tsc",
    "watch": "rollup -wc",
    "lint": "standard && tsc",
    "start": "concurrently 'http-server -o index.html' 'npm run watch'"
  },
  "dependencies": {
    "@codemirror/lang-javascript": "^6.0.2",
    "codemirror": "^6.0.1",
    "y-codemirror.next": "^0.3.2",
    "y-webrtc": "^10.2.5",
    "yjs": "^13.5.41"
  },
  "devDependencies": {
    "@rollup/plugin-babel": "^6.0.3",
    "@rollup/plugin-commonjs": "^25.0.3",
    "@rollup/plugin-node-resolve": "^15.0.1",
    "concurrently": "^5.3.0",
    "http-server": "^14.1.0",
    "jsdom": "^22.1.0",
    "rollup": "^3.27.2",
    "standard": "^14.3.4",
    "typescript": "^3.9.10"
  }
}

Update:

rollup.config.js

import babel from "@rollup/plugin-babel";
import {nodeResolve} from "@rollup/plugin-node-resolve";
export default {
  input: "./codemirror.js",
  output: {
    file: "./cm6.bundle.js",
    format: "umd"
  },
  plugins: [babel(), nodeResolve()]
}
Charles
  • 675
  • 3
  • 12
  • 21

0 Answers0