-
Notifications
You must be signed in to change notification settings - Fork 478
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
Remove built-in plugins from plugin package #1752
Comments
@flowchartsman Why do you want to exclude it? You would just do |
@alixander It's because I'm building a plugin, which makes it a binary that depends on I can see why the decision was made to bundle dagre and elk into the package, but this hampers the use of
Thus, my suggestion would be to convert them to positive tags and add these to the release tooling or, better still, move them to separate packages completely and add a Something like this: /*d2/d2plugin/embedded.go*/
//go:build plugins_embed
package d2plugin
func RegisterEmbeddedPlugin(p Plugin) {
plugins = append(plugins, p)
} Then move the entire contents of
and
Respectively, and modify them to call This way embedded plugins can still register themselves for production builds but |
Ended up being a bit more than that, since the plugin types were unexported, however moving them to internal and making them exported was enough to solve the issue. Now they are included as part of the process of building |
Having considered this some more, I think you could get away without build tags entirely by moving all of the dagre/elk code inside of internal (since there's probably not much need for a user to include either of them), and just allowing |
Why is this so undesirable?
Is it just the extra size? Goja is pure go, so there's no concerns about dependencies causing anything else. |
It's undesirable because it's completely unnecessary, makes building plugins more difficult, and kind of goes against the otherwise-clean plugin abstraction you've set up. It feels like a minor oversight to compile two unrelated bundled layout plugins into every plugin someone might want to develop, and it's easy enough to fix by just moving the bundled plugin integration into the CLI, which is where it makes more sense to put it since it's the primary release artifact (this is what my second PR would be).
Not just that, it also made it difficult to build the plugin, since there was a mismatch between the The PR I'm currently working on simply moves the initialization of the bundled plugins into the CLI package which is probably where they belong anyway, since that's the primary release artifact. It also cleans up the abstraction and moves the bundled plugins into their own package. It's not the end of the world or anything, but it's definitely the cleanest way to handle it if you actually want people to be able to build their on plugins. |
I see. Yeah I think that's right that they should be initialized by the CLI instead of a lib package. I'll take a look at the PR shortly. |
Don't look at the current PR too seriously. I think it's more complicated than it needs to be and touches more of the build than it needs to. There is a more elegant way to do it that I will submit soon. |
I am in the very early stages of building my own layout plugin for d2 and everything works mostly well, however I am forced to use build tags in order to exclude the built-in plugins. This is due to their built tags being negative instead of positive. It would probably be better to have the built-in plugins in a separate package, but changing the build tag system from
//go:build !nodagre
to//go:build bundledagre
and then including these in your release scripting would also work. Willing to submit a PR, if needed.The text was updated successfully, but these errors were encountered: