[{"data":1,"prerenderedAt":2628},["ShallowReactive",2],{"article-/topics/frontend/frontend-2027-trends-outlook":3,"related-frontend":406,"content-query-3xnsS5sOxl":2330},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":12,"image":18,"imageQuery":19,"pexelsPhotoId":20,"pexelsUrl":21,"featured":6,"readingTime":22,"body":23,"_type":400,"_id":401,"_source":402,"_file":403,"_stem":404,"_extension":405},"/topics/frontend/frontend-2027-trends-outlook","frontend",false,"","2027 前端技术趋势展望：真正值得关注的不是新名词，而是边界继续重组","展望 2027 年，前端技术最值得关注的不是更花哨的工具，而是运行时边界、AI 协作方式、可观测性和交付链路的进一步重组。本文给出一份更偏工程视角的趋势判断。","2026-05-01","HTMLPAGE 团队",[13,14,15,16,17],"Frontend Trends",2027,"Engineering Strategy","AI Workflow","Architecture","/images/topics/frontend/frontend-2027-trends-outlook.jpg","future technology planning dashboard on laptop",27141314,"https://www.pexels.com/photo/touchscreen-of-modern-device-27141314/",17,{"type":24,"children":25,"toc":387},"root",[26,34,49,54,61,66,89,94,99,104,122,127,133,138,156,161,167,172,177,195,200,206,211,216,234,239,245,250,255,264,269,275,280,303,308,313,341,346,351,356],{"type":27,"tag":28,"props":29,"children":30},"element","p",{},[31],{"type":32,"value":33},"text","预测前端趋势很容易滑向两种极端：",{"type":27,"tag":35,"props":36,"children":37},"ul",{},[38,44],{"type":27,"tag":39,"props":40,"children":41},"li",{},[42],{"type":32,"value":43},"把每个新名词都当成下一代基础设施",{"type":27,"tag":39,"props":45,"children":46},{},[47],{"type":32,"value":48},"或者把所有趋势都当成营销噪音",{"type":27,"tag":28,"props":50,"children":51},{},[52],{"type":32,"value":53},"更有效的判断方式，是看哪些变化会真实影响团队的工程边界、交付流程和维护成本。",{"type":27,"tag":55,"props":56,"children":58},"h2",{"id":57},"_2027-年最重要的主题仍然会是边界重组",[59],{"type":32,"value":60},"2027 年最重要的主题，仍然会是“边界重组”",{"type":27,"tag":28,"props":62,"children":63},{},[64],{"type":32,"value":65},"过去几年里，前端边界已经发生多次变化：",{"type":27,"tag":35,"props":67,"children":68},{},[69,74,79,84],{"type":27,"tag":39,"props":70,"children":71},{},[72],{"type":32,"value":73},"UI 与数据层的边界在改变",{"type":27,"tag":39,"props":75,"children":76},{},[77],{"type":32,"value":78},"客户端与服务端的分工在调整",{"type":27,"tag":39,"props":80,"children":81},{},[82],{"type":32,"value":83},"组件开发与内容系统的关系在重构",{"type":27,"tag":39,"props":85,"children":86},{},[87],{"type":32,"value":88},"AI 工具与开发者工作流开始混合",{"type":27,"tag":28,"props":90,"children":91},{},[92],{"type":32,"value":93},"2027 年这一趋势不会减弱，反而会继续深化。",{"type":27,"tag":55,"props":95,"children":97},{"id":96},"运行时边界会继续前移",[98],{"type":32,"value":96},{"type":27,"tag":28,"props":100,"children":101},{},[102],{"type":32,"value":103},"未来一年，前端团队仍然会更多讨论：",{"type":27,"tag":35,"props":105,"children":106},{},[107,112,117],{"type":27,"tag":39,"props":108,"children":109},{},[110],{"type":32,"value":111},"哪些逻辑留在客户端",{"type":27,"tag":39,"props":113,"children":114},{},[115],{"type":32,"value":116},"哪些更适合服务端或边缘完成",{"type":27,"tag":39,"props":118,"children":119},{},[120],{"type":32,"value":121},"哪些结果可以预计算或缓存",{"type":27,"tag":28,"props":123,"children":124},{},[125],{"type":32,"value":126},"这不只是性能问题，更是复杂度治理问题。前移得越多，越要有更清晰的日志、监控和回滚能力。",{"type":27,"tag":55,"props":128,"children":130},{"id":129},"ai-不会替代前端但会持续改变任务组织方式",[131],{"type":32,"value":132},"AI 不会替代前端，但会持续改变任务组织方式",{"type":27,"tag":28,"props":134,"children":135},{},[136],{"type":32,"value":137},"2027 年最有可能继续变化的，不是“AI 能不能写页面”，而是：",{"type":27,"tag":35,"props":139,"children":140},{},[141,146,151],{"type":27,"tag":39,"props":142,"children":143},{},[144],{"type":32,"value":145},"需求拆解是否更依赖结构化上下文",{"type":27,"tag":39,"props":147,"children":148},{},[149],{"type":32,"value":150},"测试、修复、文档和评审是否会更紧密联动",{"type":27,"tag":39,"props":152,"children":153},{},[154],{"type":32,"value":155},"开发者是否会从“直接写实现”转向“先定义约束与验证”",{"type":27,"tag":28,"props":157,"children":158},{},[159],{"type":32,"value":160},"也就是说，AI 更可能重写工作流，而不是简单替代工程判断。",{"type":27,"tag":55,"props":162,"children":164},{"id":163},"可观测性会成为前端默认配置而不是后补模块",[165],{"type":32,"value":166},"可观测性会成为前端默认配置，而不是后补模块",{"type":27,"tag":28,"props":168,"children":169},{},[170],{"type":32,"value":171},"越来越多团队已经认识到，只看构建成功和页面可打开远远不够。",{"type":27,"tag":28,"props":173,"children":174},{},[175],{"type":32,"value":176},"2027 年前端可观测性更可能继续下沉成默认能力，包括：",{"type":27,"tag":35,"props":178,"children":179},{},[180,185,190],{"type":27,"tag":39,"props":181,"children":182},{},[183],{"type":32,"value":184},"发布版本与用户问题的快速关联",{"type":27,"tag":39,"props":186,"children":187},{},[188],{"type":32,"value":189},"页面性能和交互异常的自动归因",{"type":27,"tag":39,"props":191,"children":192},{},[193],{"type":32,"value":194},"实验、回归和错误的统一追踪",{"type":27,"tag":28,"props":196,"children":197},{},[198],{"type":32,"value":199},"谁能更快看见问题，谁就更有机会稳定迭代。",{"type":27,"tag":55,"props":201,"children":203},{"id":202},"组件与设计系统会更加平台化但也更强调节制",[204],{"type":32,"value":205},"组件与设计系统会更加平台化，但也更强调节制",{"type":27,"tag":28,"props":207,"children":208},{},[209],{"type":32,"value":210},"前几年大量团队都在建设设计系统，未来一年更值得注意的是“系统治理”而不是“组件数量”。",{"type":27,"tag":28,"props":212,"children":213},{},[214],{"type":32,"value":215},"真正重要的问题会是：",{"type":27,"tag":35,"props":217,"children":218},{},[219,224,229],{"type":27,"tag":39,"props":220,"children":221},{},[222],{"type":32,"value":223},"变更如何发布",{"type":27,"tag":39,"props":225,"children":226},{},[227],{"type":32,"value":228},"token 和组件契约如何治理",{"type":27,"tag":39,"props":230,"children":231},{},[232],{"type":32,"value":233},"设计、开发和内容团队如何共享规则",{"type":27,"tag":28,"props":235,"children":236},{},[237],{"type":32,"value":238},"设计系统会继续重要，但更像运营平台，而不只是 UI 仓库。",{"type":27,"tag":55,"props":240,"children":242},{"id":241},"复杂架构将更频繁地接受-roi-审视",[243],{"type":32,"value":244},"复杂架构将更频繁地接受 ROI 审视",{"type":27,"tag":28,"props":246,"children":247},{},[248],{"type":32,"value":249},"到 2027 年，团队对复杂架构的态度大概率会更务实。",{"type":27,"tag":28,"props":251,"children":252},{},[253],{"type":32,"value":254},"无论是微前端、RSC、边缘渲染、跨端统一，还是 AI 驱动开发流，大家都会越来越关心一个问题：",{"type":27,"tag":28,"props":256,"children":257},{},[258],{"type":27,"tag":259,"props":260,"children":261},"strong",{},[262],{"type":32,"value":263},"这套复杂度是否真的带来了稳定收益？",{"type":27,"tag":28,"props":265,"children":266},{},[267],{"type":32,"value":268},"不能持续回答这个问题的方案，很可能会被收缩。",{"type":27,"tag":55,"props":270,"children":272},{"id":271},"_2027-年更值得投资的能力是什么",[273],{"type":32,"value":274},"2027 年更值得投资的能力是什么",{"type":27,"tag":28,"props":276,"children":277},{},[278],{"type":32,"value":279},"如果站在团队能力建设角度，未来一年更值得优先投资的大概率是：",{"type":27,"tag":35,"props":281,"children":282},{},[283,288,293,298],{"type":27,"tag":39,"props":284,"children":285},{},[286],{"type":32,"value":287},"约束清晰的架构边界",{"type":27,"tag":39,"props":289,"children":290},{},[291],{"type":32,"value":292},"更强的发布与回归治理",{"type":27,"tag":39,"props":294,"children":295},{},[296],{"type":32,"value":297},"面向 AI 协作的任务拆解能力",{"type":27,"tag":39,"props":299,"children":300},{},[301],{"type":32,"value":302},"真正可被复用的可观测性资产",{"type":27,"tag":28,"props":304,"children":305},{},[306],{"type":32,"value":307},"这些能力未必最有话题性，但更可能成为组织的长期优势。",{"type":27,"tag":55,"props":309,"children":311},{"id":310},"一份可直接复用的趋势判断清单",[312],{"type":32,"value":310},{"type":27,"tag":35,"props":314,"children":315},{},[316,321,326,331,336],{"type":27,"tag":39,"props":317,"children":318},{},[319],{"type":32,"value":320},"这项趋势会改变团队边界，还是只会增加工具层热闹度",{"type":27,"tag":39,"props":322,"children":323},{},[324],{"type":32,"value":325},"它是否能降低长期维护成本，而不是只提高演示效果",{"type":27,"tag":39,"props":327,"children":328},{},[329],{"type":32,"value":330},"它是否要求新的可观测性和治理能力一起跟进",{"type":27,"tag":39,"props":332,"children":333},{},[334],{"type":32,"value":335},"它对多人协作是减负还是增负",{"type":27,"tag":39,"props":337,"children":338},{},[339],{"type":32,"value":340},"如果不采用，组织是否会真的失去竞争力",{"type":27,"tag":55,"props":342,"children":344},{"id":343},"总结",[345],{"type":32,"value":343},{"type":27,"tag":28,"props":347,"children":348},{},[349],{"type":32,"value":350},"2027 年前端最值得关注的趋势，不会只是一个新框架或新编译器，而是边界继续重组后的工程后果。谁更早把协作、治理和可观测性一起纳入趋势判断，谁就更容易把变化转化成长期收益。",{"type":27,"tag":28,"props":352,"children":353},{},[354],{"type":32,"value":355},"进一步阅读：",{"type":27,"tag":35,"props":357,"children":358},{},[359,369,378],{"type":27,"tag":39,"props":360,"children":361},{},[362],{"type":27,"tag":363,"props":364,"children":366},"a",{"href":365},"/topics/frontend/frontend-2026-annual-review",[367],{"type":32,"value":368},"2026 前端技术年度总结",{"type":27,"tag":39,"props":370,"children":371},{},[372],{"type":27,"tag":363,"props":373,"children":375},{"href":374},"/topics/frontend/frontend-architecture-evolution-retrospective",[376],{"type":32,"value":377},"前端架构演进：回顾与思考",{"type":27,"tag":39,"props":379,"children":380},{},[381],{"type":27,"tag":363,"props":382,"children":384},{"href":383},"/topics/ai/ai-agent-trends-outlook",[385],{"type":32,"value":386},"AI Agent 发展趋势与展望",{"title":7,"searchDepth":388,"depth":388,"links":389},3,[390,392,393,394,395,396,397,398,399],{"id":57,"depth":391,"text":60},2,{"id":96,"depth":391,"text":96},{"id":129,"depth":391,"text":132},{"id":163,"depth":391,"text":166},{"id":202,"depth":391,"text":205},{"id":241,"depth":391,"text":244},{"id":271,"depth":391,"text":274},{"id":310,"depth":391,"text":310},{"id":343,"depth":391,"text":343},"markdown","content:topics:frontend:frontend-2027-trends-outlook.md","content","topics/frontend/frontend-2027-trends-outlook.md","topics/frontend/frontend-2027-trends-outlook","md",[407,740,1052],{"_path":408,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":409,"description":410,"keywords":411,"image":417,"author":418,"date":419,"readingTime":420,"topic":5,"body":421,"_type":400,"_id":737,"_source":402,"_file":738,"_stem":739,"_extension":405},"/topics/frontend/react-hooks-guide","React Hooks 完全指南","全面讲解 React Hooks，包括内置钩子、自定义钩子和最佳实践",[412,413,414,415,416],"React","Hooks","自定义钩子","状态管理","函数组件","/images/topics/react-hooks-guide.jpg","AI Content Team","2025-12-08",23,{"type":24,"children":422,"toc":718},[423,428,433,439,446,459,465,474,480,489,495,501,510,516,525,531,540,546,555,560,566,575,580,592,620,631,659,664],{"type":27,"tag":55,"props":424,"children":426},{"id":425},"react-hooks-完全指南",[427],{"type":32,"value":409},{"type":27,"tag":28,"props":429,"children":430},{},[431],{"type":32,"value":432},"Hooks 改变了 React 的开发方式。本文全面讲解如何使用和创建 Hooks。",{"type":27,"tag":55,"props":434,"children":436},{"id":435},"内置-hooks",[437],{"type":32,"value":438},"内置 Hooks",{"type":27,"tag":440,"props":441,"children":443},"h3",{"id":442},"usestate-状态管理",[444],{"type":32,"value":445},"useState - 状态管理",{"type":27,"tag":447,"props":448,"children":453},"pre",{"className":449,"code":451,"language":452,"meta":7},[450],"language-javascript","import { useState } from 'react'\n\nfunction Counter() {\n  const [count, setCount] = useState(0)\n  const [name, setName] = useState('John')\n  const [user, setUser] = useState({\n    age: 30,\n    email: 'john@example.com',\n  })\n  \n  // 使用函数初始化状态（对于复杂初始值）\n  const [data, setData] = useState(() => {\n    console.log('初始化数据...')\n    return fetchInitialData() // 仅在首次渲染时调用\n  })\n  \n  return (\n    \u003Cdiv>\n      \u003Cp>计数: {count}\u003C/p>\n      \u003Cbutton onClick={() => setCount(count + 1)}>增加\u003C/button>\n      \n      {/* 函数式更新 */}\n      \u003Cbutton onClick={() => setCount(prev => prev + 1)}>\n        函数式增加\n      \u003C/button>\n      \n      {/* 更新对象 */}\n      \u003Cbutton onClick={() => setUser({ ...user, age: user.age + 1 })}>\n        增加年龄\n      \u003C/button>\n    \u003C/div>\n  )\n}\n","javascript",[454],{"type":27,"tag":455,"props":456,"children":457},"code",{"__ignoreMap":7},[458],{"type":32,"value":451},{"type":27,"tag":440,"props":460,"children":462},{"id":461},"useeffect-副作用处理",[463],{"type":32,"value":464},"useEffect - 副作用处理",{"type":27,"tag":447,"props":466,"children":469},{"className":467,"code":468,"language":452,"meta":7},[450],"import { useState, useEffect } from 'react'\n\nfunction DataFetcher() {\n  const [data, setData] = useState(null)\n  const [loading, setLoading] = useState(true)\n  const [error, setError] = useState(null)\n  const [userId, setUserId] = useState(1)\n  \n  // 副作用 - 每次渲染后执行\n  useEffect(() => {\n    console.log('组件已挂载或已更新')\n  })\n  \n  // 挂载时执行一次\n  useEffect(() => {\n    console.log('组件已挂载')\n    \n    return () => {\n      console.log('组件已卸载')\n    }\n  }, [])\n  \n  // 当 userId 改变时执行\n  useEffect(() => {\n    let isMounted = true // 防止内存泄漏\n    \n    const fetchData = async () => {\n      setLoading(true)\n      try {\n        const response = await fetch(\\`/api/users/\\${userId}\\`)\n        const result = await response.json()\n        \n        if (isMounted) {\n          setData(result)\n        }\n      } catch (err) {\n        if (isMounted) {\n          setError(err)\n        }\n      } finally {\n        if (isMounted) {\n          setLoading(false)\n        }\n      }\n    }\n    \n    fetchData()\n    \n    // 清理函数\n    return () => {\n      isMounted = false\n    }\n  }, [userId])\n  \n  if (loading) return \u003Cp>加载中...\u003C/p>\n  if (error) return \u003Cp>错误: {error.message}\u003C/p>\n  \n  return \u003Cdiv>{data && JSON.stringify(data)}\u003C/div>\n}\n",[470],{"type":27,"tag":455,"props":471,"children":472},{"__ignoreMap":7},[473],{"type":32,"value":468},{"type":27,"tag":440,"props":475,"children":477},{"id":476},"usecontext-跨组件通信",[478],{"type":32,"value":479},"useContext - 跨组件通信",{"type":27,"tag":447,"props":481,"children":484},{"className":482,"code":483,"language":452,"meta":7},[450],"import { createContext, useContext, useState } from 'react'\n\n// 创建上下文\nconst ThemeContext = createContext()\n\n// 提供者组件\nfunction ThemeProvider({ children }) {\n  const [theme, setTheme] = useState('light')\n  \n  const toggleTheme = () => {\n    setTheme(prev => prev === 'light' ? 'dark' : 'light')\n  }\n  \n  const value = { theme, toggleTheme }\n  \n  return (\n    \u003CThemeContext.Provider value={value}>\n      {children}\n    \u003C/ThemeContext.Provider>\n  )\n}\n\n// 使用 Hook\nfunction useTheme() {\n  const context = useContext(ThemeContext)\n  \n  if (!context) {\n    throw new Error('useTheme 必须在 ThemeProvider 内使用')\n  }\n  \n  return context\n}\n\n// 组件使用\nfunction App() {\n  const { theme, toggleTheme } = useTheme()\n  \n  return (\n    \u003Cdiv style={{\n      background: theme === 'light' ? '#fff' : '#333',\n      color: theme === 'light' ? '#000' : '#fff',\n    }}>\n      \u003Cp>当前主题: {theme}\u003C/p>\n      \u003Cbutton onClick={toggleTheme}>切换主题\u003C/button>\n    \u003C/div>\n  )\n}\n\n// 使用\nexport default function Root() {\n  return (\n    \u003CThemeProvider>\n      \u003CApp />\n    \u003C/ThemeProvider>\n  )\n}\n",[485],{"type":27,"tag":455,"props":486,"children":487},{"__ignoreMap":7},[488],{"type":32,"value":483},{"type":27,"tag":55,"props":490,"children":492},{"id":491},"自定义-hooks",[493],{"type":32,"value":494},"自定义 Hooks",{"type":27,"tag":440,"props":496,"children":498},{"id":497},"uselocalstorage",[499],{"type":32,"value":500},"useLocalStorage",{"type":27,"tag":447,"props":502,"children":505},{"className":503,"code":504,"language":452,"meta":7},[450],"import { useState, useEffect } from 'react'\n\nfunction useLocalStorage(key, initialValue) {\n  // 从本地存储获取初始值\n  const [storedValue, setStoredValue] = useState(() => {\n    try {\n      const item = window.localStorage.getItem(key)\n      return item ? JSON.parse(item) : initialValue\n    } catch (error) {\n      console.error(error)\n      return initialValue\n    }\n  })\n  \n  // 当值改变时更新本地存储\n  const setValue = (value) => {\n    try {\n      const valueToStore = value instanceof Function ? value(storedValue) : value\n      setStoredValue(valueToStore)\n      window.localStorage.setItem(key, JSON.stringify(valueToStore))\n    } catch (error) {\n      console.error(error)\n    }\n  }\n  \n  return [storedValue, setValue]\n}\n\n// 使用\nfunction App() {\n  const [name, setName] = useLocalStorage('name', 'Guest')\n  \n  return (\n    \u003Cdiv>\n      \u003Cp>姓名: {name}\u003C/p>\n      \u003Cinput\n        value={name}\n        onChange={(e) => setName(e.target.value)}\n      />\n    \u003C/div>\n  )\n}\n",[506],{"type":27,"tag":455,"props":507,"children":508},{"__ignoreMap":7},[509],{"type":32,"value":504},{"type":27,"tag":440,"props":511,"children":513},{"id":512},"useasync-异步操作",[514],{"type":32,"value":515},"useAsync - 异步操作",{"type":27,"tag":447,"props":517,"children":520},{"className":518,"code":519,"language":452,"meta":7},[450],"import { useState, useEffect, useRef } from 'react'\n\nfunction useAsync(asyncFunction, immediate = true) {\n  const [status, setStatus] = useState('idle')\n  const [value, setValue] = useState(null)\n  const [error, setError] = useState(null)\n  \n  // 使用 ref 来防止无限循环\n  const executeRef = useRef(null)\n  \n  const execute = useRef(async () => {\n    setStatus('pending')\n    setValue(null)\n    setError(null)\n    \n    try {\n      const response = await asyncFunction()\n      setValue(response)\n      setStatus('success')\n      return response\n    } catch (error) {\n      setError(error)\n      setStatus('error')\n    }\n  })\n  \n  executeRef.current = execute.current\n  \n  useEffect(() => {\n    if (!immediate) return\n    \n    executeRef.current()\n  }, [immediate])\n  \n  return { execute: executeRef.current, status, value, error }\n}\n\n// 使用\nfunction UserProfile({ userId }) {\n  const { execute, status, value: user, error } = useAsync(\n    () => fetch(\\`/api/users/\\${userId}\\`).then(r => r.json()),\n    true\n  )\n  \n  if (status === 'pending') return \u003Cp>加载中...\u003C/p>\n  if (status === 'error') return \u003Cp>错误: {error?.message}\u003C/p>\n  if (status === 'success') return \u003Cp>用户: {user?.name}\u003C/p>\n  \n  return null\n}\n",[521],{"type":27,"tag":455,"props":522,"children":523},{"__ignoreMap":7},[524],{"type":32,"value":519},{"type":27,"tag":440,"props":526,"children":528},{"id":527},"usefetch-数据获取",[529],{"type":32,"value":530},"useFetch - 数据获取",{"type":27,"tag":447,"props":532,"children":535},{"className":533,"code":534,"language":452,"meta":7},[450],"import { useState, useEffect } from 'react'\n\nfunction useFetch(url, options = {}) {\n  const [data, setData] = useState(null)\n  const [loading, setLoading] = useState(true)\n  const [error, setError] = useState(null)\n  \n  useEffect(() => {\n    let isMounted = true\n    \n    const fetchData = async () => {\n      try {\n        const response = await fetch(url, {\n          method: 'GET',\n          ...options,\n        })\n        \n        if (!response.ok) {\n          throw new Error(\\`HTTP error! status: \\${response.status}\\`)\n        }\n        \n        const result = await response.json()\n        \n        if (isMounted) {\n          setData(result)\n          setError(null)\n        }\n      } catch (err) {\n        if (isMounted) {\n          setError(err)\n          setData(null)\n        }\n      } finally {\n        if (isMounted) {\n          setLoading(false)\n        }\n      }\n    }\n    \n    fetchData()\n    \n    return () => {\n      isMounted = false\n    }\n  }, [url, options])\n  \n  const refetch = async () => {\n    setLoading(true)\n    try {\n      const response = await fetch(url, options)\n      const result = await response.json()\n      setData(result)\n    } catch (err) {\n      setError(err)\n    } finally {\n      setLoading(false)\n    }\n  }\n  \n  return { data, loading, error, refetch }\n}\n\n// 使用\nfunction UserList() {\n  const { data: users, loading, error, refetch } = useFetch('/api/users')\n  \n  if (loading) return \u003Cp>加载中...\u003C/p>\n  if (error) return \u003Cp>错误: {error.message}\u003C/p>\n  \n  return (\n    \u003Cdiv>\n      \u003Cbutton onClick={refetch}>刷新\u003C/button>\n      \u003Cul>\n        {users?.map(user => (\n          \u003Cli key={user.id}>{user.name}\u003C/li>\n        ))}\n      \u003C/ul>\n    \u003C/div>\n  )\n}\n",[536],{"type":27,"tag":455,"props":537,"children":538},{"__ignoreMap":7},[539],{"type":32,"value":534},{"type":27,"tag":440,"props":541,"children":543},{"id":542},"useprevious-保存前一个值",[544],{"type":32,"value":545},"usePrevious - 保存前一个值",{"type":27,"tag":447,"props":547,"children":550},{"className":548,"code":549,"language":452,"meta":7},[450],"import { useEffect, useRef } from 'react'\n\nfunction usePrevious(value) {\n  const ref = useRef()\n  \n  useEffect(() => {\n    ref.current = value\n  }, [value])\n  \n  return ref.current\n}\n\n// 使用\nfunction Counter() {\n  const [count, setCount] = React.useState(0)\n  const prevCount = usePrevious(count)\n  \n  return (\n    \u003Cdiv>\n      \u003Cp>当前: {count}, 前一个: {prevCount}\u003C/p>\n      \u003Cbutton onClick={() => setCount(count + 1)}>增加\u003C/button>\n    \u003C/div>\n  )\n}\n",[551],{"type":27,"tag":455,"props":552,"children":553},{"__ignoreMap":7},[554],{"type":32,"value":549},{"type":27,"tag":55,"props":556,"children":558},{"id":557},"高级模式",[559],{"type":32,"value":557},{"type":27,"tag":440,"props":561,"children":563},{"id":562},"usereducer-复杂状态管理",[564],{"type":32,"value":565},"useReducer - 复杂状态管理",{"type":27,"tag":447,"props":567,"children":570},{"className":568,"code":569,"language":452,"meta":7},[450],"import { useReducer } from 'react'\n\nconst initialState = {\n  todos: [],\n  filter: 'all',\n  error: null,\n}\n\nfunction todoReducer(state, action) {\n  switch (action.type) {\n    case 'ADD_TODO':\n      return {\n        ...state,\n        todos: [...state.todos, { id: Date.now(), text: action.payload }],\n      }\n    \n    case 'REMOVE_TODO':\n      return {\n        ...state,\n        todos: state.todos.filter(todo => todo.id !== action.payload),\n      }\n    \n    case 'SET_FILTER':\n      return { ...state, filter: action.payload }\n    \n    case 'SET_ERROR':\n      return { ...state, error: action.payload }\n    \n    default:\n      return state\n  }\n}\n\nfunction TodoApp() {\n  const [state, dispatch] = useReducer(todoReducer, initialState)\n  \n  const addTodo = (text) => {\n    dispatch({ type: 'ADD_TODO', payload: text })\n  }\n  \n  const removeTodo = (id) => {\n    dispatch({ type: 'REMOVE_TODO', payload: id })\n  }\n  \n  return (\n    \u003Cdiv>\n      {state.todos.map(todo => (\n        \u003Cdiv key={todo.id}>\n          {todo.text}\n          \u003Cbutton onClick={() => removeTodo(todo.id)}>删除\u003C/button>\n        \u003C/div>\n      ))}\n    \u003C/div>\n  )\n}\n",[571],{"type":27,"tag":455,"props":572,"children":573},{"__ignoreMap":7},[574],{"type":32,"value":569},{"type":27,"tag":55,"props":576,"children":578},{"id":577},"最佳实践",[579],{"type":32,"value":577},{"type":27,"tag":28,"props":581,"children":582},{},[583,585,590],{"type":32,"value":584},"✅ ",{"type":27,"tag":259,"props":586,"children":587},{},[588],{"type":32,"value":589},"应该做的事",{"type":32,"value":591},":",{"type":27,"tag":35,"props":593,"children":594},{},[595,600,605,610,615],{"type":27,"tag":39,"props":596,"children":597},{},[598],{"type":32,"value":599},"将相关逻辑提取到自定义 Hooks",{"type":27,"tag":39,"props":601,"children":602},{},[603],{"type":32,"value":604},"在 useEffect 的依赖数组中包含所有依赖",{"type":27,"tag":39,"props":606,"children":607},{},[608],{"type":32,"value":609},"使用 useCallback 和 useMemo 优化性能",{"type":27,"tag":39,"props":611,"children":612},{},[613],{"type":32,"value":614},"为自定义 Hooks 编写文档",{"type":27,"tag":39,"props":616,"children":617},{},[618],{"type":32,"value":619},"及时清理副作用",{"type":27,"tag":28,"props":621,"children":622},{},[623,625,630],{"type":32,"value":624},"❌ ",{"type":27,"tag":259,"props":626,"children":627},{},[628],{"type":32,"value":629},"不应该做的事",{"type":32,"value":591},{"type":27,"tag":35,"props":632,"children":633},{},[634,639,644,649,654],{"type":27,"tag":39,"props":635,"children":636},{},[637],{"type":32,"value":638},"在条件或循环中调用 Hooks",{"type":27,"tag":39,"props":640,"children":641},{},[642],{"type":32,"value":643},"在普通函数中调用 Hooks",{"type":27,"tag":39,"props":645,"children":646},{},[647],{"type":32,"value":648},"忘记依赖数组",{"type":27,"tag":39,"props":650,"children":651},{},[652],{"type":32,"value":653},"过度使用 useMemo/useCallback",{"type":27,"tag":39,"props":655,"children":656},{},[657],{"type":32,"value":658},"在 Hooks 中创建过多的闭包",{"type":27,"tag":55,"props":660,"children":662},{"id":661},"检查清单",[663],{"type":32,"value":661},{"type":27,"tag":35,"props":665,"children":668},{"className":666},[667],"contains-task-list",[669,682,691,700,709],{"type":27,"tag":39,"props":670,"children":673},{"className":671},[672],"task-list-item",[674,680],{"type":27,"tag":675,"props":676,"children":679},"input",{"disabled":677,"type":678},true,"checkbox",[],{"type":32,"value":681}," Hooks 调用顺序正确",{"type":27,"tag":39,"props":683,"children":685},{"className":684},[672],[686,689],{"type":27,"tag":675,"props":687,"children":688},{"disabled":677,"type":678},[],{"type":32,"value":690}," 依赖数组完整",{"type":27,"tag":39,"props":692,"children":694},{"className":693},[672],[695,698],{"type":27,"tag":675,"props":696,"children":697},{"disabled":677,"type":678},[],{"type":32,"value":699}," 副作用正确清理",{"type":27,"tag":39,"props":701,"children":703},{"className":702},[672],[704,707],{"type":27,"tag":675,"props":705,"children":706},{"disabled":677,"type":678},[],{"type":32,"value":708}," 性能优化得当",{"type":27,"tag":39,"props":710,"children":712},{"className":711},[672],[713,716],{"type":27,"tag":675,"props":714,"children":715},{"disabled":677,"type":678},[],{"type":32,"value":717}," 代码易于理解和测试",{"title":7,"searchDepth":388,"depth":388,"links":719},[720,721,726,732,735,736],{"id":425,"depth":391,"text":409},{"id":435,"depth":391,"text":438,"children":722},[723,724,725],{"id":442,"depth":388,"text":445},{"id":461,"depth":388,"text":464},{"id":476,"depth":388,"text":479},{"id":491,"depth":391,"text":494,"children":727},[728,729,730,731],{"id":497,"depth":388,"text":500},{"id":512,"depth":388,"text":515},{"id":527,"depth":388,"text":530},{"id":542,"depth":388,"text":545},{"id":557,"depth":391,"text":557,"children":733},[734],{"id":562,"depth":388,"text":565},{"id":577,"depth":391,"text":577},{"id":661,"depth":391,"text":661},"content:topics:frontend:react-hooks-guide.md","topics/frontend/react-hooks-guide.md","topics/frontend/react-hooks-guide",{"_path":741,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":742,"description":743,"keywords":744,"image":750,"author":418,"date":419,"readingTime":751,"topic":5,"body":752,"_type":400,"_id":1049,"_source":402,"_file":1050,"_stem":1051,"_extension":405},"/topics/frontend/vue3-composition-api","Vue 3 Composition API 深度解析","全面讲解 Vue 3 Composition API 的用法、最佳实践和高级模式",[745,746,747,748,749],"Vue 3","Composition API","组合式函数","响应式系统","前端开发","/images/topics/vue3-composition-api.jpg",22,{"type":24,"children":753,"toc":1025},[754,759,764,769,775,784,789,798,802,807,816,821,827,836,841,847,856,861,866,875,880,886,895,899,908,936,945,973,977],{"type":27,"tag":55,"props":755,"children":757},{"id":756},"vue-3-composition-api-深度解析",[758],{"type":32,"value":742},{"type":27,"tag":28,"props":760,"children":761},{},[762],{"type":32,"value":763},"Composition API 让 Vue 应用更易于组织和重用逻辑。本文深入讲解这一核心特性。",{"type":27,"tag":55,"props":765,"children":767},{"id":766},"核心概念",[768],{"type":32,"value":766},{"type":27,"tag":440,"props":770,"children":772},{"id":771},"setup-函数",[773],{"type":32,"value":774},"setup 函数",{"type":27,"tag":447,"props":776,"children":779},{"className":777,"code":778,"language":452,"meta":7},[450],"import { ref, computed, watch } from 'vue'\n\nexport default {\n  props: ['initialCount'],\n  emits: ['count-changed'],\n  \n  setup(props, { emit, slots, expose }) {\n    // 创建响应式状态\n    const count = ref(props.initialCount)\n    const doubled = computed(() => count.value * 2)\n    \n    // 监听状态变化\n    watch(count, (newVal, oldVal) => {\n      console.log(`Count changed from ${oldVal} to ${newVal}`)\n      emit('count-changed', newVal)\n    })\n    \n    // 定义方法\n    const increment = () => count.value++\n    const decrement = () => count.value--\n    \n    // 返回模板需要的内容\n    return {\n      count,\n      doubled,\n      increment,\n      decrement,\n    }\n  },\n}\n",[780],{"type":27,"tag":455,"props":781,"children":782},{"__ignoreMap":7},[783],{"type":32,"value":778},{"type":27,"tag":440,"props":785,"children":787},{"id":786},"响应式基础",[788],{"type":32,"value":786},{"type":27,"tag":447,"props":790,"children":793},{"className":791,"code":792,"language":452,"meta":7},[450],"import { ref, reactive, readonly, isRef } from 'vue'\n\n// ref - 用于基本类型\nconst count = ref(0)\nconsole.log(count.value) // 0\ncount.value++\n\n// reactive - 用于对象\nconst state = reactive({\n  name: 'John',\n  age: 30,\n  address: {\n    city: 'Beijing',\n  },\n})\n\nstate.name = 'Jane' // 自动更新，无需 .value\n\n// readonly - 创建只读副本\nconst original = reactive({ count: 0 })\nconst copy = readonly(original)\n// copy.count++ // 错误：不能修改\n\n// isRef 检查\nconsole.log(isRef(count)) // true\nconsole.log(isRef(state)) // false\n",[794],{"type":27,"tag":455,"props":795,"children":796},{"__ignoreMap":7},[797],{"type":32,"value":792},{"type":27,"tag":55,"props":799,"children":800},{"id":747},[801],{"type":32,"value":747},{"type":27,"tag":440,"props":803,"children":805},{"id":804},"创建可重用逻辑",[806],{"type":32,"value":804},{"type":27,"tag":447,"props":808,"children":811},{"className":809,"code":810,"language":452,"meta":7},[450],"// useCounter.js - 组合式函数\nimport { ref, computed } from 'vue'\n\nexport function useCounter(initialValue = 0) {\n  const count = ref(initialValue)\n  const doubled = computed(() => count.value * 2)\n  \n  const increment = () => count.value++\n  const decrement = () => count.value--\n  const reset = () => count.value = initialValue\n  \n  return {\n    count,\n    doubled,\n    increment,\n    decrement,\n    reset,\n  }\n}\n\n// useFetch.js - 数据获取组合式函数\nimport { ref, onMounted } from 'vue'\n\nexport function useFetch(url) {\n  const data = ref(null)\n  const loading = ref(false)\n  const error = ref(null)\n  \n  const fetch = async () => {\n    loading.value = true\n    error.value = null\n    \n    try {\n      const response = await fetch(url)\n      data.value = await response.json()\n    } catch (e) {\n      error.value = e\n    } finally {\n      loading.value = false\n    }\n  }\n  \n  onMounted(fetch)\n  \n  return {\n    data,\n    loading,\n    error,\n    refetch: fetch,\n  }\n}\n\n// 使用\nexport default {\n  setup() {\n    const { count, doubled, increment } = useCounter(10)\n    const { data, loading, refetch } = useFetch('/api/data')\n    \n    return {\n      count,\n      doubled,\n      increment,\n      data,\n      loading,\n      refetch,\n    }\n  },\n}\n",[812],{"type":27,"tag":455,"props":813,"children":814},{"__ignoreMap":7},[815],{"type":32,"value":810},{"type":27,"tag":55,"props":817,"children":819},{"id":818},"生命周期钩子",[820],{"type":32,"value":818},{"type":27,"tag":440,"props":822,"children":824},{"id":823},"composition-api-中的生命周期",[825],{"type":32,"value":826},"Composition API 中的生命周期",{"type":27,"tag":447,"props":828,"children":831},{"className":829,"code":830,"language":452,"meta":7},[450],"import {\n  onBeforeMount,\n  onMounted,\n  onBeforeUpdate,\n  onUpdated,\n  onBeforeUnmount,\n  onUnmounted,\n  onErrorCaptured,\n} from 'vue'\n\nexport default {\n  setup() {\n    onBeforeMount(() => {\n      console.log('组件挂载前')\n    })\n    \n    onMounted(() => {\n      console.log('组件已挂载')\n      // 初始化事件监听器、定时器等\n    })\n    \n    onBeforeUpdate(() => {\n      console.log('组件更新前')\n    })\n    \n    onUpdated(() => {\n      console.log('组件已更新')\n    })\n    \n    onBeforeUnmount(() => {\n      console.log('组件卸载前')\n    })\n    \n    onUnmounted(() => {\n      console.log('组件已卸载')\n      // 清理事件监听器、定时器等\n    })\n    \n    onErrorCaptured((err, instance, info) => {\n      console.log('捕获错误:', err)\n      return false // 返回 false 阻止错误传播\n    })\n    \n    return {}\n  },\n}\n",[832],{"type":27,"tag":455,"props":833,"children":834},{"__ignoreMap":7},[835],{"type":32,"value":830},{"type":27,"tag":55,"props":837,"children":839},{"id":838},"模板引用",[840],{"type":32,"value":838},{"type":27,"tag":440,"props":842,"children":844},{"id":843},"访问-dom-元素",[845],{"type":32,"value":846},"访问 DOM 元素",{"type":27,"tag":447,"props":848,"children":851},{"className":849,"code":850,"language":452,"meta":7},[450],"import { ref, onMounted } from 'vue'\n\nexport default {\n  setup() {\n    const inputRef = ref(null)\n    const listRef = ref(null)\n    const dynamicRef = ref(null)\n    \n    onMounted(() => {\n      // 访问 DOM 元素\n      inputRef.value?.focus()\n      console.log(listRef.value?.offsetHeight)\n    })\n    \n    // 函数式引用\n    const assignRef = el => {\n      if (el) {\n        console.log('元素已赋值', el)\n      } else {\n        console.log('元素已移除')\n      }\n    }\n    \n    return {\n      inputRef,\n      listRef,\n      dynamicRef,\n      assignRef,\n    }\n  },\n  \n  template: \\`\n    \u003Cdiv>\n      \u003Cinput ref=\"inputRef\" />\n      \u003Cul ref=\"listRef\">\n        \u003Cli v-for=\"item in items\" :key=\"item\">{{ item }}\u003C/li>\n      \u003C/ul>\n      \u003Cdiv :ref=\"assignRef\">\u003C/div>\n    \u003C/div>\n  \\`,\n}\n",[852],{"type":27,"tag":455,"props":853,"children":854},{"__ignoreMap":7},[855],{"type":32,"value":850},{"type":27,"tag":55,"props":857,"children":859},{"id":858},"依赖注入",[860],{"type":32,"value":858},{"type":27,"tag":440,"props":862,"children":864},{"id":863},"跨组件共享数据",[865],{"type":32,"value":863},{"type":27,"tag":447,"props":867,"children":870},{"className":868,"code":869,"language":452,"meta":7},[450],"import { provide, inject, ref, readonly } from 'vue'\n\n// 父组件\nexport default {\n  setup() {\n    const theme = ref('light')\n    const user = ref({ name: 'John', role: 'admin' })\n    \n    // 提供数据给子组件\n    provide('theme', readonly(theme))\n    provide('updateTheme', (newTheme) => {\n      theme.value = newTheme\n    })\n    \n    // 使用 Symbol 作为 key 避免命名冲突\n    const userKey = Symbol()\n    provide(userKey, readonly(user))\n    \n    return {\n      theme,\n      updateTheme: (newTheme) => {\n        theme.value = newTheme\n      },\n    }\n  },\n}\n\n// 子组件\nexport default {\n  setup() {\n    // 注入数据\n    const theme = inject('theme')\n    const updateTheme = inject('updateTheme')\n    const user = inject(Symbol.for('user'))\n    \n    // 带默认值的注入\n    const config = inject('config', {\n      apiUrl: 'http://localhost:3000',\n    })\n    \n    return {\n      theme,\n      updateTheme,\n      user,\n      config,\n    }\n  },\n}\n",[871],{"type":27,"tag":455,"props":872,"children":873},{"__ignoreMap":7},[874],{"type":32,"value":869},{"type":27,"tag":55,"props":876,"children":878},{"id":877},"高级状态管理",[879],{"type":32,"value":877},{"type":27,"tag":440,"props":881,"children":883},{"id":882},"创建小型-store",[884],{"type":32,"value":885},"创建小型 store",{"type":27,"tag":447,"props":887,"children":890},{"className":888,"code":889,"language":452,"meta":7},[450],"import { reactive, readonly, computed } from 'vue'\n\n// store.js - 不依赖 Pinia 的简单 store\nexport function createStore() {\n  const state = reactive({\n    items: [],\n    filter: 'all',\n    sortBy: 'date',\n  })\n  \n  const filteredItems = computed(() => {\n    let result = state.items\n    \n    if (state.filter !== 'all') {\n      result = result.filter(item => item.status === state.filter)\n    }\n    \n    if (state.sortBy === 'date') {\n      result.sort((a, b) => new Date(b.date) - new Date(a.date))\n    } else if (state.sortBy === 'name') {\n      result.sort((a, b) => a.name.localeCompare(b.name))\n    }\n    \n    return result\n  })\n  \n  const actions = {\n    addItem(item) {\n      state.items.push({ ...item, id: Date.now() })\n    },\n    \n    removeItem(id) {\n      state.items = state.items.filter(item => item.id !== id)\n    },\n    \n    updateItem(id, updates) {\n      const item = state.items.find(item => item.id === id)\n      if (item) {\n        Object.assign(item, updates)\n      }\n    },\n    \n    setFilter(filter) {\n      state.filter = filter\n    },\n    \n    setSortBy(sortBy) {\n      state.sortBy = sortBy\n    },\n  }\n  \n  return {\n    state: readonly(state),\n    filteredItems,\n    ...actions,\n  }\n}\n\n// 使用\nexport default {\n  setup() {\n    const store = createStore()\n    \n    const handleAdd = (item) => {\n      store.addItem(item)\n    }\n    \n    return {\n      items: store.filteredItems,\n      addItem: handleAdd,\n      setFilter: store.setFilter,\n    }\n  },\n}\n",[891],{"type":27,"tag":455,"props":892,"children":893},{"__ignoreMap":7},[894],{"type":32,"value":889},{"type":27,"tag":55,"props":896,"children":897},{"id":577},[898],{"type":32,"value":577},{"type":27,"tag":28,"props":900,"children":901},{},[902,903,907],{"type":32,"value":584},{"type":27,"tag":259,"props":904,"children":905},{},[906],{"type":32,"value":589},{"type":32,"value":591},{"type":27,"tag":35,"props":909,"children":910},{},[911,916,921,926,931],{"type":27,"tag":39,"props":912,"children":913},{},[914],{"type":32,"value":915},"将相关逻辑组织在一起",{"type":27,"tag":39,"props":917,"children":918},{},[919],{"type":32,"value":920},"创建可重用的组合式函数",{"type":27,"tag":39,"props":922,"children":923},{},[924],{"type":32,"value":925},"使用 TypeScript 获得更好的类型检查",{"type":27,"tag":39,"props":927,"children":928},{},[929],{"type":32,"value":930},"合理使用计算属性和监听器",{"type":27,"tag":39,"props":932,"children":933},{},[934],{"type":32,"value":935},"及时清理事件监听器和定时器",{"type":27,"tag":28,"props":937,"children":938},{},[939,940,944],{"type":32,"value":624},{"type":27,"tag":259,"props":941,"children":942},{},[943],{"type":32,"value":629},{"type":32,"value":591},{"type":27,"tag":35,"props":946,"children":947},{},[948,953,958,963,968],{"type":27,"tag":39,"props":949,"children":950},{},[951],{"type":32,"value":952},"在 setup 中执行副作用操作（除了生命周期钩子）",{"type":27,"tag":39,"props":954,"children":955},{},[956],{"type":32,"value":957},"过度使用计算属性",{"type":27,"tag":39,"props":959,"children":960},{},[961],{"type":32,"value":962},"忘记清理 watch 监听器",{"type":27,"tag":39,"props":964,"children":965},{},[966],{"type":32,"value":967},"在 reactive 对象中存储引用类型时不谨慎",{"type":27,"tag":39,"props":969,"children":970},{},[971],{"type":32,"value":972},"过度复杂化组合式函数",{"type":27,"tag":55,"props":974,"children":975},{"id":661},[976],{"type":32,"value":661},{"type":27,"tag":35,"props":978,"children":980},{"className":979},[667],[981,990,999,1008,1017],{"type":27,"tag":39,"props":982,"children":984},{"className":983},[672],[985,988],{"type":27,"tag":675,"props":986,"children":987},{"disabled":677,"type":678},[],{"type":32,"value":989}," 正确使用 ref 和 reactive",{"type":27,"tag":39,"props":991,"children":993},{"className":992},[672],[994,997],{"type":27,"tag":675,"props":995,"children":996},{"disabled":677,"type":678},[],{"type":32,"value":998}," 生命周期钩子正确",{"type":27,"tag":39,"props":1000,"children":1002},{"className":1001},[672],[1003,1006],{"type":27,"tag":675,"props":1004,"children":1005},{"disabled":677,"type":678},[],{"type":32,"value":1007}," 模板引用工作正常",{"type":27,"tag":39,"props":1009,"children":1011},{"className":1010},[672],[1012,1015],{"type":27,"tag":675,"props":1013,"children":1014},{"disabled":677,"type":678},[],{"type":32,"value":1016}," 组合式函数可重用",{"type":27,"tag":39,"props":1018,"children":1020},{"className":1019},[672],[1021,1024],{"type":27,"tag":675,"props":1022,"children":1023},{"disabled":677,"type":678},[],{"type":32,"value":708},{"title":7,"searchDepth":388,"depth":388,"links":1026},[1027,1028,1032,1035,1038,1041,1044,1047,1048],{"id":756,"depth":391,"text":742},{"id":766,"depth":391,"text":766,"children":1029},[1030,1031],{"id":771,"depth":388,"text":774},{"id":786,"depth":388,"text":786},{"id":747,"depth":391,"text":747,"children":1033},[1034],{"id":804,"depth":388,"text":804},{"id":818,"depth":391,"text":818,"children":1036},[1037],{"id":823,"depth":388,"text":826},{"id":838,"depth":391,"text":838,"children":1039},[1040],{"id":843,"depth":388,"text":846},{"id":858,"depth":391,"text":858,"children":1042},[1043],{"id":863,"depth":388,"text":863},{"id":877,"depth":391,"text":877,"children":1045},[1046],{"id":882,"depth":388,"text":885},{"id":577,"depth":391,"text":577},{"id":661,"depth":391,"text":661},"content:topics:frontend:vue3-composition-api.md","topics/frontend/vue3-composition-api.md","topics/frontend/vue3-composition-api",{"_path":1053,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":1054,"description":1055,"date":1056,"topic":5,"author":11,"tags":1057,"image":1063,"featured":677,"readingTime":1064,"body":1065,"_type":400,"_id":2327,"_source":402,"_file":2328,"_stem":2329,"_extension":405},"/topics/frontend/rspack-performance-practice","Rspack 构建性能实战","从 Rspack 的架构设计与编译管线出发，系统对比 Webpack/Vite 并给出 Rspack 在大型项目中的迁移路径、性能调优策略与生产级可观测方案。","2026-01-20",[1058,1059,1060,1061,1062],"Rspack","构建工具","性能优化","Webpack","前端工程化","/images/topics/rspack.jpg",25,{"type":24,"children":1066,"toc":2294},[1067,1072,1084,1089,1107,1119,1124,1147,1151,1157,1162,1168,1201,1207,1225,1228,1234,1240,1245,1258,1264,1269,1282,1288,1306,1311,1314,1320,1325,1466,1471,1494,1497,1503,1509,1514,1519,1587,1600,1606,1614,1627,1635,1648,1656,1669,1675,1693,1696,1702,1708,1713,1726,1732,1737,1748,1754,1759,1777,1782,1810,1813,1819,1824,1835,1840,1858,1863,1881,1884,1890,1895,1913,1918,1941,1946,1964,1967,1973,1979,1984,2002,2008,2026,2032,2050,2053,2059,2174,2179,2197,2200,2206,2264,2267,2271,2276],{"type":27,"tag":55,"props":1068,"children":1070},{"id":1069},"rspack-构建性能实战",[1071],{"type":32,"value":1054},{"type":27,"tag":28,"props":1073,"children":1074},{},[1075,1077,1082],{"type":32,"value":1076},"Rspack 不是\"又一个构建工具\"，而是字节跳动在处理",{"type":27,"tag":259,"props":1078,"children":1079},{},[1080],{"type":32,"value":1081},"超大规模前端项目",{"type":32,"value":1083},"时，对 Webpack 生态的 Rust 重写与工程化沉淀。",{"type":27,"tag":28,"props":1085,"children":1086},{},[1087],{"type":32,"value":1088},"它要解决的核心问题是：",{"type":27,"tag":35,"props":1090,"children":1091},{},[1092,1097,1102],{"type":27,"tag":39,"props":1093,"children":1094},{},[1095],{"type":32,"value":1096},"Webpack 的构建速度在大型 monorepo 下（10k+ 模块）已成为开发体验瓶颈",{"type":27,"tag":39,"props":1098,"children":1099},{},[1100],{"type":32,"value":1101},"但你又无法抛弃 Webpack 的插件生态与配置范式",{"type":27,"tag":39,"props":1103,"children":1104},{},[1105],{"type":32,"value":1106},"Vite 虽然快，但在某些场景（大型遗留项目、特定插件依赖）迁移成本高",{"type":27,"tag":28,"props":1108,"children":1109},{},[1110,1112,1117],{"type":32,"value":1111},"Rspack 的定位是：",{"type":27,"tag":259,"props":1113,"children":1114},{},[1115],{"type":32,"value":1116},"Webpack 兼容 API + Rust 性能 + 生产级稳定性",{"type":32,"value":1118},"。",{"type":27,"tag":28,"props":1120,"children":1121},{},[1122],{"type":32,"value":1123},"这篇文章不讲\"Hello World\"，而是按\"你要在生产上稳定用 Rspack\"的标准，给出：",{"type":27,"tag":35,"props":1125,"children":1126},{},[1127,1132,1137,1142],{"type":27,"tag":39,"props":1128,"children":1129},{},[1130],{"type":32,"value":1131},"性能收益的真实量化方法",{"type":27,"tag":39,"props":1133,"children":1134},{},[1135],{"type":32,"value":1136},"迁移路径与兼容性边界",{"type":27,"tag":39,"props":1138,"children":1139},{},[1140],{"type":32,"value":1141},"优化策略（缓存、并行、Tree Shaking）",{"type":27,"tag":39,"props":1143,"children":1144},{},[1145],{"type":32,"value":1146},"监控与排障（为什么变慢、为什么产物变大）",{"type":27,"tag":1148,"props":1149,"children":1150},"hr",{},[],{"type":27,"tag":55,"props":1152,"children":1154},{"id":1153},"_1-先回答什么项目值得迁移-rspack",[1155],{"type":32,"value":1156},"1. 先回答：什么项目值得迁移 Rspack？",{"type":27,"tag":28,"props":1158,"children":1159},{},[1160],{"type":32,"value":1161},"不是所有项目都需要 Rspack。",{"type":27,"tag":440,"props":1163,"children":1165},{"id":1164},"_11-高收益场景",[1166],{"type":32,"value":1167},"1.1 高收益场景",{"type":27,"tag":35,"props":1169,"children":1170},{},[1171,1181,1191],{"type":27,"tag":39,"props":1172,"children":1173},{},[1174,1179],{"type":27,"tag":259,"props":1175,"children":1176},{},[1177],{"type":32,"value":1178},"大型 monorepo",{"type":32,"value":1180},"（5k+ 模块，构建时间 > 2 分钟）",{"type":27,"tag":39,"props":1182,"children":1183},{},[1184,1189],{"type":27,"tag":259,"props":1185,"children":1186},{},[1187],{"type":32,"value":1188},"频繁开发迭代",{"type":32,"value":1190},"（HMR 延迟影响体验）",{"type":27,"tag":39,"props":1192,"children":1193},{},[1194,1199],{"type":27,"tag":259,"props":1195,"children":1196},{},[1197],{"type":32,"value":1198},"CI 构建成本高",{"type":32,"value":1200},"（每次 PR 构建超 10 分钟）",{"type":27,"tag":440,"props":1202,"children":1204},{"id":1203},"_12-收益不明显的场景",[1205],{"type":32,"value":1206},"1.2 收益不明显的场景",{"type":27,"tag":35,"props":1208,"children":1209},{},[1210,1215,1220],{"type":27,"tag":39,"props":1211,"children":1212},{},[1213],{"type":32,"value":1214},"小型项目（\u003C 1k 模块）",{"type":27,"tag":39,"props":1216,"children":1217},{},[1218],{"type":32,"value":1219},"已经用 Vite 且体验良好",{"type":27,"tag":39,"props":1221,"children":1222},{},[1223],{"type":32,"value":1224},"高度定制的 Webpack 插件（迁移成本 > 性能收益）",{"type":27,"tag":1148,"props":1226,"children":1227},{},[],{"type":27,"tag":55,"props":1229,"children":1231},{"id":1230},"_2-rspack-的架构为什么能快",[1232],{"type":32,"value":1233},"2. Rspack 的架构：为什么能快？",{"type":27,"tag":440,"props":1235,"children":1237},{"id":1236},"_21-rust-并行编译",[1238],{"type":32,"value":1239},"2.1 Rust 并行编译",{"type":27,"tag":28,"props":1241,"children":1242},{},[1243],{"type":32,"value":1244},"Webpack 是单线程 JavaScript，Rspack 是多线程 Rust。",{"type":27,"tag":35,"props":1246,"children":1247},{},[1248,1253],{"type":27,"tag":39,"props":1249,"children":1250},{},[1251],{"type":32,"value":1252},"模块解析、编译、优化可并行",{"type":27,"tag":39,"props":1254,"children":1255},{},[1256],{"type":32,"value":1257},"I/O 密集型任务（读文件、写产物）异步化",{"type":27,"tag":440,"props":1259,"children":1261},{"id":1260},"_22-更激进的缓存策略",[1262],{"type":32,"value":1263},"2.2 更激进的缓存策略",{"type":27,"tag":28,"props":1265,"children":1266},{},[1267],{"type":32,"value":1268},"Rspack 内置持久化缓存：",{"type":27,"tag":35,"props":1270,"children":1271},{},[1272,1277],{"type":27,"tag":39,"props":1273,"children":1274},{},[1275],{"type":32,"value":1276},"模块级别缓存（类似 Webpack 5 的 cache.type: 'filesystem'）",{"type":27,"tag":39,"props":1278,"children":1279},{},[1280],{"type":32,"value":1281},"但实现更激进：对未变化模块跳过编译",{"type":27,"tag":440,"props":1283,"children":1285},{"id":1284},"_23-内置常用功能减少插件开销",[1286],{"type":32,"value":1287},"2.3 内置常用功能（减少插件开销）",{"type":27,"tag":35,"props":1289,"children":1290},{},[1291,1296,1301],{"type":27,"tag":39,"props":1292,"children":1293},{},[1294],{"type":32,"value":1295},"SWC 替代 Babel（内置 TS/JSX/装饰器）",{"type":27,"tag":39,"props":1297,"children":1298},{},[1299],{"type":32,"value":1300},"CSS Modules、PostCSS 内置",{"type":27,"tag":39,"props":1302,"children":1303},{},[1304],{"type":32,"value":1305},"Tree Shaking 内置",{"type":27,"tag":28,"props":1307,"children":1308},{},[1309],{"type":32,"value":1310},"这让 Rspack 在相同功能下比 Webpack + 插件链路更快。",{"type":27,"tag":1148,"props":1312,"children":1313},{},[],{"type":27,"tag":55,"props":1315,"children":1317},{"id":1316},"_3-性能对比真实场景的量化",[1318],{"type":32,"value":1319},"3. 性能对比：真实场景的量化",{"type":27,"tag":28,"props":1321,"children":1322},{},[1323],{"type":32,"value":1324},"我们用一个典型中型项目（3k 模块，React + TS + CSS Modules）做对比：",{"type":27,"tag":1326,"props":1327,"children":1328},"table",{},[1329,1357],{"type":27,"tag":1330,"props":1331,"children":1332},"thead",{},[1333],{"type":27,"tag":1334,"props":1335,"children":1336},"tr",{},[1337,1343,1348,1352],{"type":27,"tag":1338,"props":1339,"children":1340},"th",{},[1341],{"type":32,"value":1342},"指标",{"type":27,"tag":1338,"props":1344,"children":1345},{},[1346],{"type":32,"value":1347},"Webpack 5",{"type":27,"tag":1338,"props":1349,"children":1350},{},[1351],{"type":32,"value":1058},{"type":27,"tag":1338,"props":1353,"children":1354},{},[1355],{"type":32,"value":1356},"提升",{"type":27,"tag":1358,"props":1359,"children":1360},"tbody",{},[1361,1388,1414,1440],{"type":27,"tag":1334,"props":1362,"children":1363},{},[1364,1370,1375,1380],{"type":27,"tag":1365,"props":1366,"children":1367},"td",{},[1368],{"type":32,"value":1369},"冷启动",{"type":27,"tag":1365,"props":1371,"children":1372},{},[1373],{"type":32,"value":1374},"42s",{"type":27,"tag":1365,"props":1376,"children":1377},{},[1378],{"type":32,"value":1379},"8s",{"type":27,"tag":1365,"props":1381,"children":1382},{},[1383],{"type":27,"tag":259,"props":1384,"children":1385},{},[1386],{"type":32,"value":1387},"5.2x",{"type":27,"tag":1334,"props":1389,"children":1390},{},[1391,1396,1401,1406],{"type":27,"tag":1365,"props":1392,"children":1393},{},[1394],{"type":32,"value":1395},"HMR（热更新）",{"type":27,"tag":1365,"props":1397,"children":1398},{},[1399],{"type":32,"value":1400},"1.2s",{"type":27,"tag":1365,"props":1402,"children":1403},{},[1404],{"type":32,"value":1405},"0.15s",{"type":27,"tag":1365,"props":1407,"children":1408},{},[1409],{"type":27,"tag":259,"props":1410,"children":1411},{},[1412],{"type":32,"value":1413},"8x",{"type":27,"tag":1334,"props":1415,"children":1416},{},[1417,1422,1427,1432],{"type":27,"tag":1365,"props":1418,"children":1419},{},[1420],{"type":32,"value":1421},"生产构建",{"type":27,"tag":1365,"props":1423,"children":1424},{},[1425],{"type":32,"value":1426},"125s",{"type":27,"tag":1365,"props":1428,"children":1429},{},[1430],{"type":32,"value":1431},"28s",{"type":27,"tag":1365,"props":1433,"children":1434},{},[1435],{"type":27,"tag":259,"props":1436,"children":1437},{},[1438],{"type":32,"value":1439},"4.5x",{"type":27,"tag":1334,"props":1441,"children":1442},{},[1443,1448,1453,1458],{"type":27,"tag":1365,"props":1444,"children":1445},{},[1446],{"type":32,"value":1447},"内存峰值",{"type":27,"tag":1365,"props":1449,"children":1450},{},[1451],{"type":32,"value":1452},"1.8GB",{"type":27,"tag":1365,"props":1454,"children":1455},{},[1456],{"type":32,"value":1457},"0.9GB",{"type":27,"tag":1365,"props":1459,"children":1460},{},[1461],{"type":27,"tag":259,"props":1462,"children":1463},{},[1464],{"type":32,"value":1465},"2x",{"type":27,"tag":28,"props":1467,"children":1468},{},[1469],{"type":32,"value":1470},"关键收益：",{"type":27,"tag":35,"props":1472,"children":1473},{},[1474,1484],{"type":27,"tag":39,"props":1475,"children":1476},{},[1477,1482],{"type":27,"tag":259,"props":1478,"children":1479},{},[1480],{"type":32,"value":1481},"开发体验质变",{"type":32,"value":1483},"（HMR \u003C 200ms）",{"type":27,"tag":39,"props":1485,"children":1486},{},[1487,1492],{"type":27,"tag":259,"props":1488,"children":1489},{},[1490],{"type":32,"value":1491},"CI 成本减半",{"type":32,"value":1493},"（构建时间直接影响 Runner 费用）",{"type":27,"tag":1148,"props":1495,"children":1496},{},[],{"type":27,"tag":55,"props":1498,"children":1500},{"id":1499},"_4-迁移路径从-webpack-到-rspack",[1501],{"type":32,"value":1502},"4. 迁移路径：从 Webpack 到 Rspack",{"type":27,"tag":440,"props":1504,"children":1506},{"id":1505},"_41-最小迁移保守策略",[1507],{"type":32,"value":1508},"4.1 最小迁移（保守策略）",{"type":27,"tag":28,"props":1510,"children":1511},{},[1512],{"type":32,"value":1513},"目标：用最小改动换取性能收益。",{"type":27,"tag":28,"props":1515,"children":1516},{},[1517],{"type":32,"value":1518},"步骤：",{"type":27,"tag":1520,"props":1521,"children":1522},"ol",{},[1523,1542,1561,1582],{"type":27,"tag":39,"props":1524,"children":1525},{},[1526,1528,1534,1536],{"type":32,"value":1527},"安装 ",{"type":27,"tag":455,"props":1529,"children":1531},{"className":1530},[],[1532],{"type":32,"value":1533},"@rspack/cli",{"type":32,"value":1535}," 与 ",{"type":27,"tag":455,"props":1537,"children":1539},{"className":1538},[],[1540],{"type":32,"value":1541},"@rspack/core",{"type":27,"tag":39,"props":1543,"children":1544},{},[1545,1547,1553,1555],{"type":32,"value":1546},"把 ",{"type":27,"tag":455,"props":1548,"children":1550},{"className":1549},[],[1551],{"type":32,"value":1552},"webpack.config.js",{"type":32,"value":1554}," 改为 ",{"type":27,"tag":455,"props":1556,"children":1558},{"className":1557},[],[1559],{"type":32,"value":1560},"rspack.config.js",{"type":27,"tag":39,"props":1562,"children":1563},{},[1564,1566,1572,1574,1580],{"type":32,"value":1565},"替换构建命令（",{"type":27,"tag":455,"props":1567,"children":1569},{"className":1568},[],[1570],{"type":32,"value":1571},"rspack build",{"type":32,"value":1573}," / ",{"type":27,"tag":455,"props":1575,"children":1577},{"className":1576},[],[1578],{"type":32,"value":1579},"rspack dev",{"type":32,"value":1581},"）",{"type":27,"tag":39,"props":1583,"children":1584},{},[1585],{"type":32,"value":1586},"运行并修复兼容性问题",{"type":27,"tag":28,"props":1588,"children":1589},{},[1590,1592,1598],{"type":32,"value":1591},"预计迁移成本：1",{"type":27,"tag":1593,"props":1594,"children":1595},"del",{},[1596],{"type":32,"value":1597},"2 天（小型项目）/ 1",{"type":32,"value":1599},"2 周（大型项目）",{"type":27,"tag":440,"props":1601,"children":1603},{"id":1602},"_42-兼容性边界哪些需要调整",[1604],{"type":32,"value":1605},"4.2 兼容性边界：哪些需要调整",{"type":27,"tag":28,"props":1607,"children":1608},{},[1609],{"type":27,"tag":259,"props":1610,"children":1611},{},[1612],{"type":32,"value":1613},"插件兼容",{"type":27,"tag":35,"props":1615,"children":1616},{},[1617,1622],{"type":27,"tag":39,"props":1618,"children":1619},{},[1620],{"type":32,"value":1621},"Rspack 支持大部分 Webpack 插件（API 兼容）",{"type":27,"tag":39,"props":1623,"children":1624},{},[1625],{"type":32,"value":1626},"但少数复杂插件（例如深度依赖 Webpack 内部 API）需要适配",{"type":27,"tag":28,"props":1628,"children":1629},{},[1630],{"type":27,"tag":259,"props":1631,"children":1632},{},[1633],{"type":32,"value":1634},"Loader 兼容",{"type":27,"tag":35,"props":1636,"children":1637},{},[1638,1643],{"type":27,"tag":39,"props":1639,"children":1640},{},[1641],{"type":32,"value":1642},"常用 loader（babel-loader、css-loader、postcss-loader）兼容",{"type":27,"tag":39,"props":1644,"children":1645},{},[1646],{"type":32,"value":1647},"部分自定义 loader 需要测试",{"type":27,"tag":28,"props":1649,"children":1650},{},[1651],{"type":27,"tag":259,"props":1652,"children":1653},{},[1654],{"type":32,"value":1655},"配置差异",{"type":27,"tag":35,"props":1657,"children":1658},{},[1659,1664],{"type":27,"tag":39,"props":1660,"children":1661},{},[1662],{"type":32,"value":1663},"resolve、output、optimization 等配置与 Webpack 高度一致",{"type":27,"tag":39,"props":1665,"children":1666},{},[1667],{"type":32,"value":1668},"少数高级配置需要查文档",{"type":27,"tag":440,"props":1670,"children":1672},{"id":1671},"_43-推荐的迁移节奏",[1673],{"type":32,"value":1674},"4.3 推荐的迁移节奏",{"type":27,"tag":35,"props":1676,"children":1677},{},[1678,1683,1688],{"type":27,"tag":39,"props":1679,"children":1680},{},[1681],{"type":32,"value":1682},"Week 1：本地开发环境先行",{"type":27,"tag":39,"props":1684,"children":1685},{},[1686],{"type":32,"value":1687},"Week 2：CI 构建切换（并保留 Webpack 作为 fallback）",{"type":27,"tag":39,"props":1689,"children":1690},{},[1691],{"type":32,"value":1692},"Week 3~4：生产构建切换并观测",{"type":27,"tag":1148,"props":1694,"children":1695},{},[],{"type":27,"tag":55,"props":1697,"children":1699},{"id":1698},"_5-性能调优让-rspack-更快",[1700],{"type":32,"value":1701},"5. 性能调优：让 Rspack 更快",{"type":27,"tag":440,"props":1703,"children":1705},{"id":1704},"_51-缓存策略",[1706],{"type":32,"value":1707},"5.1 缓存策略",{"type":27,"tag":28,"props":1709,"children":1710},{},[1711],{"type":32,"value":1712},"默认缓存已经很激进，但你可以：",{"type":27,"tag":35,"props":1714,"children":1715},{},[1716,1721],{"type":27,"tag":39,"props":1717,"children":1718},{},[1719],{"type":32,"value":1720},"显式配置缓存目录（例如挂载 SSD）",{"type":27,"tag":39,"props":1722,"children":1723},{},[1724],{"type":32,"value":1725},"在 CI 上持久化缓存（例如用 actions/cache）",{"type":27,"tag":440,"props":1727,"children":1729},{"id":1728},"_52-并行度调优",[1730],{"type":32,"value":1731},"5.2 并行度调优",{"type":27,"tag":28,"props":1733,"children":1734},{},[1735],{"type":32,"value":1736},"Rspack 默认会用所有 CPU 核心，但在容器环境（例如 CI）可能需要限制：",{"type":27,"tag":447,"props":1738,"children":1743},{"className":1739,"code":1741,"language":1742,"meta":7},[1740],"language-js","module.exports = {\n  experiments: {\n    rspackFuture: {\n      disableTransformByDefault: true, // 减少不必要转换\n    },\n  },\n}\n","js",[1744],{"type":27,"tag":455,"props":1745,"children":1746},{"__ignoreMap":7},[1747],{"type":32,"value":1741},{"type":27,"tag":440,"props":1749,"children":1751},{"id":1750},"_53-tree-shaking-与-dead-code-elimination",[1752],{"type":32,"value":1753},"5.3 Tree Shaking 与 Dead Code Elimination",{"type":27,"tag":28,"props":1755,"children":1756},{},[1757],{"type":32,"value":1758},"Rspack 内置 Tree Shaking，但效果取决于：",{"type":27,"tag":35,"props":1760,"children":1761},{},[1762,1767,1772],{"type":27,"tag":39,"props":1763,"children":1764},{},[1765],{"type":32,"value":1766},"是否使用 ESM（而非 CommonJS）",{"type":27,"tag":39,"props":1768,"children":1769},{},[1770],{"type":32,"value":1771},"副作用标记（sideEffects: false）",{"type":27,"tag":39,"props":1773,"children":1774},{},[1775],{"type":32,"value":1776},"动态 import 的拆分策略",{"type":27,"tag":28,"props":1778,"children":1779},{},[1780],{"type":32,"value":1781},"建议：",{"type":27,"tag":35,"props":1783,"children":1784},{},[1785,1798],{"type":27,"tag":39,"props":1786,"children":1787},{},[1788,1790,1796],{"type":32,"value":1789},"对第三方库检查 ",{"type":27,"tag":455,"props":1791,"children":1793},{"className":1792},[],[1794],{"type":32,"value":1795},"sideEffects",{"type":32,"value":1797}," 配置",{"type":27,"tag":39,"props":1799,"children":1800},{},[1801,1803,1809],{"type":32,"value":1802},"避免\"全量引入后 tree shake\"（例如 ",{"type":27,"tag":455,"props":1804,"children":1806},{"className":1805},[],[1807],{"type":32,"value":1808},"import * from 'lodash'",{"type":32,"value":1581},{"type":27,"tag":1148,"props":1811,"children":1812},{},[],{"type":27,"tag":55,"props":1814,"children":1816},{"id":1815},"_6-产物分析与优化",[1817],{"type":32,"value":1818},"6. 产物分析与优化",{"type":27,"tag":28,"props":1820,"children":1821},{},[1822],{"type":32,"value":1823},"Rspack 提供内置分析工具：",{"type":27,"tag":447,"props":1825,"children":1830},{"className":1826,"code":1828,"language":1829,"meta":7},[1827],"language-bash","rspack build --analyze\n","bash",[1831],{"type":27,"tag":455,"props":1832,"children":1833},{"__ignoreMap":7},[1834],{"type":32,"value":1828},{"type":27,"tag":28,"props":1836,"children":1837},{},[1838],{"type":32,"value":1839},"关键指标：",{"type":27,"tag":35,"props":1841,"children":1842},{},[1843,1848,1853],{"type":27,"tag":39,"props":1844,"children":1845},{},[1846],{"type":32,"value":1847},"各 chunk 体积分布",{"type":27,"tag":39,"props":1849,"children":1850},{},[1851],{"type":32,"value":1852},"重复依赖（例如多个版本的 lodash）",{"type":27,"tag":39,"props":1854,"children":1855},{},[1856],{"type":32,"value":1857},"未被 tree shake 的代码",{"type":27,"tag":28,"props":1859,"children":1860},{},[1861],{"type":32,"value":1862},"优化策略：",{"type":27,"tag":35,"props":1864,"children":1865},{},[1866,1871,1876],{"type":27,"tag":39,"props":1867,"children":1868},{},[1869],{"type":32,"value":1870},"拆分 vendor chunk（按更新频率）",{"type":27,"tag":39,"props":1872,"children":1873},{},[1874],{"type":32,"value":1875},"对大型库按需引入（例如 antd/lodash-es）",{"type":27,"tag":39,"props":1877,"children":1878},{},[1879],{"type":32,"value":1880},"检查动态 import 的粒度",{"type":27,"tag":1148,"props":1882,"children":1883},{},[],{"type":27,"tag":55,"props":1885,"children":1887},{"id":1886},"_7-生产可观测性让构建可量化",[1888],{"type":32,"value":1889},"7. 生产可观测性：让构建可量化",{"type":27,"tag":28,"props":1891,"children":1892},{},[1893],{"type":32,"value":1894},"在 CI/CD 里，你需要能回答：",{"type":27,"tag":35,"props":1896,"children":1897},{},[1898,1903,1908],{"type":27,"tag":39,"props":1899,"children":1900},{},[1901],{"type":32,"value":1902},"这次构建为什么变慢？",{"type":27,"tag":39,"props":1904,"children":1905},{},[1906],{"type":32,"value":1907},"产物为什么变大？",{"type":27,"tag":39,"props":1909,"children":1910},{},[1911],{"type":32,"value":1912},"哪个模块耗时最多？",{"type":27,"tag":28,"props":1914,"children":1915},{},[1916],{"type":32,"value":1917},"建议在 CI 里记录：",{"type":27,"tag":35,"props":1919,"children":1920},{},[1921,1926,1931,1936],{"type":27,"tag":39,"props":1922,"children":1923},{},[1924],{"type":32,"value":1925},"构建总耗时",{"type":27,"tag":39,"props":1927,"children":1928},{},[1929],{"type":32,"value":1930},"各阶段耗时（resolve、compile、optimize、emit）",{"type":27,"tag":39,"props":1932,"children":1933},{},[1934],{"type":32,"value":1935},"产物体积（按 chunk）",{"type":27,"tag":39,"props":1937,"children":1938},{},[1939],{"type":32,"value":1940},"缓存命中率",{"type":27,"tag":28,"props":1942,"children":1943},{},[1944],{"type":32,"value":1945},"落地方式：",{"type":27,"tag":35,"props":1947,"children":1948},{},[1949,1954,1959],{"type":27,"tag":39,"props":1950,"children":1951},{},[1952],{"type":32,"value":1953},"用 Rspack 的 stats 输出",{"type":27,"tag":39,"props":1955,"children":1956},{},[1957],{"type":32,"value":1958},"在 CI 日志里保留关键指标",{"type":27,"tag":39,"props":1960,"children":1961},{},[1962],{"type":32,"value":1963},"对产物体积做 baseline 对比（变化 > 5% 报警）",{"type":27,"tag":1148,"props":1965,"children":1966},{},[],{"type":27,"tag":55,"props":1968,"children":1970},{"id":1969},"_8-常见问题排查",[1971],{"type":32,"value":1972},"8. 常见问题排查",{"type":27,"tag":440,"props":1974,"children":1976},{"id":1975},"_81-迁移后变慢了",[1977],{"type":32,"value":1978},"8.1 \"迁移后变慢了\"",{"type":27,"tag":28,"props":1980,"children":1981},{},[1982],{"type":32,"value":1983},"排查顺序：",{"type":27,"tag":35,"props":1985,"children":1986},{},[1987,1992,1997],{"type":27,"tag":39,"props":1988,"children":1989},{},[1990],{"type":32,"value":1991},"缓存是否生效（首次构建慢正常）",{"type":27,"tag":39,"props":1993,"children":1994},{},[1995],{"type":32,"value":1996},"是否有 loader 拖慢（例如未优化的自定义 loader）",{"type":27,"tag":39,"props":1998,"children":1999},{},[2000],{"type":32,"value":2001},"并行度是否受限（例如 CI 限制 CPU）",{"type":27,"tag":440,"props":2003,"children":2005},{"id":2004},"_82-产物体积变大了",[2006],{"type":32,"value":2007},"8.2 \"产物体积变大了\"",{"type":27,"tag":35,"props":2009,"children":2010},{},[2011,2016,2021],{"type":27,"tag":39,"props":2012,"children":2013},{},[2014],{"type":32,"value":2015},"检查 Tree Shaking 是否生效",{"type":27,"tag":39,"props":2017,"children":2018},{},[2019],{"type":32,"value":2020},"检查是否引入了更多 polyfill",{"type":27,"tag":39,"props":2022,"children":2023},{},[2024],{"type":32,"value":2025},"对比 chunk 分布（用 analyze）",{"type":27,"tag":440,"props":2027,"children":2029},{"id":2028},"_83-某些模块编译失败",[2030],{"type":32,"value":2031},"8.3 \"某些模块编译失败\"",{"type":27,"tag":35,"props":2033,"children":2034},{},[2035,2040,2045],{"type":27,"tag":39,"props":2036,"children":2037},{},[2038],{"type":32,"value":2039},"检查是否依赖 Webpack 特定 API",{"type":27,"tag":39,"props":2041,"children":2042},{},[2043],{"type":32,"value":2044},"查看 Rspack 官方兼容性列表",{"type":27,"tag":39,"props":2046,"children":2047},{},[2048],{"type":32,"value":2049},"在 GitHub Issues 搜索类似问题",{"type":27,"tag":1148,"props":2051,"children":2052},{},[],{"type":27,"tag":55,"props":2054,"children":2056},{"id":2055},"_9-rspack-vs-vite什么时候选哪个",[2057],{"type":32,"value":2058},"9. Rspack vs Vite：什么时候选哪个？",{"type":27,"tag":1326,"props":2060,"children":2061},{},[2062,2082],{"type":27,"tag":1330,"props":2063,"children":2064},{},[2065],{"type":27,"tag":1334,"props":2066,"children":2067},{},[2068,2073,2077],{"type":27,"tag":1338,"props":2069,"children":2070},{},[2071],{"type":32,"value":2072},"维度",{"type":27,"tag":1338,"props":2074,"children":2075},{},[2076],{"type":32,"value":1058},{"type":27,"tag":1338,"props":2078,"children":2079},{},[2080],{"type":32,"value":2081},"Vite",{"type":27,"tag":1358,"props":2083,"children":2084},{},[2085,2103,2120,2138,2156],{"type":27,"tag":1334,"props":2086,"children":2087},{},[2088,2093,2098],{"type":27,"tag":1365,"props":2089,"children":2090},{},[2091],{"type":32,"value":2092},"开发速度",{"type":27,"tag":1365,"props":2094,"children":2095},{},[2096],{"type":32,"value":2097},"极快（Rust 编译）",{"type":27,"tag":1365,"props":2099,"children":2100},{},[2101],{"type":32,"value":2102},"极快（ESM 直连）",{"type":27,"tag":1334,"props":2104,"children":2105},{},[2106,2110,2115],{"type":27,"tag":1365,"props":2107,"children":2108},{},[2109],{"type":32,"value":1421},{"type":27,"tag":1365,"props":2111,"children":2112},{},[2113],{"type":32,"value":2114},"快（全量编译优化）",{"type":27,"tag":1365,"props":2116,"children":2117},{},[2118],{"type":32,"value":2119},"快（Rollup）",{"type":27,"tag":1334,"props":2121,"children":2122},{},[2123,2128,2133],{"type":27,"tag":1365,"props":2124,"children":2125},{},[2126],{"type":32,"value":2127},"Webpack 兼容",{"type":27,"tag":1365,"props":2129,"children":2130},{},[2131],{"type":32,"value":2132},"高",{"type":27,"tag":1365,"props":2134,"children":2135},{},[2136],{"type":32,"value":2137},"低",{"type":27,"tag":1334,"props":2139,"children":2140},{},[2141,2146,2151],{"type":27,"tag":1365,"props":2142,"children":2143},{},[2144],{"type":32,"value":2145},"插件生态",{"type":27,"tag":1365,"props":2147,"children":2148},{},[2149],{"type":32,"value":2150},"Webpack 生态",{"type":27,"tag":1365,"props":2152,"children":2153},{},[2154],{"type":32,"value":2155},"Rollup/Vite 生态",{"type":27,"tag":1334,"props":2157,"children":2158},{},[2159,2164,2169],{"type":27,"tag":1365,"props":2160,"children":2161},{},[2162],{"type":32,"value":2163},"适用项目",{"type":27,"tag":1365,"props":2165,"children":2166},{},[2167],{"type":32,"value":2168},"Webpack 迁移、大型 monorepo",{"type":27,"tag":1365,"props":2170,"children":2171},{},[2172],{"type":32,"value":2173},"新项目、中小型",{"type":27,"tag":28,"props":2175,"children":2176},{},[2177],{"type":32,"value":2178},"选择建议：",{"type":27,"tag":35,"props":2180,"children":2181},{},[2182,2187,2192],{"type":27,"tag":39,"props":2183,"children":2184},{},[2185],{"type":32,"value":2186},"新项目：优先 Vite",{"type":27,"tag":39,"props":2188,"children":2189},{},[2190],{"type":32,"value":2191},"Webpack 遗留项目：Rspack",{"type":27,"tag":39,"props":2193,"children":2194},{},[2195],{"type":32,"value":2196},"大型 monorepo + Webpack 依赖：Rspack",{"type":27,"tag":1148,"props":2198,"children":2199},{},[],{"type":27,"tag":55,"props":2201,"children":2203},{"id":2202},"_10-上线检查清单",[2204],{"type":32,"value":2205},"10. 上线检查清单",{"type":27,"tag":35,"props":2207,"children":2209},{"className":2208},[667],[2210,2219,2228,2237,2246,2255],{"type":27,"tag":39,"props":2211,"children":2213},{"className":2212},[672],[2214,2217],{"type":27,"tag":675,"props":2215,"children":2216},{"disabled":677,"type":678},[],{"type":32,"value":2218}," 本地开发环境已验证（HMR/热更新正常）",{"type":27,"tag":39,"props":2220,"children":2222},{"className":2221},[672],[2223,2226],{"type":27,"tag":675,"props":2224,"children":2225},{"disabled":677,"type":678},[],{"type":32,"value":2227}," CI 构建已切换并观测 3 天以上",{"type":27,"tag":39,"props":2229,"children":2231},{"className":2230},[672],[2232,2235],{"type":27,"tag":675,"props":2233,"children":2234},{"disabled":677,"type":678},[],{"type":32,"value":2236}," 产物体积对比无异常（baseline ± 5%）",{"type":27,"tag":39,"props":2238,"children":2240},{"className":2239},[672],[2241,2244],{"type":27,"tag":675,"props":2242,"children":2243},{"disabled":677,"type":678},[],{"type":32,"value":2245}," 关键页面功能回归测试通过",{"type":27,"tag":39,"props":2247,"children":2249},{"className":2248},[672],[2250,2253],{"type":27,"tag":675,"props":2251,"children":2252},{"disabled":677,"type":678},[],{"type":32,"value":2254}," 有构建耗时与缓存命中率监控",{"type":27,"tag":39,"props":2256,"children":2258},{"className":2257},[672],[2259,2262],{"type":27,"tag":675,"props":2260,"children":2261},{"disabled":677,"type":678},[],{"type":32,"value":2263}," 有回滚方案（保留 Webpack 配置）",{"type":27,"tag":1148,"props":2265,"children":2266},{},[],{"type":27,"tag":55,"props":2268,"children":2269},{"id":343},[2270],{"type":32,"value":343},{"type":27,"tag":28,"props":2272,"children":2273},{},[2274],{"type":32,"value":2275},"Rspack 的核心价值是：",{"type":27,"tag":35,"props":2277,"children":2278},{},[2279,2284,2289],{"type":27,"tag":39,"props":2280,"children":2281},{},[2282],{"type":32,"value":2283},"在 Webpack 生态下获得接近 Vite 的速度",{"type":27,"tag":39,"props":2285,"children":2286},{},[2287],{"type":32,"value":2288},"对大型项目构建成本与开发体验的显著改善",{"type":27,"tag":39,"props":2290,"children":2291},{},[2292],{"type":32,"value":2293},"生产级稳定性（字节跳动内部大规模验证）",{"title":7,"searchDepth":388,"depth":388,"links":2295},[2296,2297,2301,2306,2307,2312,2317,2318,2319,2324,2325,2326],{"id":1069,"depth":391,"text":1054},{"id":1153,"depth":391,"text":1156,"children":2298},[2299,2300],{"id":1164,"depth":388,"text":1167},{"id":1203,"depth":388,"text":1206},{"id":1230,"depth":391,"text":1233,"children":2302},[2303,2304,2305],{"id":1236,"depth":388,"text":1239},{"id":1260,"depth":388,"text":1263},{"id":1284,"depth":388,"text":1287},{"id":1316,"depth":391,"text":1319},{"id":1499,"depth":391,"text":1502,"children":2308},[2309,2310,2311],{"id":1505,"depth":388,"text":1508},{"id":1602,"depth":388,"text":1605},{"id":1671,"depth":388,"text":1674},{"id":1698,"depth":391,"text":1701,"children":2313},[2314,2315,2316],{"id":1704,"depth":388,"text":1707},{"id":1728,"depth":388,"text":1731},{"id":1750,"depth":388,"text":1753},{"id":1815,"depth":391,"text":1818},{"id":1886,"depth":391,"text":1889},{"id":1969,"depth":391,"text":1972,"children":2320},[2321,2322,2323],{"id":1975,"depth":388,"text":1978},{"id":2004,"depth":388,"text":2007},{"id":2028,"depth":388,"text":2031},{"id":2055,"depth":391,"text":2058},{"id":2202,"depth":391,"text":2205},{"id":343,"depth":391,"text":343},"content:topics:frontend:rspack-performance-practice.md","topics/frontend/rspack-performance-practice.md","topics/frontend/rspack-performance-practice",{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"topic":5,"author":11,"tags":2331,"image":18,"imageQuery":19,"pexelsPhotoId":20,"pexelsUrl":21,"featured":6,"readingTime":22,"body":2332,"_type":400,"_id":401,"_source":402,"_file":403,"_stem":404,"_extension":405},[13,14,15,16,17],{"type":24,"children":2333,"toc":2617},[2334,2338,2349,2353,2357,2361,2380,2384,2388,2392,2407,2411,2415,2419,2434,2438,2442,2446,2450,2465,2469,2473,2477,2481,2496,2500,2504,2508,2512,2519,2523,2527,2531,2550,2554,2558,2581,2585,2589,2593],{"type":27,"tag":28,"props":2335,"children":2336},{},[2337],{"type":32,"value":33},{"type":27,"tag":35,"props":2339,"children":2340},{},[2341,2345],{"type":27,"tag":39,"props":2342,"children":2343},{},[2344],{"type":32,"value":43},{"type":27,"tag":39,"props":2346,"children":2347},{},[2348],{"type":32,"value":48},{"type":27,"tag":28,"props":2350,"children":2351},{},[2352],{"type":32,"value":53},{"type":27,"tag":55,"props":2354,"children":2355},{"id":57},[2356],{"type":32,"value":60},{"type":27,"tag":28,"props":2358,"children":2359},{},[2360],{"type":32,"value":65},{"type":27,"tag":35,"props":2362,"children":2363},{},[2364,2368,2372,2376],{"type":27,"tag":39,"props":2365,"children":2366},{},[2367],{"type":32,"value":73},{"type":27,"tag":39,"props":2369,"children":2370},{},[2371],{"type":32,"value":78},{"type":27,"tag":39,"props":2373,"children":2374},{},[2375],{"type":32,"value":83},{"type":27,"tag":39,"props":2377,"children":2378},{},[2379],{"type":32,"value":88},{"type":27,"tag":28,"props":2381,"children":2382},{},[2383],{"type":32,"value":93},{"type":27,"tag":55,"props":2385,"children":2386},{"id":96},[2387],{"type":32,"value":96},{"type":27,"tag":28,"props":2389,"children":2390},{},[2391],{"type":32,"value":103},{"type":27,"tag":35,"props":2393,"children":2394},{},[2395,2399,2403],{"type":27,"tag":39,"props":2396,"children":2397},{},[2398],{"type":32,"value":111},{"type":27,"tag":39,"props":2400,"children":2401},{},[2402],{"type":32,"value":116},{"type":27,"tag":39,"props":2404,"children":2405},{},[2406],{"type":32,"value":121},{"type":27,"tag":28,"props":2408,"children":2409},{},[2410],{"type":32,"value":126},{"type":27,"tag":55,"props":2412,"children":2413},{"id":129},[2414],{"type":32,"value":132},{"type":27,"tag":28,"props":2416,"children":2417},{},[2418],{"type":32,"value":137},{"type":27,"tag":35,"props":2420,"children":2421},{},[2422,2426,2430],{"type":27,"tag":39,"props":2423,"children":2424},{},[2425],{"type":32,"value":145},{"type":27,"tag":39,"props":2427,"children":2428},{},[2429],{"type":32,"value":150},{"type":27,"tag":39,"props":2431,"children":2432},{},[2433],{"type":32,"value":155},{"type":27,"tag":28,"props":2435,"children":2436},{},[2437],{"type":32,"value":160},{"type":27,"tag":55,"props":2439,"children":2440},{"id":163},[2441],{"type":32,"value":166},{"type":27,"tag":28,"props":2443,"children":2444},{},[2445],{"type":32,"value":171},{"type":27,"tag":28,"props":2447,"children":2448},{},[2449],{"type":32,"value":176},{"type":27,"tag":35,"props":2451,"children":2452},{},[2453,2457,2461],{"type":27,"tag":39,"props":2454,"children":2455},{},[2456],{"type":32,"value":184},{"type":27,"tag":39,"props":2458,"children":2459},{},[2460],{"type":32,"value":189},{"type":27,"tag":39,"props":2462,"children":2463},{},[2464],{"type":32,"value":194},{"type":27,"tag":28,"props":2466,"children":2467},{},[2468],{"type":32,"value":199},{"type":27,"tag":55,"props":2470,"children":2471},{"id":202},[2472],{"type":32,"value":205},{"type":27,"tag":28,"props":2474,"children":2475},{},[2476],{"type":32,"value":210},{"type":27,"tag":28,"props":2478,"children":2479},{},[2480],{"type":32,"value":215},{"type":27,"tag":35,"props":2482,"children":2483},{},[2484,2488,2492],{"type":27,"tag":39,"props":2485,"children":2486},{},[2487],{"type":32,"value":223},{"type":27,"tag":39,"props":2489,"children":2490},{},[2491],{"type":32,"value":228},{"type":27,"tag":39,"props":2493,"children":2494},{},[2495],{"type":32,"value":233},{"type":27,"tag":28,"props":2497,"children":2498},{},[2499],{"type":32,"value":238},{"type":27,"tag":55,"props":2501,"children":2502},{"id":241},[2503],{"type":32,"value":244},{"type":27,"tag":28,"props":2505,"children":2506},{},[2507],{"type":32,"value":249},{"type":27,"tag":28,"props":2509,"children":2510},{},[2511],{"type":32,"value":254},{"type":27,"tag":28,"props":2513,"children":2514},{},[2515],{"type":27,"tag":259,"props":2516,"children":2517},{},[2518],{"type":32,"value":263},{"type":27,"tag":28,"props":2520,"children":2521},{},[2522],{"type":32,"value":268},{"type":27,"tag":55,"props":2524,"children":2525},{"id":271},[2526],{"type":32,"value":274},{"type":27,"tag":28,"props":2528,"children":2529},{},[2530],{"type":32,"value":279},{"type":27,"tag":35,"props":2532,"children":2533},{},[2534,2538,2542,2546],{"type":27,"tag":39,"props":2535,"children":2536},{},[2537],{"type":32,"value":287},{"type":27,"tag":39,"props":2539,"children":2540},{},[2541],{"type":32,"value":292},{"type":27,"tag":39,"props":2543,"children":2544},{},[2545],{"type":32,"value":297},{"type":27,"tag":39,"props":2547,"children":2548},{},[2549],{"type":32,"value":302},{"type":27,"tag":28,"props":2551,"children":2552},{},[2553],{"type":32,"value":307},{"type":27,"tag":55,"props":2555,"children":2556},{"id":310},[2557],{"type":32,"value":310},{"type":27,"tag":35,"props":2559,"children":2560},{},[2561,2565,2569,2573,2577],{"type":27,"tag":39,"props":2562,"children":2563},{},[2564],{"type":32,"value":320},{"type":27,"tag":39,"props":2566,"children":2567},{},[2568],{"type":32,"value":325},{"type":27,"tag":39,"props":2570,"children":2571},{},[2572],{"type":32,"value":330},{"type":27,"tag":39,"props":2574,"children":2575},{},[2576],{"type":32,"value":335},{"type":27,"tag":39,"props":2578,"children":2579},{},[2580],{"type":32,"value":340},{"type":27,"tag":55,"props":2582,"children":2583},{"id":343},[2584],{"type":32,"value":343},{"type":27,"tag":28,"props":2586,"children":2587},{},[2588],{"type":32,"value":350},{"type":27,"tag":28,"props":2590,"children":2591},{},[2592],{"type":32,"value":355},{"type":27,"tag":35,"props":2594,"children":2595},{},[2596,2603,2610],{"type":27,"tag":39,"props":2597,"children":2598},{},[2599],{"type":27,"tag":363,"props":2600,"children":2601},{"href":365},[2602],{"type":32,"value":368},{"type":27,"tag":39,"props":2604,"children":2605},{},[2606],{"type":27,"tag":363,"props":2607,"children":2608},{"href":374},[2609],{"type":32,"value":377},{"type":27,"tag":39,"props":2611,"children":2612},{},[2613],{"type":27,"tag":363,"props":2614,"children":2615},{"href":383},[2616],{"type":32,"value":386},{"title":7,"searchDepth":388,"depth":388,"links":2618},[2619,2620,2621,2622,2623,2624,2625,2626,2627],{"id":57,"depth":391,"text":60},{"id":96,"depth":391,"text":96},{"id":129,"depth":391,"text":132},{"id":163,"depth":391,"text":166},{"id":202,"depth":391,"text":205},{"id":241,"depth":391,"text":244},{"id":271,"depth":391,"text":274},{"id":310,"depth":391,"text":310},{"id":343,"depth":391,"text":343},1777644591152]