MyGit

v2.0.0-rc.3

medusajs/medusa

版本发布时间: 2024-10-14 17:00:50

medusajs/medusa最新发布版本:v2.0.1(2024-10-25 23:24:21)

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):

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:

- import { MODULE_PACKAGE_NAMES } from "@medusajs/framework/modules-sdk
+ import { MODULE_PACKAGE_NAMES } from "@medusajs/framework/utils
- 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: https://github.com/medusajs/medusa/compare/v2.0.0-rc.2...v2.0.0-rc.3

相关地址:原始地址 下载(tar) 下载(zip)

查看:2024-10-14发行的版本