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

Convert utils.js to part of ES module (and move to src dir?) #105

Open
canadaduane opened this issue May 5, 2022 · 0 comments
Open

Convert utils.js to part of ES module (and move to src dir?) #105

canadaduane opened this issue May 5, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@canadaduane
Copy link
Contributor

canadaduane commented May 5, 2022

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.

@canadaduane canadaduane added the enhancement New feature or request label May 5, 2022
@canadaduane canadaduane changed the title Convert utils.js to ES (and move to src dir?) Convert utils.js to part of ES module (and move to src dir?) May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants