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

Missing dompurify addHook #300

Closed
vbar opened this issue Nov 10, 2021 · 9 comments
Closed

Missing dompurify addHook #300

vbar opened this issue Nov 10, 2021 · 9 comments

Comments

@vbar
Copy link

vbar commented Nov 10, 2021

I've just checked out the latest version and am trying to run the Node.js example. When building, yarn shows quite few warnings like

WARNING in ../node_modules/monaco-editor-core/esm/vs/base/browser/markdownRenderer.js
250:4-21 "export 'addHook' (imported as 'dompurify') was not found in './dompurify/dompurify' 
@ ../node_modules/monaco-editor-core/esm/vs/base/browser/markdownRenderer.js
@ ../node_modules/monaco-editor-core/esm/vs/editor/browser/core/markdownRenderer.js
@ ../node_modules/monaco-editor-core/esm/vs/editor/contrib/parameterHints/parameterHintsWidget.js
@ ../node_modules/monaco-editor-core/esm/vs/editor/contrib/parameterHints/parameterHints.js
@ ../node_modules/monaco-editor-core/esm/vs/editor/editor.all.js
@ ../node_modules/monaco-editor-core/esm/vs/editor/editor.main.js
@ ./lib/main.js

That's just a warning, so I ignore it and proceed to run yarn run start and open http://localhost:3000/ .

That seems to be working - I see the Monaco Language Client Node.js Sample page, and the console has "Sample Language Client: The server is initialized." - but soon (I suppose on any further input from the backend language server) crashes:

Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1__dompurify_dompurify__.addHook is not a function
    sanitizeRenderedMarkdown markdownRenderer.js:250
    renderMarkdown markdownRenderer.js:227
    render markdownRenderer.js:53
    renderHoverParts markdownHoverParticipant.js:122
    _renderMessages modesContentHover.js:438
    _withResult modesContentHover.js:405
    _hoverOperation modesContentHover.js:197

So it seems the warning was about something real... I see at https://githubmemory.com/repo/microsoft/monaco-editor/issues/2691 that monaco-editor recently had a suspiciously similar dependency problem - perhaps it should also be fixed in monaco-editor-core?

@CGNonofr
Copy link
Collaborator

The latest version is a old version... no active maintainer have the permissions on https://www.npmjs.com/package/monaco-languageclient so the last version is published on https://www.npmjs.com/package/@codingame/monaco-languageclient

@vbar
Copy link
Author

vbar commented Nov 10, 2021

The latest version is a old version... no active maintainer have the permissions on https://www.npmjs.com/package/monaco-languageclient so the last version is published on https://www.npmjs.com/package/@codingame/monaco-languageclient

I probably was too vague: I didn't install monaco-languageclient with npm , but checked out the latest master here. Of course it can still have wrong dependencies (attaching package-lock.json ), but which would be the right ones?
package-lock.zip

@CGNonofr
Copy link
Collaborator

This bug was only impacting the version 0.29.0 of monaco-editor, I guess you can update it.

Btw feel free to create a PR or I'll do it when I'll get time.

@vbar
Copy link
Author

vbar commented Nov 10, 2021

Well, it isn't so simple: changing
- "monaco-editor-core": "^0.29.0",
+ "monaco-editor-core": "^0.30.1",

in example/package.json leads to compilation failure:

yarn run v1.22.15
$ yarn run compile && webpack && yarn run copy
$ tsc
src/client.ts:36:24 - error TS2345: Argument of type 'typeof import("/home/vb/monaco-languageclient/example/node_modules
/monaco-editor-core/esm/vs/editor/editor.api")' is not assignable to parameter of type 'typeof import("/home/vb/monaco-
languageclient/node_modules/monaco-editor-core/esm/vs/editor/editor.api")'.
  Types of property 'KeyCode' are incompatible.
    Type 'typeof KeyCode' is missing the following properties from type 'typeof KeyCode': KEY_0, KEY_1, KEY_2, KEY_3, 
    and 59 more.

@CGNonofr
Copy link
Collaborator

You just seem to have multiple version of monaco-editor-core, your yarn.lock is probably broken, I suggest you remove it and regenerate it

@CGNonofr
Copy link
Collaborator

#301 should fix it

@vbar
Copy link
Author

vbar commented Nov 11, 2021

#301 should fix it

Well, doesn't that create multiple versions of monaco-editor-core? Now the top-level package.json has

"devDependencies": {
    ...
    "monaco-editor-core": "^0.30.1",

while example/package.json still has

    "monaco-editor-core": "^0.29.0",

And since @codingame/monaco-languageclient changed, version "^0.14.0" should probably be bumped as well...

@CGNonofr
Copy link
Collaborator

I don't think it was an issue, the example just wasn't up to date.

It's updated

@vbar
Copy link
Author

vbar commented Nov 11, 2021

It's updated

Yes, now it works (or at least no longer crashes so soon :-) ) - thanks a lot!

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

No branches or pull requests

2 participants