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

Awareness as type import? #124

Open
Hideman85 opened this issue Jul 11, 2022 · 0 comments
Open

Awareness as type import? #124

Hideman85 opened this issue Jul 11, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@Hideman85
Copy link

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

@Hideman85 Hideman85 added the bug Something isn't working label Jul 11, 2022
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

2 participants