Cannot Import Module

I am new to plugin development and typescript. I want to create a plugin that syncs my google calendar events and such as notes; but I ran into some problems right away. I need to import a few modules: readline, http2, fs-extra.

Everything builds okay after running, npm install and npm run dist, but when I start the app in dev using "\AppData\Local\Programs\Joplin\Joplin.exe --env dev" the console throws an error saying Uncaught Error: Module readline cannot be found. I've tried everything I can think of and everything in this thread generator-joplin: Module not found: Error: Can't resolve 'fs' · Issue #4372 · laurent22/joplin · GitHub.

See the following from GENERATOR_DOC.md

External script files

By default, the compiler (webpack) is going to compile src/index.ts only (as well as any file it imports), and any other file will simply be copied to the plugin package. In some cases this is sufficient, however if you have content scripts or webview scripts you might want to compile them too, in particular in these two cases:

  • The script is a TypeScript file - in which case it has to be compiled to JavaScript.

  • The script requires modules you've added to package.json. In that case, the script, whether JS or TS, must be compiled so that the dependencies are bundled with the JPL file.

To get such an external script file to compile, you need to add it to the extraScripts array in plugin.config.json. The path you add should be relative to /src. For example, if you have a file in "/src/webviews/index.ts", the path should be set to "webviews/index.ts". Once compiled, the file will always be named with a .js extension. So you will get "webviews/index.js" in the plugin package, and that's the path you should use to reference the file.