@jiangdyjp2/common 1.0.5 → 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 +0 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.txt +46 -0
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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
package/readme.txt
CHANGED
|
@@ -56,3 +56,49 @@
|
|
|
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
|
+
|