zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
3.76k stars 204 forks source link

Build instructions? #845

Closed ChristofferNorgaard closed 1 year ago

ChristofferNorgaard commented 1 year ago

Hi.

I am modifying excalidraw to be a bit more usable with apple pen and am trying to build obsidian excalidraw plugin.

Are there any instructions how to build this? Any node or yarn versions and so on...

I am having a bit of trouble with rollup and colormaster and I think it may be a version problem.

yarn run v1.22.17
$ cross-env NODE_ENV=production rollup --config rollup.config.js
1.7.24

src/main.ts → ....
babelHelpers: 'bundled' option was used by default. It is recommended to configure this option explicitly, read more here: https://github.com/rollup/plugins/tree/master/packages/babel#babelhelpers
(!) Circular dependencies
src/ExcalidrawView.ts -> src/ExcalidrawAutomate.ts -> src/ExcalidrawView.ts
src/ExcalidrawAutomate.ts -> src/ExcalidrawData.ts -> src/ExcalidrawAutomate.ts
src/ExcalidrawView.ts -> src/ExcalidrawAutomate.ts -> src/ExcalidrawData.ts -> src/ExcalidrawView.ts
...and 5 more
(!) Plugin node-resolve: Could not resolve import "colormaster/plugins/luv" in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\src\ExcalidrawAutomate.ts using exports defined in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\node_modules\colormaster\package.json.
(!) Plugin node-resolve: Could not resolve import "colormaster/plugins/uvw" in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\src\ExcalidrawAutomate.ts using exports defined in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\node_modules\colormaster\package.json.
(!) Plugin node-resolve: Could not resolve import "colormaster/plugins/ryb" in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\src\ExcalidrawAutomate.ts using exports defined in C:\Users\Jakob\Downloads\obsidian-excalidraw-plugin-master\node_modules\colormaster\package.json.
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
colormaster/plugins/luv (imported by src/ExcalidrawAutomate.ts)
colormaster/plugins/uvw (imported by src/ExcalidrawAutomate.ts)
colormaster/plugins/ryb (imported by src/ExcalidrawAutomate.ts)
created . in 9.8s
Done in 12.05s.

Thanks for all the good work on the project.

zsviczian commented 1 year ago

Great! Once you have improvements for the apple pencil let's implement them in the Obsidian fork as well. Instead of working with the Obsidian fork you might be better off forking the excalidraw main product. If you get additional features for apple pencil developed there it will be easy to bring them into the obsidian fork. Also if I do developments to the core package I always try to make the changes to excalidraw.com because that way my enhancements are available to others as well, and when the package changes, my changes are considered as well.

If you still want to build the obsidian version you need to fork two projects, this and this.

Have you noticed the comments I have in rollup.js? you need to apply these. //!postprocess - the version available on npmjs does not work, need this update: // npm install brettz9/rollup-plugin-postprocess#update --save-dev // https://github.com/developit/rollup-plugin-postprocess/issues/10

Other then these comments and the need to build both projects (the for-obsidian excalidraw package and the plugin project), there should be nothing additional required. I build on Windows - you may need to modify scripts in package.json to work with your operating system.

ChristofferNorgaard commented 1 year ago

Ok, thank you for information.

swoh816 commented 1 month ago

I want to debug https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1814 which is presumably happening only in my machine, so I tried to follow the build instruction described here (since I had the same issue as @ChristofferNorgaard for npm not being able to resolve import "colormaster/plugins/luv"). However, I cannot resolve the issue, so I guess there's something I'm doing wrong. I would really really appreciate it if any of you could help me for a successful build. Here are the steps I tried following @zsviczian 's reply above:

  1. Clone both obsidian-excalidraw-plugin and excalidraw to .obsidian/plugins/. 1.1 For excalidraw, switch to for-obsidian branch
  2. Run npm install in both excalidraw and obsidian-excalidraw-plugin.
  3. Go to obsidian-excalidraw-plugin directory, run npm install brettz9/rollup-plugin-postprocess#update --save-dev.
  4. Run npm run build in both excalidraw and obsidian-excalidraw-plugin. 4.1. For excalidraw, run export NODE_OPTIONS=--openssl-legacy-provider before build. Otherwise, I get Error: error:0308010C:digital envelope routines::unsupported
  5. Go to obsidian-excalidraw-plugin directory, and copy ./dist/main.js to ./main.js.
  6. In Obsidian, run Command Palette -> Reload app without saving
  7. In Obsidian, go to Community plugins -> Turn on Excalidraw

After 7 above, I get Plugin failure: obsidian-excalidraw-plugin Error: Cannot find module 'colormaster/plugins/luv' in Obsidian Developer console, which is because of npm was not able to resolve import "colormaster/plugins/luv", I guess.

I'm not familiar with the entire Javascript ecosystem, and that's probably why I'm having these difficulties. I would really really appreciate if you could help me figure out the issue!

node version: v18.19.1 Operating system: Ubuntu 22.04