@gadmin2n/schematics 0.0.131 → 0.0.133

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.
@@ -1,6 +1,6 @@
1
1
  import * as jwt from 'jsonwebtoken';
2
- import * as request from 'request';
3
2
  import { URLSearchParams } from 'url';
3
+ const request = require('request'); //改成import,SWC编译会将其包装为命名空间对象导致调用报错
4
4
 
5
5
  export type TaiHuTokenInfo = {
6
6
  access_token: string;
@@ -13,7 +13,9 @@ module.exports = {
13
13
  // NODE_OPTIONS 保留原 package.json 里的 4GB 上限设置。
14
14
  node_args: '--max-old-space-size=4096',
15
15
  env: {
16
- ...(process.env.VITE_BRANCH_OWNER ? { VITE_BRANCH_OWNER: process.env.VITE_BRANCH_OWNER } : {}),
16
+ ...(process.env.VITE_BRANCH_OWNER
17
+ ? { VITE_BRANCH_OWNER: process.env.VITE_BRANCH_OWNER }
18
+ : {}),
17
19
  },
18
20
  },
19
21
  ],
@@ -81,6 +81,7 @@
81
81
  "dev": "NODE_OPTIONS='--max-old-space-size=4096' vite --port 3000",
82
82
  "build": "tsc && vite build",
83
83
  "preview": "vite preview",
84
+ "typecheck": "tsc --noEmit",
84
85
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx}\"",
85
86
  "lint": "eslint \"src/**/*.{ts,tsx}\"",
86
87
  "prepare": "cd .. && husky install || true"
@@ -5,8 +5,15 @@ import tsconfigPaths from 'vite-tsconfig-paths';
5
5
  import { devShellPlugin } from './src/plugins/devShellPlugin';
6
6
 
7
7
  // gadmin g prisma 生成完毕后触发:CLI 会 touch 本文件,
8
- // 插件监听变更后调用 server.restart() —— 清空 module graph 释放内存,
9
- // 并通过 HMR ws 广播 full-reload,浏览器自动刷新。
8
+ // 插件监听变更后 invalidate module graph 并广播 full-reload。
9
+ //
10
+ // 历史:曾用 server.restart(),每次会重新 esbuild bundle 一次 vite.config.ts
11
+ // 及其依赖,旧 config module 被 v8 保留,实测每次泄漏 15~20MB rss,
12
+ // 几十次调用后进程内存从 60MB 涨到 600MB+。
13
+ //
14
+ // 改用 moduleGraph.invalidateAll() + hot full-reload:
15
+ // - invalidateAll() 只清 transform 结果,不重载 config、不重跑 esbuild
16
+ // - full-reload 让浏览器重新请求,vite 按最新文件重新 transform
10
17
  function gadminRestartPlugin(): Plugin {
11
18
  const sentinel = path.resolve(__dirname, '.vite-restart');
12
19
  return {
@@ -16,10 +23,11 @@ function gadminRestartPlugin(): Plugin {
16
23
  server.watcher.on('change', (file) => {
17
24
  if (path.resolve(file) === sentinel) {
18
25
  server.config.logger.info(
19
- '[gadmin] generated code changed, restarting vite...',
26
+ '[gadmin] generated code changed, invalidating & full-reload...',
20
27
  { timestamp: true },
21
28
  );
22
- server.restart();
29
+ server.moduleGraph.invalidateAll();
30
+ server.hot.send({ type: 'full-reload', path: '*' });
23
31
  }
24
32
  });
25
33
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gadmin2n/schematics",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "description": "Gadmin - modern, fast, powerful node.js web framework (@schematics)",
5
5
  "main": "dist/index.js",
6
6
  "files": [