medusajs / medusa

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

Cannot create a custom module #7980

Closed Niblu closed 4 months ago

Niblu commented 4 months ago

Bug report

Describe the bug

I have created a module per documentation https://docs.medusajs.com/development/modules/create and when building, I get Could not resolve module: Custom: moduleType <--- I am not sure what I need to input for this but I tried with my service name, other service names etc... nothing works, no explanation of what this is aswell in the docs.

moduleType: { resolve: "./modules/ses/src/index.ts", options: { // options if necessary }, }

System information

Medusa version (including plugins): 1.20.6 Node.js version: 20 Database: postgres Operating system: macOS Browser (if relevant):

Steps to reproduce the behavior

  1. Follow guide to creating a custom module
  2. run npx medusa develop

Expected behavior

Custom module should be initialized.

Code snippets

// what must be here? What types of modules are there, I can't find reference to this.... moduleType: { resolve: "./modules/ses/src/index.ts", options: { // options if necessary }, }

Additional context

Add any other context about the problem here

sradevski commented 4 months ago

Hey @Niblu are you trying to create a v1 or v2 module? Initially the idea was that v1 would also support modules, but that idea was scrapped. If you need customizations in v1, please have a look at https://docs.medusajs.com/development/overview. If you are planning on starting a new project, I would suggest you have a look at https://docs.medusajs.com/v2.

Let me know if that answers your question, and we can close the ticket

Niblu commented 4 months ago

It is in v1 yes, so that is not possible in v1 anymore? Maybe would be good to update the docs here

Also, is v2 ready for production, I am starting a project and would like to use v2 as it has been a long time since I used medusa and so I am relarning it anyway, but in the docs it says to not use v2 in prod yet.

sradevski commented 4 months ago

@Niblu Yeah we are in the process of reiterating over the docs :). In v1, you'd probably want to use custom services to do extensions, among other methods, not modules (again, I am not sure what your use-case is here).

It's not production-ready yet, but it should be in 2-3 months. If you are planning to go to production later than that, I'd suggest you start with v2, but it all depends on your timelines as well

Niblu commented 4 months ago

Allright, thank you. Didn't realise v2 should be ready in 2-3 months, cool. I will need this project faster, so I will just use normal extending, but the next project will definitely be v2.

I wanted to use modules like sort of like plugins, but without posting them to npm... so to separate and group my code for reusability, but keep it locally. I think this was the point of modules and is the way v2 is moving towards, right?

Anyway, thank you for your help.

sradevski commented 4 months ago

@Niblu yes that's the idea of modules, and in v2 all of this is a lot more structured and easier to build I'd say. I think you probably want to go with a plugin for v1: https://docs.medusajs.com/development/plugins/create

Anyway, feel free to reach out if you get stuck anywhere else. I'll close the ticket in the meantime.