[canvas/plugins_build] whitelist specific imports#27100
Closed
spalger wants to merge 4 commits intoelastic:masterfrom
Closed
[canvas/plugins_build] whitelist specific imports#27100spalger wants to merge 4 commits intoelastic:masterfrom
spalger wants to merge 4 commits intoelastic:masterfrom
Conversation
Contributor
|
Pinging @elastic/kibana-canvas |
b8be11d to
952449a
Compare
Contributor
💔 Build Failed |
Contributor
|
I really like this approach to defining what @spalger calls a "DMZ" for plugin components. This makes our plugin API clean and isolated and an encourages us to write well isolated plugin code. |
Contributor
|
A lot of the issues we have here is additional fallout from #26068 😿 |
Contributor
💔 Build Failed |
This was referenced Dec 17, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We discovered that a number of modules from outside of
x-pack/plugins/canvas/canvas_plugin_srcare being imported and added to thecanvas_pluginbuild. Some minor duplication wouldn't be that big of a problem, but as Canvas integrates more closely with Kibana it causes more and more to get included in thecanvas_plugin.The issue that caught my attention was in #27084 where a small unrelated change caused modules like
ui/notifyto start ending up in thecanvas_pluginbuild.Doing a little research I found the following files are imported into the
canvas_plugin_srcdirectory from outside of it:There are an additional 18 modules that are imported in from packages. Some of these modules can be problematic, like
packages/kbn-interpreter/target/common/lib/types_registry.js, which stores the types registry in its module scope. This approach to storing state only works when we have a single instance of the module in all of the bundles. If we leave this unchecked I imagine it's only a matter of time before we accidentally pull in modules like https://github.com/elastic/kibana/blob/master/packages/kbn-interpreter/src/public/socket.js#L25I'm not sure exactly how we should solve this, but I hope folks on the canvas team have ideas.
For now I've created a simple webpack plugin that allows us to whitelist certain directories/files that can be in the
canvas_pluginbundle. I naively thought that we would be able to whitelist thecanvas_plugin_srcdirectory andnode_modules, but shortly realized that packages were also going to be necessary and then thatcanvas_pluginwas already reaching out of itself quite often.Does canvas have a mechanism for sharing code with plugins that doesn't require importing it from a module? If we went down the path of only whitelisting the
node_modulesandcanvas_plugin_srcdirectory could we pass in all the other dependencies via this mechanism?