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

[Vue] detect dependent plugins in vue UMDs and order plugins appropriately #18337

Merged
merged 2 commits into from Nov 17, 2021

Conversation

diosmosis
Copy link
Member

Description:

Plugin UMD modules can depend on other ones, but the loading order currently is just how it is encountered when reading filesystem folders. This is an issue if, for example, CorePluginsAdmin is loaded before CoreHome when CorePluginsAdmin depends on CoreHome. This PR fixes this by:

  • detecting UMD module dependencies via the vue.config.js file. Webpack allows us to specify what imports should result in accessing the window object directly. Currently we do this for plugins, eg, import blahblah from 'CoreHome'. We did this before by using an object mapping 'CoreHome' with the object in window (also 'CoreHome' currently). webpack also allows using a function instead of an object, so now we're using a function that will detect and remember when a plugin is imported.
  • then a new webpack plugin is used to output that data to a umd.metadata.json file.
  • in JScriptUIFetcher, we read these files and do a quick DFS to order the plugins correctly for loading UMD files.

Note: this PR does not currently detect cycles.

Review

@diosmosis
Copy link
Member Author

Added docs for this here: matomo-org/developer-documentation#587

@diosmosis diosmosis merged commit 1dcab06 into 4.x-dev Nov 17, 2021
@diosmosis diosmosis deleted the vue-plugin-dependencies branch November 17, 2021 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants