Is your feature request related to a problem? Please describe.
Our ES server backend (EcmaScript, i.e. preferring "import" over "require") directly imports utils.js:
import * as yws from "y-websocket/bin/utils";
Unfortunately, because utils.js has a const Y = require('yjs') line, it is importing Yjs once as CJS, and then when our server later includes yjs by calling import * as Y from 'yjs', Yjs gets included a 2nd time as a module.
This causes the warning:
Yjs was already imported. Importing different versions of Yjs often leads to issues.
Describe the solution you'd like
Would it be possible to refactor such that utils.js is part of the ES module?
Describe alternatives you've considered
Currently, we have code duplication that is (probably) causing issues, as the warning suggests. I believe a workaround is to copy/paste the utils.js file and change the require statements to import.
Is your feature request related to a problem? Please describe.
Our ES server backend (EcmaScript, i.e. preferring "import" over "require") directly imports
utils.js
:Unfortunately, because
utils.js
has aconst Y = require('yjs')
line, it is importing Yjs once as CJS, and then when our server later includes yjs by callingimport * as Y from 'yjs'
, Yjs gets included a 2nd time as a module.This causes the warning:
Describe the solution you'd like Would it be possible to refactor such that
utils.js
is part of the ES module?Describe alternatives you've considered Currently, we have code duplication that is (probably) causing issues, as the warning suggests. I believe a workaround is to copy/paste the utils.js file and change the
require
statements toimport
.