Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support cjs and esm both by tshy #34

Merged
merged 9 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Comment on lines +24 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add dual module format support to requirements

The requirements section should mention the dual module format support (ESM/CommonJS).

 ## Requirements

 - egg >= 4.x
+- Supports both ESM and CommonJS module formats
+- Node.js >= 18.19.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Requirements
- egg >= 4.x
## Requirements
- egg >= 4.x
- Supports both ESM and CommonJS module formats
- Node.js >= 18.19.0

## 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
Loading