github medusajs/medusa v2.0.0-rc.3
Medusa 2.0 Release Candidate #3

latest releases: v2.0.0-rc.6, v2.0.0-rc.5, v2.0.0-rc.4...
4 days ago

Get started with a new project

To get started using the RC, run the following command:

npx create-medusa-app@rc

This command will create a new Medusa project with our redesigned admin and a 2.0-compatible Next.js storefront. The Medusa application and the Next.js storefront are separate projects in separate folders.

Update existing project

Ensure your Medusa dependencies in package.json are using the rc tag:

{
  "dependencies": {
    "@medusajs/admin-sdk": "rc",
    "@medusajs/framework": "rc",
    "@medusajs/medusa": "rc",
    "@medusajs/medusa-cli": "rc",
    ...
  }
}

To ensure an upgrade to a new version is completed correctly, run the following sequence of commands:

rm -rf node_modules
rm yarn.lock // or package-lock.json

yarn // If you are using yarn berry, you need to create the lock-file first

Highlights

Standalone builds

Warning

Breaking change

As part of our preparations for the official release, we have improved our build process by introducing standalone builds. Now, when you build your Medusa project, we compile it within the project and mimic the file structure in the build output, not just the src directory. Additionally, we are placing the build artifacts in .medusa in the server and admin folders for the backend and dashboard code, respectively.

Here's how the build output looks like

.medusa
├── server
│   ├── package.json
│   ├── yarn.lock
│   ├── medusa-config.js
│   ├── modules
│   │   ├── hello
│   │       ├── index.js
│   ├─── model
│   ├─── index.js
├── admin
│   ├── assets
│   ├── index.html
└── types

If you notice carefully, medusa-config.js, yarn.lock, and package.json is included in the build artifacts. We do so to create a standalone built application, something you can copy/paste to your server and run without relying on the original source code.

This results in small containers since you are not copying unnecessary files. Additionally, it clearly distinguishes between the development and production code. If you want to run the production server, then cd into the .medusa/server directory and run it from there.

Breaking changes (summarised):

  • Remove the dist and build folders. Instead, write them production artifacts within the .medusa directory as .medusa/admin and .medusa/server.
  • Change the output of the .medusa/server folder to mimic the root project structure.

Read more in the PR.

Module registration

Warning

Breaking change

We have cleaned up module registration in medusa-config.js to be consistent with the rest of the configuration. This means modules can now be passed as an array instead of an object:

// before

-modules: {
-  custom: {
-    resolve: "./modules/custom",
-      options: {
-      apiKey: "test",
-    },
-  },
-},
+modules: [
+ {
+    resolve:  "./modules/custom",
+    options: {
+      apiKey: "test",
+    },
+  },
+],

This is a backward-compatible change. The backward compatibility will be removed in the near future, so we recommend updating your medusa-config.js now.

With this change, we now default to using the key specificed in the module export to register the module in the dependency container.

For example, let's say you've built a custom module with the following export:

export default Module("my_custom_module", { ... } )

The registration key in the dependency container will be my_custom_module and is resolved as follows:

const service = req.scope.resolve("my_custom_module")

Breaking changes:

  • The import location changed for the following utils:
- import { MODULE_PACKAGE_NAMES } from "@medusajs/framework/modules-sdk
+ import { MODULE_PACKAGE_NAMES } from "@medusajs/framework/utils
  • The module registration key names have changed to be snake_cased instead of PascalCased:
- export const Modules = {
-   AUTH: "Auth",
-   CACHE: "Cache",
-   CART: "Cart",
-   CUSTOMER: "Customer",
-   EVENT_BUS: "EventBus",
...
- } as const
+ export const Modules = {
+   AUTH: "auth",
+   CACHE: "cache",
+   CART: "cart",
+   CUSTOMER: "customer",
+   EVENT_BUS: "event_bus",
...

The latter is only a breaking change if you have used raw strings to resolve modules from the dependency container.

Features

Bugs

Documentation

Chores

Other Changes

New Contributors

Full Changelog: v2.0.0-rc.2...v2.0.0-rc.3

Don't miss a new medusa release

NewReleases is sending notifications on new releases.