帮助开发者构建 React 微前端架构,并实现共享依赖、动态表单与状态管理。
该技能材料显示为纯提示/模式文档,未要求密钥、未声明运行代码或直接访问外部端点,整体风险较低。需注意其示例涉及浏览器本地存储与从 esm.sh 加载前端依赖,这属于实现层面的常规注意事项而非直接高风险信号。
材料明确注明无需密钥或环境变量;README 也未出现令牌申请、凭证注入或凭证外传设计。
系统检查项标记为无远程端点,且该技能本身为 prompt-only。README 仅在示例中提到通过 import map 从 esm.sh 获取 React 前端模块,这是架构示例,不构成该技能自身声明的数据外发通道。
作为纯文档/提示型技能,材料未声明会在本机启动进程、执行脚本或调用系统能力;内容主要是 React/Vite 模式说明。
未声明读取或写入宿主文件、数据库或其他受保护资源。README 中提到 localStorage sync 属于前端实现示例,反映浏览器侧持久化思路,不表示该技能直接获得额外数据访问权限。
来源为 GitHub 上的开源仓库,具备可审计性,这明显降低风险;但仓库 star 为 0、许可证未声明、维护状态未知,且 README 示例依赖第三方 CDN/包源 esm.sh,供应链成熟度与长期维护性仍需留意。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "react-microfrontend-patterns" 技能: 1. 下载 https://raw.githubusercontent.com/microsoft/amplifier-bundle-skills/main/skills/react-microfrontend-patterns/SKILL.md 2. 保存为 ~/.claude/skills/react-microfrontend-patterns/SKILL.md 3. 装好后重载技能,告诉我可以用了
我正在开发一个 React 微前端系统,需要通过 import maps 动态加载多个独立 bundle,并确保它们共享同一个 React 实例。请给我一个推荐架构方案,包括模块加载、依赖共享、版本控制和部署注意事项。
一份清晰的 React 微前端架构建议,说明动态加载、共享依赖和部署策略。
请帮我设计一个基于 schema 的 React 动态表单方案,要求支持字段联动、校验规则、异步选项加载,并适合集成到微前端应用中。
一套可落地的动态表单设计思路,包含 schema 结构、渲染逻辑与扩展建议。
我想在 React 微前端项目中使用 Zustand 和 localStorage 管理用户偏好与缓存状态,请给我一个状态切分方案,并说明如何避免不同子应用之间的数据冲突。
一份 Zustand 状态管理与本地持久化方案,重点说明命名空间、同步和冲突规避。
Problem: You have multiple independently-built UI bundles that must share React at runtime, a form system driven by server-side schemas that change dynamically, and state that needs to persist in the browser and sync across tabs.
Approach: Import maps with Vite's rollupOptions.external for shared React, a useFrecency hook with exponential decay scoring, schema-to-React rendering with action-triggered schema refinement, and Zustand stores with localStorage sync.
Pattern proven in production across multiple React frontends and web services.
rollupOptions.external for shared ReactWhen multiple independently-built bundles run on the same page, each gets its own copy of React. This causes the "dual React instance" bug: hooks break because the React instance that rendered the component is different from the one providing useState.
The fix: externalize React in every bundle's Vite config and provide it via an import map in the HTML:
<!-- index.html -->
<script type="importmap">
{
"imports": {
"react": "https://esm.sh/[email protected]",
"react-dom": "https://esm.sh/[email protected]",
"react-dom/client": "https://esm.sh/[email protected]/client",
"react/jsx-runtime": "https://esm.sh/[email protected]/jsx-runtime"
}
}
</script>
// vite.config.ts
export default defineConfig({
build: {
rollupOptions: {
external: ['react', 'react-dom', 'react-dom/client', 'react/jsx-runtime'],
},
},
})
Vite's dev server ignores browser import maps — it pre-bundles CJS modules and serves them from /.vite/deps/. This means dynamically-loaded bundles that use bare import React from 'react' will resolve via the import map to a different React instance than the host app.
Solutions: Use @vitejs/plugin-react with careful configuration, or write a custom Vite plugin that serves shim modules redirecting bare specifiers to Vite's pre-bundled paths during dev. This is inherently complex — consult your Vite config documentation for the specifics of your setup.
Frecency (frequency + recency) ranks autocomplete results by how often AND how recently a user selected them:
// hooks/useFrecency.ts
const DECAY_HALF_LIFE_MS = 7 * 24 * 60 * 60 * 1000 // 1-week half-life
const STORAGE_KEY = 'frecency-data'
const _suggestionCache = new Map<string, string[]>() // module-level perf cache
interface FrecencyEntry {
score: number
lastUsed: number // timestamp ms
}
function computeScore(entry: FrecencyEntry, now: number): number {
const ageFraction = (now - entry.lastUsed) / DECAY_HALF_LIFE_MS
return entry.score * Math.pow(0.5, ageFraction)
}
function useFrecency(namespace: string) {
const [entries, setEntries] = useState<Record<string, FrecencyEntry>>(() => {
const stored = localStorage.getItem(`${STORAGE_KEY}:${namespace}`)
return stored ? JSON.parse(stored) : {}
})
const getSuggestions = useCallback((fieldKey: string, allValues: string[]) => {
const cacheKey = `${namespace}:${fieldKey}`
if (_suggestionCache.has(cacheKey)) return _suggestionCache.get(cacheKey)!
const now = Date.now()
const sorted = [...allValues].sort((a, b) => {
const sa = entries[a] ? computeScore(entries[a], now) : 0
const sb = entries[b] ? computeScore(entries[b], now) : 0
return sb - sa
})
_suggestionCache.set(cacheKey, sorted)
return sorted
}, [namespace, entries])
const recordValue = useCallback((fieldKey: string, value: string) => {
_suggestionCache.clear()
setEntries(prev => {
const now = Date.now()
const existing = prev[value] ?? { score: 0, lastUsed: now }
const updated = { ...prev, [value]: { score: existing.score + 1, lastUsed: now } }
…
帮助你调研、规划并并行执行大规模代码变更,让多个代理分别提交 PR。
用多模型视觉能力分析图片内容、提取文字并回答图像相关问题。
帮助开发者设计安全持久的配置与状态文件管理模式,兼顾默认值合并和崩溃恢复。
以资深工程师视角审视架构、遗留重构与工具选型,给出务实建议。
帮助开发与运维设计兼顾本地顺畅和远程安全的认证与 TLS 接入方案。
帮助开发者设计易安装、易扩展且配置分层清晰的 CLI 工具模式。
帮助你梳理 React 与 Next.js 前端模式、状态管理及性能优化最佳实践
帮助开发者为 React 与 Next.js 交互界面实现无障碍设计与可用性优化。
帮助你编写或审查符合 React 18/19 最佳实践的组件与架构。
帮助你在编写、审查或重构 React/Next.js 代码时系统优化性能。
提供适用于 React/Next.js 的高质量动画模式,快速实现常见交互动效。
帮助你为 React/Next.js 产品实现可复用的界面动效与过渡方案。