feat!: migrate all packages to ES modules
BREAKING CHANGE: All shared packages now export ES modules instead of CommonJS - Changed TypeScript compilation target from commonjs to ES2020 - Updated packages/config/tsconfig/node.json module format - Updated packages/types/tsconfig.json with moduleResolution - All packages (@goodgo/types, @goodgo/http-client, @goodgo/logger, @goodgo/auth-sdk, @goodgo/tracing) now output ES modules - Updated README.md and README.vi.md with migration guide Migration required: - Replace any require() statements with import - Clean and rebuild packages after pulling changes Closes: Module format mismatch errors in Next.js build
This commit is contained in:
35
README.md
35
README.md
@@ -52,6 +52,41 @@ This monorepo follows a microservices architecture pattern with:
|
||||
└── docs/ # Documentation
|
||||
```
|
||||
|
||||
## ⚠️ Breaking Changes
|
||||
|
||||
### v1.0.0 - Module Format Migration (2026-01-07)
|
||||
|
||||
**BREAKING**: All shared packages now use ES modules instead of CommonJS.
|
||||
|
||||
**What Changed:**
|
||||
- TypeScript compilation target changed from `commonjs` to `ES2020`
|
||||
- All packages (`@goodgo/types`, `@goodgo/http-client`, `@goodgo/logger`, `@goodgo/auth-sdk`, `@goodgo/tracing`) now export ES modules
|
||||
- `package.json` files already declared `"type": "module"`, now TypeScript output matches
|
||||
|
||||
**Migration Required:**
|
||||
If you have existing code importing these packages:
|
||||
|
||||
```typescript
|
||||
// ✅ This still works (no changes needed for most cases)
|
||||
import { UserResponse } from '@goodgo/types';
|
||||
import { createHttpClient } from '@goodgo/http-client';
|
||||
|
||||
// ⚠️ If you were using require() (CommonJS), you must update:
|
||||
// ❌ OLD: const { UserResponse } = require('@goodgo/types');
|
||||
// ✅ NEW: import { UserResponse } from '@goodgo/types';
|
||||
```
|
||||
|
||||
**Action Required:**
|
||||
1. Pull latest changes
|
||||
2. Clean and rebuild: `pnpm -r --filter "./packages/*" run clean && pnpm build`
|
||||
3. Update any CommonJS `require()` statements to ES `import`
|
||||
|
||||
**Files Changed:**
|
||||
- `packages/config/tsconfig/node.json` - Changed `"module": "commonjs"` → `"module": "ES2020"`
|
||||
- `packages/types/tsconfig.json` - Added `"moduleResolution": "node"`
|
||||
|
||||
For detailed information, see [Migration Walkthrough](docs/en/guides/module-format-migration.md).
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
35
README.vi.md
35
README.vi.md
@@ -52,6 +52,41 @@ Monorepo này tuân theo mô hình kiến trúc microservices với:
|
||||
└── docs/ # Tài liệu
|
||||
```
|
||||
|
||||
## ⚠️ Thay Đổi Quan Trọng (Breaking Changes)
|
||||
|
||||
### v1.0.0 - Di chuyển sang ES Modules (2026-01-07)
|
||||
|
||||
**BREAKING**: Tất cả shared packages hiện sử dụng ES modules thay vì CommonJS.
|
||||
|
||||
**Những gì đã thay đổi:**
|
||||
- Đích compile của TypeScript đã đổi từ `commonjs` sang `ES2020`
|
||||
- Tất cả packages (`@goodgo/types`, `@goodgo/http-client`, `@goodgo/logger`, `@goodgo/auth-sdk`, `@goodgo/tracing`) hiện xuất ra ES modules
|
||||
- File `package.json` đã khai báo `"type": "module"`, giờ output TypeScript đã khớp
|
||||
|
||||
**Cần di chuyển code:**
|
||||
Nếu bạn có code hiện tại đang import các packages này:
|
||||
|
||||
```typescript
|
||||
// ✅ Cách này vẫn hoạt động (không cần thay đổi trong hầu hết trường hợp)
|
||||
import { UserResponse } from '@goodgo/types';
|
||||
import { createHttpClient } from '@goodgo/http-client';
|
||||
|
||||
// ⚠️ Nếu bạn đang dùng require() (CommonJS), bạn phải cập nhật:
|
||||
// ❌ CŨ: const { UserResponse } = require('@goodgo/types');
|
||||
// ✅ MỚI: import { UserResponse } from '@goodgo/types';
|
||||
```
|
||||
|
||||
**Hành động cần thiết:**
|
||||
1. Pull code mới nhất
|
||||
2. Clean và rebuild: `pnpm -r --filter "./packages/*" run clean && pnpm build`
|
||||
3. Cập nhật mọi câu lệnh `require()` (CommonJS) thành `import` (ES)
|
||||
|
||||
**Files đã thay đổi:**
|
||||
- `packages/config/tsconfig/node.json` - Đổi `"module": "commonjs"` → `"module": "ES2020"`
|
||||
- `packages/types/tsconfig.json` - Thêm `"moduleResolution": "node"`
|
||||
|
||||
Để biết thông tin chi tiết, xem [Hướng dẫn Di chuyển](docs/vi/guides/module-format-migration.md).
|
||||
|
||||
## 🚀 Bắt đầu
|
||||
|
||||
### Yêu cầu tiên quyết
|
||||
|
||||
Reference in New Issue
Block a user