The note renderer is now back in the main repository

The note renderer has been moved back to the main repository, to make development easier:

https://github.com/laurent22/joplin/tree/master/ReactNativeClient/lib/joplin-renderer

The way it was setup in a separate repo was complicated and I assume would discourage contributions (including my own). Now it’s possible to simply make a change to the renderer, and see the result directly, without any complicated build step.

The advantage is that it will also benefit from the existing tooling, including eslint and TypeScript.

The renderer can still be compiled to a self-contained renderer though and thus can be used in projects outside of the main Joplin apps (the goal eventually is to use that renderer in the Joplin Web API for Nextcloud).

:+1:

I am trying to build the latest ElectronClient, but having problems with missing dependencies in the renderer.

Is there anything obvious I have missed that might fix this?

Do they need to be listed in ElectronClient/app/package.json ?

Example:

Uncaught Error: Cannot find module 'markdown-it-deflist'
Require stack:

  • /tmp/.mount_JoplindqTVBS/resources/app/lib/joplin-renderer/MdToHtml.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/joplin-renderer/MarkupToHtml.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/joplin-renderer/index.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/markdownUtils.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/models/BaseItem.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/models/Note.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/reducer.js
  • /tmp/.mount_JoplindqTVBS/resources/app/lib/BaseApplication.js
  • /tmp/.mount_JoplindqTVBS/resources/app/app.js
  • /tmp/.mount_JoplindqTVBS/resources/app/index.html
    at Module._resolveFilename (internal/modules/cjs/loader.js:717)
    at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (reset-search-paths.ts:40)
    at Module._load (internal/modules/cjs/loader.js:622)
    at Module._load (electron/js2c/asar.js:717)
    at Function.Module._load (electron/js2c/asar.js:717)
    at Module.require (internal/modules/cjs/loader.js:775)
    at require (internal/modules/cjs/helpers.js:68)
    at Object. (/tmp/.mount_JoplindqTVBS/resources/app/lib/joplin-renderer/MdToHtml.js:25)
    at Object. (/tmp/.mount_JoplindqTVBS/resources/app/lib/joplin-renderer/MdToHtml.js:245)
    at Module._compile (internal/modules/cjs/loader.js:880)

Thanks

It is due to this electron-builder bug I think: https://github.com/electron-userland/electron-builder/issues/3185

What if you downgrade electron-builder to 20.15.0? Does it work?

No, that didn’t work. I also tried 22.2.0, also didn’t work.

But I edited packages.json, adding the missing package names, and it seemed to work.

I copied the names and versions from the list in the recently deleted joplin-renderer section:

"joplin-renderer": {
  "version": "1.0.8",
  "resolved": "https://registry.npmjs.org/joplin-renderer/-/joplin-renderer-1.0.8.tgz",
  "integrity": "sha512-Q4SSYXl9ErcnUDTz7N4FjWcOOgfPEf5yyNRjU2J1fuxZ/1VbYt6MnfBB7OeiRW+XF+4Arhihk+/XVK++of4hEA==",
  "requires": {
    "base-64": "^0.1.0",
    "font-awesome-filetypes": "^2.1.0",
    "fs-extra": "^8.1.0",
    "highlight.js": "^9.17.1",
    "html-entities": "^1.2.1",
    "json-stringify-safe": "^5.0.1",
    "katex": "^0.11.1",
    "markdown-it": "^10.0.0",
    "markdown-it-abbr": "^1.0.4",
    "markdown-it-anchor": "^5.2.5",
    "markdown-it-deflist": "^2.0.3",
    "markdown-it-emoji": "^1.4.0",
    "markdown-it-footnote": "^3.0.2",
    "markdown-it-ins": "^3.0.0",
    "markdown-it-mark": "^3.0.0",
    "markdown-it-multimd-table": "^4.0.1",
    "markdown-it-sub": "^1.0.0",
    "markdown-it-sup": "^1.0.0",
    "markdown-it-toc-done-right": "^4.1.0",
    "md5": "^2.2.1",
    "uslug": "^1.0.4"
  },

Does that sound right?

Ok it’s good to know it can work like this, but it means we’ll have to duplicate the packages of joplin-renderer package.json in the Electron app package.json, which is a bit messy and difficult to maintain.

There are 2 issues here:

if you run the app with run.sh you have to do a npm install in ReactNativeClient/lib/joplin-renderer first.

The npm run dist breaks because of the issue with electron-builder.

Instead of copying the ReactClient/lib folder to each project, wouldn’t it possibly be better to move that folder to the root directory and then have each client just have a require=../lib where needed? Or is there a platform specific reason for the current layout?