Skip to content

Commit 7a63cd6

Browse files
authored
feat: support cjs and esm both by tshy (#34)
BREAKING CHANGE: drop Node.js < 18.19.0 support part of eggjs/egg#3644 eggjs/egg#5257 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit Based on the comprehensive changes, here are the release notes: ## Release Notes for @eggjs/development - **New Features** - Added TypeScript support for development environment - Enhanced file watching and reloading mechanisms - Improved configuration options for development mode - **Breaking Changes** - Migrated from `egg-development` to `@eggjs/development` - Requires Node.js version >=18.19.0 - Dropped support for Node.js 14 and 16 - **Improvements** - Refined ESLint configuration - Updated GitHub Actions workflow to focus on macOS testing - Added more robust file change detection - Enhanced type safety across the project - **Bug Fixes** - Improved handling of file reloading in different scenarios - Fixed potential issues with asset and service file monitoring - **Chores** - Updated dependencies - Migrated test suite to TypeScript - Restructured project configuration <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 571b851 commit 7a63cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+684
-434
lines changed

.eslintrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "eslint-config-egg"
2+
"extends": [
3+
"eslint-config-egg/typescript",
4+
"eslint-config-egg/lib/rules/enforce-node-prefix"
5+
]
36
}

.github/workflows/nodejs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: Node.js
1212
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1313
with:
14-
os: 'ubuntu-latest, macos-latest'
15-
version: '14, 16, 18, 20, 22'
14+
os: 'macos-latest'
15+
version: '18.19.0, 20, 22'
1616
secrets:
1717
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ node_modules/
44
coverage/
55
test/fixtures/**/run
66
.DS_Store
7+
.tshy*
8+
.eslintcache
9+
dist
10+
package-lock.json
11+
.package-lock.json

README.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# egg-development
1+
# @eggjs/development
22

