fix(wechat): deliver failure notices and hot-swappable wechat-mp bundle

Notify users when HTML publish guards reject stub pages instead of silently
failing, send real page links when non-stub files exist, and split wechat-mp
into wechat-mp.bundle.mjs for fast production updates without full portal rebuilds.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-04 12:52:59 +08:00
parent 5ed655b6c3
commit 6bc5d128d2
9 changed files with 327 additions and 116 deletions
+28
View File
@@ -0,0 +1,28 @@
import fs from 'node:fs';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { loadWechatMpConfig } from './wechat-mp-config.mjs';
export { loadWechatMpConfig };
let cachedModule = null;
let cachedTarget = '';
let cachedMtime = 0;
function resolveWechatMpEntry(root = process.cwd()) {
const bundlePath = path.join(root, 'wechat-mp.bundle.mjs');
if (fs.existsSync(bundlePath)) return bundlePath;
return path.join(root, 'wechat-mp.mjs');
}
export async function loadWechatMpModule(root = process.cwd()) {
const target = resolveWechatMpEntry(root);
const mtime = fs.statSync(target).mtimeMs;
if (cachedModule && cachedTarget === target && cachedMtime === mtime) {
return cachedModule;
}
cachedModule = await import(`${pathToFileURL(target).href}?v=${mtime}`);
cachedTarget = target;
cachedMtime = mtime;
return cachedModule;
}