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

Next major release: Make this a proper esm module #72

Open
dmonad opened this issue May 31, 2021 · 9 comments
Open

Next major release: Make this a proper esm module #72

dmonad opened this issue May 31, 2021 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@dmonad
Copy link
Member

dmonad commented May 31, 2021

Note to myself:

Make this a proper ESM module by setting type: "module" in package.json. Currently, the bin folder contains commonjs modules (with file ending of .js) and the src folder contains ecmascript modules (also with the file ending .js). This is invalid to the spec.

But to keep compatibility, we have to keep the current format until the next major release because some projects require the bin module using an absolute path.

@dmonad dmonad added the bug Something isn't working label May 31, 2021
@dmonad dmonad self-assigned this May 31, 2021
@JesseVelden
Copy link

JesseVelden commented Jun 1, 2021

Kind of related (or maybe add another issue/ simple pull request?), when I build my app for production, it is throwing an error trying to import y-websocket/bin/utils:

 Error: Missing "./bin/utils" export in "y-websocket" package

because it is not listed in the exports of the package.json.

Ah I nvm, I read on Gitter, that it is recommended to basically clone the repository to implement your own custom y-websocket server right?

@jperl
Copy link

jperl commented Jun 7, 2021

Related to this, when I tried to install y-websocket@1.3.15 when I run it I get this

Screen Shot 2021-06-07 at 1 48 03 PM

This is not an issue with y-websocket@1.3.14

@TeemuKoivisto
Copy link

Is it possible to upgrade the package.json to use "type": "module"? Not sure what it breaks in downstream repos but I'm willing to fix it if I know what gets broken. Otherwise my svelte-kit project will not build unless I either remove the "exports" block manually or set the type myself by some hacky script. Maybe there's a config option to force a resolution on package basis but I'd rather fix it here.

@nokola
Copy link

nokola commented Nov 28, 2021

This issue makes yjs impossible to use with the latest Svelte/SvelteKit apart from very hard and hacky workarounds.
I'd really like the major version bump that dmonad mentions above :)

Edit: To add more info to TeemuKoivisto's post above, I hacked the package.json to use "type": "module", however that caused a "multiple versions of yjs are loaded, this could cause issues" at runtime.

@TeemuKoivisto
Copy link

TeemuKoivisto commented Nov 29, 2021

@nokola I'll make a PR and see what's the reception. And my current solution has been just pinning the y-websocket version to 1.3.14.

@darkuranium
Copy link

darkuranium commented Mar 29, 2022

Any updates to this?

I'm forced to use an ugly shim because utils.js does not export Y.
Alternatively, as a backwards-compatible stop-gap, could Y perhaps be exported? Probably won't work with everything, but.


Stop-gap for those who ended up here:

Create a shim with the *.cjs , e.g. yjs-shim.cjs (note the extension! — this will force Node to fetch the CJS version of yjs as well).

exports.Y = require('yjs');

… and then import is as normal:

import { Y } from './yjs-shim.cjs';

@jsonkao
Copy link

jsonkao commented Jan 26, 2024

Hi, it would be great if this were released soon.

@MentalGear
Copy link

Is this stil not updated? What's blocking? I'm also in the situation of having to integrate Y.js to sveltekit.

@nokola
Copy link

nokola commented Aug 25, 2024

I'm using yjs with sveltekit/svelte 5 without problem. Using esm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants