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

chore(medusa): Re enable plugin loading #8843

Merged
merged 4 commits into from
Aug 28, 2024
Merged

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Aug 28, 2024

Summary

This PR re-enables the ability to load resources from external packages through the plugins property in the medusa-config.

Resolves: FRMW-2678

What’s Changed

  • Plugin Loading:
    • The plugins property in medusa-config now supports loading resources from external packages from node modules, plugins directory or any other relative path outside of the project.
    • When loading plugins:
      • If the plugin is specified as a relative path and does not exist in the plugins directory of the local project, the system will resolve it using the relative path and will load the resources from either its dist or src directory, depending on how the project is started.
      • If the plugin is specified as a relative path and exist in the plugins directory of the local project, the system will resolve it using the relative path and will load the resources the directory itself
      • If the plugin is specified as an absolute path and/or is part of the node_modules we will load the resources from its dist

Note:

  • This update distinguishes between local development plugins and external packages based on their location and path resolution.

Testing

I created and tested a plugin in a local dummy project using the following structure:

The test plugin successfully loaded and executed the following components:

  • API: Added a store route that triggers an event and an admin route.
  • Subscribers: Registered a subscriber that listens to the event emitted by the route.
  • Jobs: Scheduled a job that executes every second.
  • Links: Registered a new link.
  • Workflows: Registered a new workflow.

Configuration Used:

module.exports = defineConfig({
  plugins: [{
    resolve: '../plugin-1'
  }],
  /*...*/
})

Copy link

changeset-bot bot commented Aug 28, 2024

⚠️ No Changeset found

Latest commit: 833c6bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Aug 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medusa-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 28, 2024 1:28pm
6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Aug 28, 2024 1:28pm
api-reference-v2 ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2024 1:28pm
docs-ui ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2024 1:28pm
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2024 1:28pm
medusa-docs ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2024 1:28pm
resources-docs ⬜️ Ignored (Inspect) Visit Preview Aug 28, 2024 1:28pm

Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice LGTM

@adrien2p
Copy link
Member Author

@olivermrbl shall we merge?

@olivermrbl
Copy link
Contributor

Yeah, think that should be fine right?

@adrien2p
Copy link
Member Author

yeah it shouldnt be a problem

@adrien2p adrien2p merged commit 5294ce8 into develop Aug 28, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants