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

[3851] - Add/yjs socketio #3923

Merged
merged 21 commits into from
Jul 3, 2024

Conversation

apsinghdev
Copy link
Member

Addresses: #3851

I am trying to install and setup yjs and y-socket.io libraries in Music Blocks. Though I've installed the libraries using npm but I am not able to access them in the collaboration.js file or anywhere else.

I have tried import * as Y from "yjs" (CommonJS) and const Y = require("yjs")" (ES module) both the methods but getting errors. Using CommonJS, I am getting the error Cannot use import statement outside a module, and in ES module, I am getting require not defined

Current Behavior

When I log Console.log(Y), it gives me not defined error.

Expected Behavior

While if library is imported, I will get a module as a result of Console.log(Y)

If you can provide any insight to sort this issue out, It'd be really helpful.

@codewiz
Copy link
Member

codewiz commented Jun 28, 2024

I have tried import * as Y from "yjs" (CommonJS) and const Y = require("yjs")" (ES module) both the methods but getting errors. Using CommonJS, I am getting the error Cannot use import statement outside a module, and in ES module, I am getting require not defined

I wonder if you need to say type="module" in order to use import in collaboarion.js?

<script type="module" src="./js/collaboration/collaboration.js"></script>

Just an idea, I'm not really a web developer. I found this suggestion in Mozilla's official JS documentation:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html

The same doc also recommends the .mjs extension for modules, but I have never seen anyone use it:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#aside_%E2%80%94_.mjs_versus_.js

@apsinghdev
Copy link
Member Author

@walterbender made commits fixing the installation error, please have a look

@walterbender walterbender merged commit 8121cc3 into sugarlabs:collaboration Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants