yjs / y-prosemirror

ProseMirror editor binding for Yjs

Home Page:https://demos.yjs.dev/prosemirror/prosemirror.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Awareness as type import?

Hideman85 opened this issue · comments

We do have the following .cjs output:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Y = require('yjs');
var prosemirrorView = require('prosemirror-view');
var prosemirrorState = require('prosemirror-state');
// Is it required?
require('y-protocols/awareness');
var mutex = require('lib0/mutex');
var PModel = require('prosemirror-model');
var math = require('lib0/math');
var object = require('lib0/object');

I was looking into the code and the only usage of y-protocols/awareness is for the type in the cursor plugin

In typescript the import would have been the following import type { Awareness } from 'y-protocols/awareness' and wont have been shipped into the bundled .cjs
Now the issue is this become required even if you do not make the use of cursor plugin because it has the require('y-protocols/awareness');

Extra context, this error happen to me in a nodejs context where the code is packed to be shiped as a serverless lambda and this dependency should not be needed.

I guess one fix without the need to move to typescrippt would be to remove the top level import and make the import in the jsdoc for the type @param {import('y-protocols/awareness').Awareness} awareness