@dimina-kit/devkit 0.1.2-dev.20260706131625 → 0.1.2-dev.20260706154125
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/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/project-watcher.test.js +68 -0
- package/package.json +4 -4
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAgB,eAAe,EAAiB,MAAM,qBAAqB,CAAA;AAEvF,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAEpG,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AACxE,YAAY,EACX,oBAAoB,EACpB,2BAA2B,EAC3B,YAAY,EACZ,YAAY,GACZ,MAAM,6BAA6B,CAAA;AAYpC;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACzC,IAAI,CAAC,EAAE,2BAA2B,GAChC,oBAAoB,CAKtB;AAqDD,MAAM,WAAW,OAAO;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,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,MAAM,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,oFAAoF;IACpF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IACxC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;CACvC;AAuFD,wBAAsB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CA0JnF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EACpC,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GACrC;IAAE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAiEtD"}
|
package/dist/index.js
CHANGED
|
@@ -309,7 +309,13 @@ export function createProjectWatcher(projectPath, onChange, onWatcherError) {
|
|
|
309
309
|
// (rel starts with '..') must never be ignored.
|
|
310
310
|
if (!rel || rel.startsWith('..'))
|
|
311
311
|
return false;
|
|
312
|
-
|
|
312
|
+
// `node_modules` (any depth) is excluded like vite/webpack exclude
|
|
313
|
+
// it: the compiler never reads it directly (its real npm input is
|
|
314
|
+
// the built `miniprogram_npm/`, which stays watched), while watching
|
|
315
|
+
// it makes chokidar hold thousands of per-directory fs.watch handles
|
|
316
|
+
// — a multi-second `watcher.close()` on session close, a slow
|
|
317
|
+
// initial scan, and spurious rebuilds on dependency churn.
|
|
318
|
+
return rel.split('/').some(seg => seg.startsWith('.') || seg === 'node_modules');
|
|
313
319
|
},
|
|
314
320
|
persistent: true,
|
|
315
321
|
ignoreInitial: true,
|
|
@@ -186,4 +186,72 @@ describe('createProjectWatcher', () => {
|
|
|
186
186
|
await settle(500);
|
|
187
187
|
expect(onChange).not.toHaveBeenCalled();
|
|
188
188
|
});
|
|
189
|
+
it('stays quiet when a file inside node_modules changes', async () => {
|
|
190
|
+
// Why this matters: a project with 87 dependencies puts chokidar under
|
|
191
|
+
// watch for 1232+ directories inside node_modules, making close() take
|
|
192
|
+
// seconds and letting dependency-internal file churn (postinstall
|
|
193
|
+
// scripts, lockfile-driven reinstalls) trigger spurious rebuilds.
|
|
194
|
+
// node_modules anywhere under the project — not just at the root — must
|
|
195
|
+
// be excluded from the watch entirely.
|
|
196
|
+
const nodeModulesDir = path.join(tempDir, 'node_modules', 'lodash');
|
|
197
|
+
fs.mkdirSync(nodeModulesDir, { recursive: true });
|
|
198
|
+
const target = path.join(nodeModulesDir, 'index.js');
|
|
199
|
+
fs.writeFileSync(target, '// vendored');
|
|
200
|
+
const onChange = vi.fn();
|
|
201
|
+
handle = createProjectWatcher(tempDir, onChange);
|
|
202
|
+
await handle.ready;
|
|
203
|
+
fs.writeFileSync(target, '// vendored, changed');
|
|
204
|
+
await settle(500);
|
|
205
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
206
|
+
});
|
|
207
|
+
it('stays quiet when a file inside a nested package node_modules changes', async () => {
|
|
208
|
+
// Why this matters: node_modules can recur at any depth (npm/pnpm
|
|
209
|
+
// dependency trees, workspace packages with their own node_modules).
|
|
210
|
+
// A watcher that only ignores the top-level node_modules segment would
|
|
211
|
+
// still get flooded by these nested trees.
|
|
212
|
+
const nestedNodeModules = path.join(tempDir, 'packages', 'a', 'node_modules', 'b');
|
|
213
|
+
fs.mkdirSync(nestedNodeModules, { recursive: true });
|
|
214
|
+
const target = path.join(nestedNodeModules, 'x.js');
|
|
215
|
+
fs.writeFileSync(target, '// nested vendored');
|
|
216
|
+
const onChange = vi.fn();
|
|
217
|
+
handle = createProjectWatcher(tempDir, onChange);
|
|
218
|
+
await handle.ready;
|
|
219
|
+
fs.writeFileSync(target, '// nested vendored, changed');
|
|
220
|
+
await settle(500);
|
|
221
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
222
|
+
});
|
|
223
|
+
it('fires onChange for changes inside miniprogram_npm', async () => {
|
|
224
|
+
// Why this matters: miniprogram_npm is the mini-app compiler's real
|
|
225
|
+
// input — the built npm output that the compiler reads directly, not a
|
|
226
|
+
// vendor tree to hide. A node_modules-ignoring rule that over-matches
|
|
227
|
+
// (e.g. any path segment containing "node_modules" as a substring, or a
|
|
228
|
+
// blanket "*npm*" pattern) would wrongly silence this directory too.
|
|
229
|
+
const npmDir = path.join(tempDir, 'miniprogram_npm', 'some-pkg');
|
|
230
|
+
fs.mkdirSync(npmDir, { recursive: true });
|
|
231
|
+
const target = path.join(npmDir, 'index.js');
|
|
232
|
+
fs.writeFileSync(target, '// built npm output');
|
|
233
|
+
const onChange = vi.fn();
|
|
234
|
+
handle = createProjectWatcher(tempDir, onChange);
|
|
235
|
+
await settle();
|
|
236
|
+
fs.writeFileSync(target, '// built npm output, changed');
|
|
237
|
+
await vi.waitFor(() => expect(onChange).toHaveBeenCalled(), { timeout: 2000 });
|
|
238
|
+
});
|
|
239
|
+
it('fires onChange for source edits when the project itself sits under an ancestor node_modules directory', async () => {
|
|
240
|
+
// Why this matters: same shape as the dotted-ancestor regression above —
|
|
241
|
+
// a project can legitimately live inside a node_modules directory (e.g.
|
|
242
|
+
// a demo/fixture project bundled inside a pnpm-installed package). Only
|
|
243
|
+
// node_modules segments *under* projectPath should be ignored; an
|
|
244
|
+
// ancestor node_modules segment must not disable the watch for the
|
|
245
|
+
// project's own source.
|
|
246
|
+
const ancestorNodeModules = path.join(tempDir, 'node_modules', 'some-demo-pkg');
|
|
247
|
+
const projectRoot = path.join(ancestorNodeModules, 'demo-app');
|
|
248
|
+
fs.mkdirSync(projectRoot, { recursive: true });
|
|
249
|
+
const target = path.join(projectRoot, 'app.json');
|
|
250
|
+
fs.writeFileSync(target, '{}');
|
|
251
|
+
const onChange = vi.fn();
|
|
252
|
+
handle = createProjectWatcher(projectRoot, onChange);
|
|
253
|
+
await settle();
|
|
254
|
+
fs.writeFileSync(target, '{"a":1}');
|
|
255
|
+
await vi.waitFor(() => expect(onChange).toHaveBeenCalled(), { timeout: 2000 });
|
|
256
|
+
});
|
|
189
257
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimina-kit/devkit",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.20260706154125",
|
|
4
4
|
"description": "Development toolkit for Dimina mini-apps with H5 container preview",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dimina",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"eslint": "^10.2.1",
|
|
54
54
|
"typescript": "5.9.2",
|
|
55
55
|
"vitest": "^4.1.4",
|
|
56
|
-
"@dimina-kit/
|
|
57
|
-
"@dimina-kit/
|
|
56
|
+
"@dimina-kit/typescript-config": "0.1.0",
|
|
57
|
+
"@dimina-kit/eslint-config": "0.1.0"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"axios": "^1.15.0",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"cors": "^2.8.6",
|
|
63
63
|
"express": "^5.2.1",
|
|
64
64
|
"open": "^11.0.0",
|
|
65
|
-
"@dimina-kit/compiler": "0.0.1-dev.
|
|
65
|
+
"@dimina-kit/compiler": "0.0.1-dev.20260706154125"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|