@jiangdyjp2/common 1.0.5 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import './types/express.js';
2
1
  export * from './errors/bad-request-error.js';
3
2
  export * from './errors/custom-error.js';
4
3
  export * from './errors/database-connection-error.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC"}
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import './types/express.js';
1
+ // import './types/express.js';
2
2
  export * from './errors/bad-request-error.js';
3
3
  export * from './errors/custom-error.js';
4
4
  export * from './errors/database-connection-error.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAE/B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jiangdyjp2/common",
3
- "version": "1.0.5",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -8,26 +8,28 @@
8
8
  "build/**/*"
9
9
  ],
10
10
  "scripts": {
11
- "clean": "del ./build/*",
12
- "build": "npm run clean && tsc",
13
- "pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
11
+ "clean": "rimraf build",
12
+ "build": "tsc",
13
+ "prepublishOnly": "npm run clean && npm run build",
14
+ "pub": "git add . && git commit -m \"release\" && npm version patch && npm publish"
14
15
  },
15
16
  "keywords": [],
16
17
  "author": "",
17
18
  "license": "ISC",
18
19
  "type": "module",
19
20
  "devDependencies": {
21
+ "@types/jsonwebtoken": "^9.0.10",
20
22
  "del-cli": "^7.0.0",
23
+ "rimraf": "^6.1.2",
21
24
  "typescript": "^5.9.3"
22
25
  },
23
26
  "peerDependencies": {
24
- "express": "^5.2.0",
25
- "@types/express": "^5.0.0",
27
+ "@types/cookie-session": "^2.0.0",
28
+ "@types/express": "^4.17.21 || ^5.0.0",
26
29
  "cookie-session": "^2.1.0",
27
- "@types/cookie-session": "^2.0.0"
30
+ "express": "^4.19.2 || ^5.2.0"
28
31
  },
29
32
  "dependencies": {
30
- "@types/jsonwebtoken": "^9.0.10",
31
33
  "express-validator": "^7.3.1",
32
34
  "jsonwebtoken": "^9.0.3"
33
35
  }
package/readme.txt CHANGED
@@ -56,3 +56,59 @@
56
56
  Frameworks like express, react, vue, etc. should almost always be peerDependencies, not normal dependencies, in shared libraries.
57
57
  This rule applies whether the package is yours or a 3rd-party package.
58
58
 
59
+
60
+ (10) use Vitest instead of using jest:
61
+
62
+ If you use Vitest, you do NOT need to compile @jiangdyjp2/common to CommonJS.
63
+ You can keep everything as ESM.
64
+ Why this works (key point)
65
+
66
+ Your current failure with Jest happens because:
67
+ @jiangdyjp2/common is ESM
68
+ Jest runs tests in CommonJS by default
69
+ Jest tries to require() this file:
70
+
71
+ import './types/express.js';
72
+ ^^^^^^
73
+ → 💥 boom
74
+
75
+ Why Vitest fixes this automatically
76
+ Vitest is built on Vite + native ESM:
77
+ Runs Node in ESM mode
78
+ Understands import in node_modules
79
+ No transpiling hacks
80
+ No transformIgnorePatterns
81
+ No ts-jest
82
+ No babel-jest
83
+
84
+ So this line is perfectly fine under Vitest:
85
+
86
+ import { currentUser } from '@jiangdyjp2/common';
87
+
88
+ (11) replace jest with vitest:
89
+
90
+ --Remove Jest-related packages
91
+ npm uninstall jest ts-jest @types/jest
92
+
93
+ --Install Vitest
94
+ npm install -D vitest
95
+
96
+ --Update package.json
97
+
98
+
99
+ (11) .d.ts files are types-only and are NEVER imported at runtime.
100
+
101
+ (12) rm -rf node_modules package-lock.json
102
+ npm install
103
+
104
+ (13)
105
+ ✅ Final checklist for @jiangdyjp2/common
106
+
107
+ ✔ No @types/* in dependencies
108
+ ✔ Express + cookie-session in peerDependencies
109
+ ✔ Only runtime JS libs in dependencies
110
+ ✔ Express augmentation in .d.ts
111
+ ✔ No runtime import of type files
112
+
113
+ (14) Libraries ( say @jiangdyjp2/common ) should never ship @types/* in dependencies
114
+