- 渲染管线迁移至 MetonaEditor 内置解析器,移除 unified/rehype 全家桶(9 个依赖) - 修复相对路径图片修复的目录前缀碰撞与路径解析 bug - ConfirmDialog/useConfirm/LoadingSpinner/useDocStats 移除,改用 MeToast.confirm/loading/promise - 新增状态栏(字数/行数/阅读时间/光标位置)、Zen 模式、数据备份导出导入 - Sqlark: 版本化迁移(addMigration/migrateTo)、subscribe 表变更、备份 exportAll/importTable - 数据库损坏自愈:异常退出残留残缺 SSTable 导致打开失败时自动重建 - 大纲导航改用 scrollToLine 官方 API - 修复 rollup 平台包互删(postinstall 自动补齐)+ 集成测试(fake-indexeddb)
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
/**
|
||
* 确保 rollup 当前平台的 optional 原生包已安装。
|
||
*
|
||
* 背景: npm bug #4828 导致跨平台共享 node_modules(如 WSL 与 Windows 挂载同一目录)时,
|
||
* 一方 npm install 可能清理掉另一方的 rollup 平台包(@rollup/rollup-<os>-x64-<libc>),
|
||
* 导致 build/test 报 "Cannot find module @rollup/rollup-<platform>"。
|
||
*
|
||
* 方案: 在 postinstall 阶段检测当前平台所需的 rollup 原生包,缺失则自动补装
|
||
* (--no-save 不污染依赖清单,--ignore-scripts 防止递归触发 postinstall)。
|
||
*/
|
||
import { execSync } from 'child_process'
|
||
import { existsSync } from 'fs'
|
||
import { join, dirname } from 'path'
|
||
import { fileURLToPath } from 'url'
|
||
|
||
const ROLLUP_VERSION = '4.60.4'
|
||
const __dirname = dirname(fileURLToPath(import.meta.url))
|
||
|
||
/** 平台 → 架构 → 对应 rollup 原生包 */
|
||
const PLATFORM_PACKAGES = {
|
||
win32: {
|
||
x64: '@rollup/rollup-win32-x64-msvc',
|
||
ia32: '@rollup/rollup-win32-ia32-msvc',
|
||
arm64: '@rollup/rollup-win32-arm64-msvc',
|
||
},
|
||
linux: {
|
||
x64: '@rollup/rollup-linux-x64-gnu',
|
||
arm64: '@rollup/rollup-linux-arm64-gnu',
|
||
arm: '@rollup/rollup-linux-arm-gnueabihf',
|
||
},
|
||
darwin: {
|
||
x64: '@rollup/rollup-darwin-x64',
|
||
arm64: '@rollup/rollup-darwin-arm64',
|
||
},
|
||
}
|
||
|
||
const pkg = PLATFORM_PACKAGES[process.platform]?.[process.arch]
|
||
if (!pkg) {
|
||
process.exit(0)
|
||
}
|
||
|
||
const pkgDir = join(__dirname, '..', 'node_modules', ...pkg.split('/'))
|
||
if (existsSync(pkgDir)) {
|
||
process.exit(0)
|
||
}
|
||
|
||
try {
|
||
execSync(`npm install --no-save --ignore-scripts ${pkg}@${ROLLUP_VERSION}`, {
|
||
stdio: 'inherit',
|
||
cwd: join(__dirname, '..'),
|
||
})
|
||
} catch (err) {
|
||
// eslint-disable-next-line no-console -- 安装失败仅告警,不阻断 npm install
|
||
console.warn(`[ensure-rollup-platform] 自动安装 ${pkg} 失败:`, err)
|
||
}
|