@jiangdyjp2/common 1.0.4 → 1.0.6

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.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
package/readme.txt CHANGED
@@ -50,3 +50,55 @@
50
50
  update src/index.ts:
51
51
  import './types/express.js';
52
52
 
53
+
54
+ (9) The core principle (very important)
55
+
56
+ Frameworks like express, react, vue, etc. should almost always be peerDependencies, not normal dependencies, in shared libraries.
57
+ This rule applies whether the package is yours or a 3rd-party package.
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
+