Skip to content

Commit

Permalink
feat: support cjs and esm both by tshy (#34)
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
fengmk2 authored Jan 11, 2025
1 parent 571b851 commit 7a63cd6
Show file tree
Hide file tree
Showing 43 changed files with 684 additions and 434 deletions.
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "eslint-config-egg"
"extends": [
"eslint-config-egg/typescript",
"eslint-config-egg/lib/rules/enforce-node-prefix"
]
}
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Node.js
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest'
version: '14, 16, 18, 20, 22'
os: 'macos-latest'
version: '18.19.0, 20, 22'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ node_modules/
coverage/
test/fixtures/**/run
.DS_Store
.tshy*
.eslintcache
dist
package-lock.json
.package-lock.json
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# egg-development
# @eggjs/development

[![NPM version][npm-image]][npm-url]
[![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)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[![Node.js Version](https://img.shields.io/node/v/egg-development.svg?style=flat)](https://nodejs.org/en/download/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)

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

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

`egg-development` has been built-in for egg. It is enabled by default.
`@eggjs/development` has been built-in for egg. It is enabled by default.

## Requirements

- egg >= 4.x

## Configuration

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

## Features

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

```js
// config/config.default.js
exports.development = {
// don't reload when ts fileChanged
// https://github.com/sindresorhus/multimatch
reloadPattern: ['**', '!**/*.ts'],
```ts
// config/config.default.ts
export default = {
development: {
// don't reload when css fileChanged
// https://github.com/sindresorhus/multimatch
reloadPattern: ['**', '!**/*.css'],
},
};
```

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

## Contributors

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

Made with [contributors-img](https://contrib.rocks).
96 changes: 0 additions & 96 deletions agent.js

This file was deleted.

7 changes: 0 additions & 7 deletions app.js

This file was deleted.

89 changes: 64 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "egg-development",
"name": "@eggjs/development",
"version": "3.0.2",
"publishConfig": {
"access": "public"
},
"description": "development tool for egg",
"eggPlugin": {
"name": "development",
Expand All @@ -9,7 +12,12 @@
],
"dependencies": [
"watcher"
]
],
"exports": {
"import": "./dist/esm",
"require": "./dist/commonjs",
"typescript": "./src"
}
},
"keywords": [
"egg",
Expand All @@ -18,42 +26,73 @@
"eggPlugin"
],
"dependencies": {
"debounce": "^1.1.0",
"@eggjs/core": "^6.2.11",
"debounce": "^2.2.0",
"multimatch": "^5.0.0",
"utility": "^2.4.0"
},
"devDependencies": {
"@types/node": "^22.10.2",
"egg": "3",
"egg-bin": "6",
"egg-mock": "5",
"@arethetypeswrong/cli": "^0.17.2",
"@eggjs/bin": "7",
"@eggjs/mock": "6",
"@eggjs/supertest": "8",
"@eggjs/tsconfig": "1",
"@types/mocha": "10",
"@types/node": "22",
"egg": "beta",
"eslint": "8",
"eslint-config-egg": "12",
"supertest": "^3.4.2"
"eslint-config-egg": "14",
"rimraf": "^6.0.1",
"tshy": "3",
"tshy-after": "1",
"typescript": "5"
},
"engines": {
"node": ">=14.0.0"
"node": ">=18.19.0"
},
"scripts": {
"test": "npm run lint -- --fix && npm run test-local",
"test-local": "egg-bin test --ts false",
"cov": "egg-bin cov --ts false",
"lint": "eslint .",
"ci": "npm run lint && npm run cov"
"lint": "eslint --cache src test --ext .ts",
"pretest": "npm run clean && npm run lint -- --fix",
"test": "egg-bin test",
"preci": "npm run clean && npm run lint",
"ci": "egg-bin cov",
"postci": "npm run prepublishOnly && npm run clean",
"clean": "rimraf dist",
"prepublishOnly": "tshy && tshy-after && attw --pack"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eggjs/egg-development.git"
"url": "git+https://github.com/eggjs/development.git"
},
"files": [
"app",
"config",
"lib",
"agent.js",
"app.js"
],
"bugs": "https://github.com/eggjs/egg/issues",
"homepage": "https://github.com/eggjs/egg-development#readme",
"homepage": "https://github.com/eggjs/development#readme",
"author": "jtyjty99999",
"license": "MIT"
"license": "MIT",
"type": "module",
"tshy": {
"exports": {
".": "./src/index.ts",
"./package.json": "./package.json"
}
},
"exports": {
".": {
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
},
"./package.json": "./package.json"
},
"files": [
"dist",
"src"
],
"types": "./dist/commonjs/index.d.ts",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js"
}
Loading

0 comments on commit 7a63cd6

Please sign in to comment.