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

Desktop: Beta editor plugin API: Fix plugins unable to require nodeJS modules #9968

Merged

Conversation

personalizedrefrigerator
Copy link
Collaborator

Summary

Fixes an issue where plugins like Enhancement failed to load in the CodeMirror 6 editor because require failed to import modules like path.

Note that Webpack preserves NodeJS modules required from content scripts with our current Webpack configuration.

Testing

This has been tested successfully by:

  1. Applying the following diff:
diff --git a/packages/app-cli/tests/support/plugins/codemirror6/src/contentScript.ts b/packages/app-cli/tests/support/plugins/codemirror6/src/contentScript.ts
index 5e61478af..c7ff50126 100644
--- a/packages/app-cli/tests/support/plugins/codemirror6/src/contentScript.ts
+++ b/packages/app-cli/tests/support/plugins/codemirror6/src/contentScript.ts
@@ -5,6 +5,7 @@
 // the editor to not work properly.
 //
 import { lineNumbers, highlightActiveLineGutter, } from '@codemirror/view';
+const path = require('path');
 //
 // For the above import to work, you may also need to add @codemirror/view as a dev dependency
 // to package.json. (For the type information only).
@@ -29,6 +30,7 @@ export default (_context: { contentScriptId: string }) => {
 
 			// See https://codemirror.net/ for more built-in extensions and configuration
 			// options.
+			console.log('test: ', path.resolve('.'));
 		},
 
 		// There are two main ways to style the CodeMirror editor:
  1. Rebuilding the example CodeMirror 6 plugin.
  2. Inspecting the built .jpl file to verify that it does include require('path').
  3. Starting Joplin (the beta editor was already enabled and the CodeMirror 6 demo plugin was already added to Joplin as a development plugin)
  4. Verifying that test: followed by a path was logged to Joplin's development tools.

This has been tested successfully on Ubuntu 23.10.

@laurent22 laurent22 merged commit 4c5e708 into laurent22:dev Feb 22, 2024
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants