medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26.25k stars 2.67k forks source link

[CORE-983] Custom plugin API endpoints dont work when using `peerDependancies` as recommended by the docs #2486

Closed chiubaca closed 12 months ago

chiubaca commented 2 years ago

Bug report

Describe the bug

custom plugin API endpoints dont work when using peerDependancies as recommended by the docs.

The recommended change is the following:

"peerDependencies": {
  "@medusajs/medusa": "^1.3.1",
  "medusa-interfaces": "^1.3.0",
  "typeorm": "^0.2.36"
},
"devDependencies": {
  "@babel/cli": "^7.14.3",
  "@babel/core": "^7.14.3",
  "@babel/preset-typescript": "^7.14.5",
  "babel-preset-medusa-package": "^1.1.19",
}

If your package.json is setup like this, your custom endpoints are not picked up by Medusa server.

System information

Medusa version (including plugins): "^1.5.0" Node.js version: v16.13.0 Database: sqlite Operating system: mac os 12.4 Browser (if relevant): Arc Browser (Chromium based)

Steps to reproduce the behavior

Follow the Create a Plugin guide from start to end with a custom endpoint like in the How to Create Endpoint guide.

And set up your package.json as per the instructions in the Change Dependencies section.

When finally installing the plugin, the custom API endpoint does not work.

If you go back to your plugin package.json and update "peerDependencies" to dependencies , then reload the medusa server this resolves the problem.

Expected behavior

The custom plugin should load the custom API endpoint as expected.

Add any other context about the problem here

CORE-983

chiubaca commented 2 years ago

I think related to https://github.com/medusajs/medusa/pull/1860 and https://github.com/medusajs/medusa/issues/1859

anup-a commented 2 years ago

I'm facing a similar issue with my custom plugin. It appears that my endpoints are not registering.

I have tried with medusa new project . Interestingly, none of the existing plugins (which register new endpoints) seems to work for me.

adrien2p commented 1 year ago

We have a pr that allows to pass a custom flag to node --preserve-symlinks which will simplify the local development as it is mainly due to how you install and manage your local deps.

chiubaca commented 1 year ago

awesome, looking forward to this dropping

Pradeepshivaram commented 1 year ago

Even I am facing the same issue, is the PR merged?

olivermrbl commented 1 year ago

Until this issue has been resolved, we will remove the note on peer deps from the documentation. We'll escalate its priority :)