laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.27k stars 4.92k forks source link

Plugin template: Scripts bundled with `extraScripts` cause "ReferenceError: exports is not defined" in some situations #11106

Open personalizedrefrigerator opened 2 days ago

personalizedrefrigerator commented 2 days ago

Operating system

Linux

Joplin version

3.1.15

Desktop version info

Joplin 3.1.15 (prod, linux)

Client ID: c13c7d68206342d0be14de538812a561 Sync Version: 3 Profile Version: 47 Keychain Supported: Yes

Revision: e5771a3

Backup: 1.4.2 Extra Markdown viewer settings: 0.4.0

Current behaviour

To reproduce:

  1. Add a plugin that either:
    • Creates a dialog/panel script built with extraScripts.
    • Adds a Markdown viewer asset built with extraScripts.
  2. If the plugin includes a WebView script, open the WebView. If it adds a Markdown viewer asset, open the Markdown viewer.
  3. Check Joplin's development tools.

Expected behaviour

No error should be logged to the console.

Past attempts at fixing this

https://github.com/laurent22/joplin/commit/c197a83de8ad6081872e8f42484a6acbc62febd5:

Setting target: 'web' and changing libraryTarget to var or global in webpack.config.js:

Logs

viewer.js:720 Uncaught ReferenceError: exports is not defined
    at viewer.js:720:11
    at viewer.js:722:12
laurent22 commented 2 days ago

Just setting target: 'web' is insufficient.

Would that fix at least certain plugins (without breaking new plugins)? I've set that up for a plugin and it did help getting rid of the error without any negative effect as far as I can see