33
[![NPM version][npm-image]][npm-url]
44
[![Node.js CI](https://github.com/eggjs/egg-development/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-development/actions/workflows/nodejs.yml)
55
[![Test coverage][codecov-image]][codecov-url]
66
[![Known Vulnerabilities][snyk-image]][snyk-url]
77
[![npm download][download-image]][download-url]
88
[![Node.js Version](https://img.shields.io/node/v/egg-development.svg?style=flat)](https://nodejs.org/en/download/)
9+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
910

1011
[npm-image]: https://img.shields.io/npm/v/egg-development.svg?style=flat-square
1112
[npm-url]: https://npmjs.org/package/egg-development
@@ -18,11 +19,15 @@
1819

1920
This is an egg plugin for local development, under development environment enabled by default, and closed under other environment.
2021

21-
`egg-development` has been built-in for egg. It is enabled by default.
22+
`@eggjs/development` has been built-in for egg. It is enabled by default.
23+
24+
## Requirements
25+
26+
- egg >= 4.x
2227

2328
## Configuration
2429

25-
see [config/config.default.js](https://github.com/eggjs/egg-development/blob/master/config/config.default.js) for more detail.
30+
see [config/config.default.ts](https://github.com/eggjs/egg-development/blob/master/src/config/config.default.ts) for more detail.
2631

2732
## Features
2833

@@ -52,12 +57,14 @@ Under the following directory (including subdirectories) will ignore file change
5257
5358
Developer can use `config.reloadPattern`([multimatch](https://github.com/sindresorhus/multimatch)) to control whether to reload.
5459

55-
```js
56-
// config/config.default.js
57-
exports.development = {
58-
// don't reload when ts fileChanged
59-
// https://github.com/sindresorhus/multimatch
60-
reloadPattern: ['**', '!**/*.ts'],
60+
```ts
61+
// config/config.default.ts
62+
export default = {
63+
development: {
64+
// don't reload when css fileChanged
65+
// https://github.com/sindresorhus/multimatch
66+
reloadPattern: ['**', '!**/*.css'],
67+
},
6168
};
6269
```
6370

@@ -75,6 +82,6 @@ Please open an issue [here](https://github.com/eggjs/egg/issues).
7582

7683
## Contributors
7784

78-
[![Contributors](https://contrib.rocks/image?repo=eggjs/egg-development)](https://github.com/eggjs/egg-development/graphs/contributors)
85+
[![Contributors](https://contrib.rocks/image?repo=eggjs/development)](https://github.com/eggjs/development/graphs/contributors)
7986

8087
Made with [contributors-img](https://contrib.rocks).

agent.js

-96
This file was deleted.

app.js

-7
This file was deleted.

package.json

+64-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
2-
"name": "egg-development",
2+
"name": "@eggjs/development",
33
"version": "3.0.2",
4+
"publishConfig": {
5+
"access": "public"
6+
},
47
"description": "development tool for egg",
58
"eggPlugin": {
69
"name": "development",
@@ -9,7 +12,12 @@
912
],
1013
"dependencies": [
1114
"watcher"
12-
]
15+
],
16+
"exports": {
17+
"import": "./dist/esm",
18+
"require": "./dist/commonjs",
19+
"typescript": "./src"
20+
}
1321
},
1422
"keywords": [
1523
"egg",
@@ -18,42 +26,73 @@
1826
"eggPlugin"
1927
],
2028
"dependencies": {
21-
"debounce": "^1.1.0",
29+
"@eggjs/core": "^6.2.11",
30+
"debounce": "^2.2.0",
2231
"multimatch": "^5.0.0",
2332
"utility": "^2.4.0"
2433
},
2534
"devDependencies": {
26-
"@types/node": "^22.10.2",
27-
"egg": "3",
28-
"egg-bin": "6",
29-
"egg-mock": "5",
35+
"@arethetypeswrong/cli": "^0.17.2",
36+
"@eggjs/bin": "7",
37+
"@eggjs/mock": "6",
38+
"@eggjs/supertest": "8",
39+
"@eggjs/tsconfig": "1",
40+
"@types/mocha": "10",
41+
"@types/node": "22",
42+
"egg": "beta",
3043
"eslint": "8",
31-
"eslint-config-egg": "12",
32-
"supertest": "^3.4.2"
44+
"eslint-config-egg": "14",
45+
"rimraf": "^6.0.1",
46+
"tshy": "3",
47+
"tshy-after": "1",
48+
"typescript": "5"
3349
},
3450
"engines": {
35-
"node": ">=14.0.0"
51+
"node": ">=18.19.0"
3652
},
3753
"scripts": {
38-
"test": "npm run lint -- --fix && npm run test-local",
39-
"test-local": "egg-bin test --ts false",
40-
"cov": "egg-bin cov --ts false",
41-
"lint": "eslint .",
42-
"ci": "npm run lint && npm run cov"
54+
"lint": "eslint --cache src test --ext .ts",
55+
"pretest": "npm run clean && npm run lint -- --fix",
56+
"test": "egg-bin test",
57+
"preci": "npm run clean && npm run lint",
58+
"ci": "egg-bin cov",
59+
"postci": "npm run prepublishOnly && npm run clean",
60+
"clean": "rimraf dist",
61+
"prepublishOnly": "tshy && tshy-after && attw --pack"
4362
},
4463
"repository": {
4564
"type": "git",
46-
"url": "git+https://github.com/eggjs/egg-development.git"
65+
"url": "git+https://github.com/eggjs/development.git"
4766
},
48-
"files": [
49-
"app",
50-
"config",
51-
"lib",
52-
"agent.js",
53-
"app.js"
54-
],
5567
"bugs": "https://github.com/eggjs/egg/issues",
56-
"homepage": "https://github.com/eggjs/egg-development#readme",
68+
"homepage": "https://github.com/eggjs/development#readme",
5769
"author": "jtyjty99999",
58-
"license": "MIT"
70+
"license": "MIT",
71+
"type": "module",
72+
"tshy": {
73+
"exports": {
74+
".": "./src/index.ts",
75+
"./package.json": "./package.json"
76+
}
77+
},
78+
"exports": {
79+
".": {
80+
"import": {
81+
"types": "./dist/esm/index.d.ts",
82+
"default": "./dist/esm/index.js"
83+
},
84+
"require": {
85+
"types": "./dist/commonjs/index.d.ts",
86+
"default": "./dist/commonjs/index.js"
87+
}
88+
},
89+
"./package.json": "./package.json"
90+
},
91+
"files": [
92+
"dist",
93+
"src"
94+
],
95+
"types": "./dist/commonjs/index.d.ts",
96+
"main": "./dist/commonjs/index.js",
97+
"module": "./dist/esm/index.js"
5998
}

0 commit comments

Comments
 (0)