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

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

Closed
personalizedrefrigerator opened this issue Sep 23, 2024 · 1 comment
Labels
bug It's a bug desktop All desktop platforms

Comments

@personalizedrefrigerator
Copy link
Collaborator

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

c197a83:

  • Defines exports
  • Reverted here — it broke the Function Plot plugin, which uses a library that behaves differently when exports is defined.

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

  • Just setting target: 'web' is insufficient.
  • This breaks renderer/editor content scripts, which define an exports variable and expect it to be modified.

Logs

viewer.js:720 Uncaught ReferenceError: exports is not defined
    at viewer.js:720:11
    at viewer.js:722:12
@personalizedrefrigerator personalizedrefrigerator added bug It's a bug desktop All desktop platforms labels Sep 23, 2024
@laurent22 laurent22 added the high High priority issues label Sep 23, 2024
@laurent22
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms
Projects
None yet
Development

No branches or pull requests

2 participants