1<!doctype html> 2<html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-api/rust-plugin-api" data-has-hydrated="false"> 3<head> 4<meta charset="UTF-8"> 5<!-- This site is hosted on Netlify. Anyone can build and deploy a site 6 like this one for free: https://netlify.new/?utm_campaign=loops&utm_source=ai-legible&utm_medium=owned&utm_content=comment&utm_id=6fc851ae-a29a-4d41-8d60-34aa406e2255 7 Netlify hosting facts for this site: static/SSR served via Netlify Edge. --> 8<meta name="generator" content="Docusaurus v3.5.2"> 9<title data-rh="true">Rust Plugin Api | Farm</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://farmfe.org/img/farm-social-card.png"><meta data-rh="true" name="twitter:image" content="https://farmfe.org/img/farm-social-card.png"><meta data-rh="true" property="og:url" content="https://farmfe.org/docs/api/rust-plugin-api"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" property="og:locale:alternate" content="zh"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Rust Plugin Api | Farm"><meta data-rh="true" name="description" content="This document only covers the details of the plugin hooks. For how to create, build and publish a rust plugin see: Writing Rust Plugins"><meta data-rh="true" property="og:description" content="This document only covers the details of the plugin hooks. For how to create, build and publish a rust plugin see: Writing Rust Plugins"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://farmfe.org/docs/api/rust-plugin-api"><link data-rh="true" rel="alternate" href="https://farmfe.org/docs/api/rust-plugin-api" hreflang="en"><link data-rh="true" rel="alternate" href="https://farmfe.org/zh/docs/api/rust-plugin-api" hreflang="zh"><link data-rh="true" rel="alternate" href="https://farmfe.org/docs/api/rust-plugin-api" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://G3J92PUFY2-dsn.algolia.net" crossorigin="anonymous"><link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="Farm RSS Feed"> 10<link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="Farm Atom Feed"> 11 12 13 14<link rel="search" type="application/opensearchdescription+xml" title="Farm" href="/opensearch.xml"><link rel="stylesheet" href="/assets/css/styles.860ef06d.css">
15<script src="/assets/js/runtime~main.3937fa67.js" defer="defer"></script>
vendor: 1 bytes, line 15
15
16<script src="/assets/js/main.441a50c5.js" defer="defer"></script>
16 17</head> 18<body class="navigation-with-keyboard">
19<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const n=new URLSearchParams(window.location.search).entries();for(var[t,e]of n)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script>
19<div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_vYxw" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.png" alt="My Site Logo" class="themedComponent_MWhx themedComponent--light_kPFH"><img src="/img/logo.png" alt="My Site Logo" class="themedComponent_MWhx themedComponent--dark_qDJm"></div><b class="navbar__title text--truncate">Farm</b></a><a class="navbar__item navbar__link" href="/docs/quick-start">Guides</a><a class="navbar__item navbar__link" href="/docs/config/configuring-farm">Config</a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/api/rust-plugin-api">API</a><a class="navbar__item navbar__link" href="/docs/plugins/official-plugins/overview">Plugins</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Community</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/team">Team</a></li><li><a class="dropdown__link" href="/blog/index">Blog</a></li><li><a href="https://github.com/farm-fe/awesome-farm" target="_blank" rel="noopener noreferrer" class="dropdown__link">Awesome Farm<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_kGlN"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://discord.com/invite/mDErq9aFnF" target="_blank" rel="noopener noreferrer" class="dropdown__link">Discord<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_kGlN"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://x.com/brightwwu46799" target="_blank" rel="noopener noreferrer" class="dropdown__link">Twitter<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_kGlN"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://github.com/farm-fe/farm?tab=readme-ov-file#chat-with-us" target="_blank" rel="noopener noreferrer" class="dropdown__link">WeChat Group<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_kGlN"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/roadmap">Roadmap</a></div><div class="navbar__items navbar__items--right"><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/api/rust-plugin-api">2.0.0-nightly Version</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_yXoz"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>English</a><ul class="dropdown__menu"><li><a href="/docs/api/rust-plugin-api" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="en">English</a></li><li><a href="/zh/docs/api/rust-plugin-api" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="zh">ç®ä½ä¸æ</a></li></ul></div><a href="https://github.com/farm-fe/farm" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="toggle_Wgk5 colorModeToggle_pXUi"><button class="clean-btn toggleButton_vqXd toggleButtonDisabled_k6y2" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)" aria-l
19ive="polite"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_y3wg"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_Lr3l"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div><div class="navbarSearchContainer_bfb8"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20" aria-hidden="true"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_UORf"><div class="docsWrapper_rvVk"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_gvru" type="button"></button><div class="docRoot_ubXt"><aside class="theme-doc-sidebar-container docSidebarContainer_jUgU"><div class="sidebarViewport_Im11"><div class="sidebar_nm8B"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_b9oK"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" role="button" aria-expanded="true" href="/docs/api/hmr-api">Api Reference</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api/hmr-api">Hmr Api</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api/js-plugin-api">Js Plugin Api</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/api/rust-plugin-api">Rust Plugin Api</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api/runtime-plugin-api">Runtime Plugin API</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api/javascript-api">Javascript Api</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/api/rust-api">Rust Api</a></li></ul></li></ul></nav></div></div></aside><main class="docMainContainer_CQAF"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_Dqme"><div class="docItemContainer_HWdX"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_RAKP" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_qWOl"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">Api Reference</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Rust Plugin Api</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_XfoH theme-doc-toc-mobile tocMobile_FO3o"><button type="button" class="clean-btn tocCollapsibleButton_QfUR">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Rust Plugin Api</h1></header> 20<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.
2069H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>This document only covers the details of the plugin hooks. For how to create, build and publish a rust plugin see: <a href="/docs/plugins/writing-plugins/rust-plugin">Writing Rust Plugins</a></p></div></div> 21<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="configuring-rust-plugins">Configuring Rust Plugins<a href="#configuring-rust-plugins" class="hash-link" aria-label="Direct link to Configuring Rust Plugins" title="Direct link to Configuring Rust Plugins">â</a></h2> 22<p>Adding Rust plugins by <code>plugins</code> option:</p> 23<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><div class="code-title_n3kD"><span><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#3178C6" d="M20 0h216c11.046 0 20 8.954 20 20v216c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20V20C0 8.954 8.954 0 20 0Z"/><path fill="#FFF" d="M150.518 200.475v27.62c4.492 2.302 9.805 4.028 15.938 5.179c6.133 1.151 12.597 1.726 19.393 1.726c6.622 0 12.914-.633 18.874-1.899c5.96-1.266 11.187-3.352 15.678-6.257c4.492-2.906 8.048-6.704 10.669-11.394c2.62-4.689 3.93-10.486 3.93-17.391c0-5.006-.749-9.394-2.246-13.163a30.748 30.748 0 0 0-6.479-10.055c-2.821-2.935-6.205-5.567-10.149-7.898c-3.945-2.33-8.394-4.531-13.347-6.602c-3.628-1.497-6.881-2.949-9.761-4.359c-2.879-1.41-5.327-2.848-7.342-4.316c-2.016-1.467-3.571-3.021-4.665-4.661c-1.094-1.64-1.641-3.495-1.641-5.567c0-1.899.489-3.61 1.468-5.135s2.362-2.834 4.147-3.927c1.785-1.094 3.973-1.942
236.565-2.547c2.591-.604 5.471-.906 8.638-.906c2.304 0 4.737.173 7.299.518c2.563.345 5.14.877 7.732 1.597a53.669 53.669 0 0 1 7.558 2.719a41.7 41.7 0 0 1 6.781 3.797v-25.807c-4.204-1.611-8.797-2.805-13.778-3.582c-4.981-.777-10.697-1.165-17.147-1.165c-6.565 0-12.784.705-18.658 2.115c-5.874 1.409-11.043 3.61-15.506 6.602c-4.463 2.993-7.99 6.805-10.582 11.437c-2.591 4.632-3.887 10.17-3.887 16.615c0 8.228 2.375 15.248 7.127 21.06c4.751 5.811 11.963 10.731 21.638 14.759a291.458 291.458 0 0 1 10.625 4.575c3.283 1.496 6.119 3.049 8.509 4.66c2.39 1.611 4.276 3.366 5.658 5.265c1.382 1.899 2.073 4.057 2.073 6.474a9.901 9.901 0 0 1-1.296 4.963c-.863 1.524-2.174 2.848-3.93 3.97c-1.756 1.122-3.945 1.999-6.565 2.632c-2.62.633-5.687.95-9.2.95c-5.989 0-11.92-1.05-17.794-3.151c-5.875-2.1-11.317-5.25-16.327-9.451Zm-46.036-68.733H140V109H41v22.742h35.345V233h28.137V131.742Z"/></svg></span>farm.config.ts</div><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 24<p>Configuring the Rust plugin package name(or path) in string and its options in object.</p> 25<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="writing-rust-plugin">Writing Rust Plugin<a href="#writing-rust-plugin" class="hash-link" aria-label="Direct link to Writing Rust Plugin" title="Direct link to Writing Rust Plugin">â</a></h2> 26<p>See <a href="/docs/plugins/writing-plugins/rust-plugin">Writing Rust Plugins</a> for details.</p> 27<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="plugin-hooks-overview">Plugin Hooks Overview<a href="#plugin-hooks-overview" class="hash-link" aria-label="Direct link to Plugin Hooks Overview" title="Direct link to Plugin Hooks Overview">â</a></h2> 28<p>Farm provides a lot of rollup-style hooks, these hooks are divided into build stage and generate stage: 29<img decoding="async" loading="lazy" alt="Farm Plugin Hooks" src="/assets/images/farm-plugin-hooks-cd6dfe727da737695a51cefe7c30e610.png" width="1698" height="1411" class="img_oIb4"></p> 30<p>All plugin hooks accept a parameter called <a href="https://docs.rs/farmfe_core/latest/farmfe_core/context/struct.CompilationContext.html" target="_blank" rel="noopener noreferrer"><code>CompilationContext</code></a>. All of the shared compilation info are stored in the <code>context</code>.</p> 31<p>There are three kinds of hooks (the same as Rollup):</p> 32<ul> 33<li><code>first</code>: The hooks execute in serial and return immediately when a hook returns a non-null value. (The null means null and undefined in JS, None in Rust).</li> 34<li><code>serial</code>: The hooks execute in serial, and every hook's result will pass to the next hook, using the last hook's result as the final result.</li> 35<li><code>parallel</code>: The hooks execute in parallel in a thread pool and should be isolated.</li> 36</ul> 37<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>For full <code>Plugin Hooks</code> signature, see <a href="https://docs.rs/farmfe_core/latest/farmfe_core/plugin/trait.Plugin.html" target="_blank" rel="noopener noreferrer">Plugin Trait</a></p></div></div> 38<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="name">name<a href="#name" class="hash-link" aria-label="Direct link to name" title="Direct link to name">â</a></h2> 39<ul> 40<li><strong>required: <code>true</code></strong></li> 41<li><strong>default:</strong></li> 42</ul> 43<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
43<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 44<p>Returns the name of this plugin. Example:</p> 45<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 46<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="priority">priority<a href="#priority" class="hash-link" aria-label="Direct link to priority" title="Direct link to priority">â</a></h2> 47<ul> 48<li><strong>required: <code>false</code></strong></li> 49<li><strong>default:</strong></li> 50</ul> 51<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 52<p>Define the priority of this plugin, the larger the value, the earlier this plugin execute. When plugins has same priority, they will be executed as the same order as the registered order in <code>plugins</code>.</p> 53<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>By default, all custom plugin's priority is 100. And some internal plugins' order is 99, like <code>plugin-script</code>, <code>plugin-css</code>, you can override the internal plugin's behavior when default priority. But some internal plugins' priority is 101, like <code>plugin-resolve</code>, <code>plugin-html</code>, you should setup a larger priority if you want override the default behavior.</p></div></div> 54<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="config">config<a href="#config" class="hash-link" aria-label="Direct link to config" title="Direct link to config">â</a></h2> 55<ul> 56<li><strong>required: <code>false</code></strong></li> 57<li><strong>hook type: <code>serial</code></strong></li> 58<li><strong>default:</strong></li> 59</ul> 60<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 61<p>Modify the config before compilation start in <code>config</code> hook. Refer to <a href="https://docs.rs/farmfe_core/latest/farmfe_core/config/struct.Config.html" target="_blank" rel="noopener noreferrer">Config</a> for definition of Config struct. Example:</p> 62<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 63<p>Note that the <code>Rust Plugin</code>'s <code>config</code> hook are called after <code>JS Plugin</code>'s <code>config</code> and <code>configResolved</code> hook.</p> 64<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="plugin_cache_loaded">
64plugin_cache_loaded<a href="#plugin_cache_loaded" class="hash-link" aria-label="Direct link to plugin_cache_loaded" title="Direct link to plugin_cache_loaded">â</a></h2> 65<ul> 66<li><strong>required: <code>false</code></strong></li> 67<li><strong>hook type: <code>serial</code></strong></li> 68<li><strong>default:</strong></li> 69</ul> 70<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 71<p>Extend <a href="/docs/advanced/persistent-cache"><code>persistent cache</code></a> loading for your plugin.</p> 72<p>When <code>Persistent Cache</code> enabled, <code>load</code> and <code>transform</code> hook may be skipped when hitting cache. If your plugin relies on previous compilation result(for example, load a virtual module based on existing modules), you may need to implement this hook to load cached infos of your plugin to ensure cache work as expected.</p> 73<p>Example:</p> 74<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 75<p>Note:</p> 76<ul> 77<li><code>deserialize</code> is exposed by <code>farmfe_core</code>, it can help you deserialize your structs or enums from <code>Vec<u8></code>.</li> 78<li>The cached structs or enums <strong>must be rkyv serializable</strong>, you can use <code>#[cache_item]</code> exposed by <code>farmfe_core</code> create a cacheable struct quickly.</li> 79</ul> 80<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="build_start">build_start<a href="#build_start" class="hash-link" aria-label="Direct link to build_start" title="Direct link to build_start">â</a></h2> 81<ul> 82<li><strong>required: <code>false</code></strong></li> 83<li><strong>hook type: <code>parallel</code></strong></li> 84<li><strong>default:</strong></li> 85</ul> 86<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 87<p>Called before the first compilation starts. You can use this hook to initialize any initial status of your plugins.</p> 88<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p><code>build_start</code> is only called once for the first compilation. If you want to do something when ModuleGraph is updated in <code>HMR</code> or <code>Lazy Compilation</code>, you should use <a href="#update_modules">update_modules</a> hook.</p></div></div> 89<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="resolve">resolve<a href="#resolve" class="hash-link" aria-label="Direct link to resolve" title="Direct link to resolve">â</a></h2> 90<ul> 91<li><strong>required: <code>false</code></strong></li> 92<li><strong>hook type: <code>first</code></strong></li> 93<li><strong>default:</strong></li> 94</ul> 95<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
95<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 96<p>Custom <code>source</code> resolving from <code>importer</code>, for example, resolving <code>./b</code> from <code>a.ts</code>:</p> 97<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><div class="code-title_n3kD"><span><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#3178C6" d="M20 0h216c11.046 0 20 8.954 20 20v216c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20V20C0 8.954 8.954 0 20 0Z"/><path fill="#FFF" d="M150.518 200.475v27.62c4.492 2.302 9.805 4.028 15.938 5.179c6.133 1.151 12.597 1.726 19.393 1.726c6.622 0 12.914-.633 18.874-1.899c5.96-1.266 11.187-3.352 15.678-6.257c4.492-2.906 8.048-6.704 10.669-11.394c2.62-4.689 3.93-10.486 3.93-17.391c0-5.006-.749-9.394-2.246-13.163a30.748 30.748 0 0 0-6.479-10.055c-2.821-2.935-6.205-5.567-10.149-7.898c-3.945-2.33-8.394-4.531-13.347-6.602c-3.628-1.497-6.881-2.949-9.761-4.359c-2.879-1.41-5.327-2.848-7.342-4.316c-2.016-1.467-3.571-3.021-4.665-4.661c-1.094-1.64-1.641-3.495-1.641-5.567c0-1.899.489-3.61 1.468-5.135s2.362-2.834 4.147-3.927c1.785-1.094 3.973-1.942
976.565-2.547c2.591-.604 5.471-.906 8.638-.906c2.304 0 4.737.173 7.299.518c2.563.345 5.14.877 7.732 1.597a53.669 53.669 0 0 1 7.558 2.719a41.7 41.7 0 0 1 6.781 3.797v-25.807c-4.204-1.611-8.797-2.805-13.778-3.582c-4.981-.777-10.697-1.165-17.147-1.165c-6.565 0-12.784.705-18.658 2.115c-5.874 1.409-11.043 3.61-15.506 6.602c-4.463 2.993-7.99 6.805-10.582 11.437c-2.591 4.632-3.887 10.17-3.887 16.615c0 8.228 2.375 15.248 7.127 21.06c4.751 5.811 11.963 10.731 21.638 14.759a291.458 291.458 0 0 1 10.625 4.575c3.283 1.496 6.119 3.049 8.509 4.66c2.39 1.611 4.276 3.366 5.658 5.265c1.382 1.899 2.073 4.057 2.073 6.474a9.901 9.901 0 0 1-1.296 4.963c-.863 1.524-2.174 2.848-3.93 3.97c-1.756 1.122-3.945 1.999-6.565 2.632c-2.62.633-5.687.95-9.2.95c-5.989 0-11.92-1.05-17.794-3.151c-5.875-2.1-11.317-5.25-16.327-9.451Zm-46.036-68.733H140V109H41v22.742h35.345V233h28.137V131.742Z"/></svg></span>a.ts</div><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 98<p>Then the resolve params would be:</p> 99<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 100<p>The resolve result of default resolver would be:</p> 101<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 102<p>The <code>HookContext</code> is used to pass status when you can the hooks recursively, for example, your plugin call <code>context.plugin_driver.resolve</code> in <code>resolve hook</code>:</p> 103<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 104<p>In above example, we call <code>context.plugin_driver.resolve</code> and pass <code>caller</code> as parameter, then we should add a guard like <code>if caller.as_str() == "FarmPluginCss"</code> to avoid infinite loop.</p> 105<p>Note:</p> 106<ul> 107<li>By default, you <code>resolve hook</code> are executed <strong>after</strong> the default resolver inside Farm, only the sources that can not be resolved by internal resolver will be passed to your plugin, which means if you want to override the default resolve, you need to set your <strong>plugin's priority larger</strong> than <code>101</code>.</li> 108<li>Usually <code>resolved_path</code> is the real absolute path that points to a file. But you can still return a <code>virtual module id</code> like <code>virtual:my-module</code>, but for virtual module you need to implement <code>load</code> hook to custom how to load your virtual module. And in Farm, <code>resolved_path + query = module_id</code>.</li> 109<li><code>ResolveKind</code> presents the <code>import type</code>, Example values: <code>ResolveKind::Require</code>(imported by commonjs require), <code>ResolveKind::CssImport</code>(imported by css's import statement), etc.</li> 110<li><code>meta</code> can be shared between plugins and hooks, you can get <code>meta</code> from params of <code>load</code>, <code>transform</code> and <code>parse</code> hooks in any plugin.</li> 111</ul> 112<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="load">load<a href="#load" class="hash-link" aria-label="Direct link to load" title="Direct link to load">â</a></h2> 113<ul> 114<li><strong>required: <code>false</code></strong></li> 115<li><strong>hook type: <code>first</code></strong></li> 116<li><strong>default:</strong></li> 117</ul> 118<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
118<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 119<p>Custom how to load your module from a resolved module path or module id. For example, load a virtual module:</p> 120<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 121<p><code>module_type</code> and <code>content</code> is required when loading modules in your <code>load</code> hook. <code>source_map</code> is optional, you can return source map if you do transform in the <code>load</code> hook(which is not recommended, we recommend to use <code>transform</code> hook for this situation) or you load original source map from other locations.</p> 122<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="transform">transform<a href="#transform" class="hash-link" aria-label="Direct link to transform" title="Direct link to transform">â</a></h2> 123<ul> 124<li><strong>required: <code>false</code></strong></li> 125<li><strong>hook type: <code>serial</code></strong></li> 126<li><strong>default:</strong></li> 127</ul> 128<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 129<p>Do transformation based on <strong><code>module content</code></strong> and <strong><code>module type</code></strong>. Example for transforming <code>sass</code> to <code>css</code>:</p> 130<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 131<p>Normal steps for writing <code>transform hook</code>:</p> 132<ol> 133<li>add a <code>if</code> guard based <code>module_type</code> or <code>resolved_path</code> or <code>module_id</code></li> 134<li>do transformation of the <code>content</code></li> 135<li>return the transformed <code>content</code>, <code>source_map</code> and <code>module_type</code></li> 136</ol> 137<p>For <code>ignore_previous_source_map</code>, if you handled <code>param.source_map_chain</code> and collapsed the source maps of previous plugins in the <code>transform hook</code>. You should set ignore_previous_source_map to <code>true</code> to ensure source map is correct. Otherwise, you should always set this option to <code>false</code> and leave source map chain handled by Farm.</p> 138<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p><code>transform</code> hook is <strong>content to content</strong>. There is a similar hook called <code>process_module</code>, <code>process_module</code> is <strong>ast to ast</strong>. So if you want to transform the loaded content string, you need to use <code>transform</code> hook, and if you want to transform the <code>ast</code>, you should use <code>process_module</code> hook.</p></div></div> 139<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="parse">
139parse<a href="#parse" class="hash-link" aria-label="Direct link to parse" title="Direct link to parse">â</a></h2> 140<ul> 141<li><strong>required: <code>false</code></strong></li> 142<li><strong>hook type: <code>first</code></strong></li> 143<li><strong>default:</strong></li> 144</ul> 145<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 146<p>Parse the <strong><code>transformed module content</code></strong> to <code>ast</code>. <code>Js/Jsx/Ts/Tsx</code>, <code>css</code> and <code>html</code> are supported natively by Farm. Normally you do not need to implement this hook unless you want to support a new <code>module_type</code> other than <code>Js/Jsx/Ts/Tsx</code>, <code>css</code> and <code>html</code>, use <code>ModuleMetaData::Custom</code> for this scenario.</p> 147<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="process_module">process_module<a href="#process_module" class="hash-link" aria-label="Direct link to process_module" title="Direct link to process_module">â</a></h2> 148<ul> 149<li><strong>required: <code>false</code></strong></li> 150<li><strong>hook type: <code>serial</code></strong></li> 151<li><strong>default:</strong></li> 152</ul> 153<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 154<p>Do transformation of the <code>parsed result</code>, usually do <strong><code>ast transformation</code></strong>. For example, Farm strip typescript in <code>process_module</code> hook:</p> 155<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 156<p>In above example, we ignore non-script modules and strip type annotation of the ast for ts/tsx modules.</p> 157<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="analyze_deps">analyze_deps<a href="#analyze_deps" class="hash-link" aria-label="Direct link to analyze_deps" title="Direct link to analyze_deps">â</a></h2> 158<ul> 159<li><strong>required: <code>false</code></strong></li> 160<li><strong>hook type: <code>serial</code></strong></li> 161<li><strong>default:</strong></li> 162</ul> 163<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 164<p>Analyze dependencies of the module. For example, we have <code>a.ts</code>:</p> 165<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><div class="code-title_n3kD"><span><svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 256 256"><path fill="#3178C6" d="M20 0h216c11.046 0 20 8.954 20 20v216c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20V20C0 8.954 8.954 0 20 0Z"/><path fill="#FFF" d="M150.518 200.475v27.62c4.492 2.302 9.805 4.028 15.938 5.179c6.133 1.151 12.597 1.726 19.393 1.726c6.622 0 12.914-.633 18.874-1.899c5.96-1.266 11.187-3.352 15.678-6.257c4.492-2.906 8.048-6.704 10.669-11.394c2.62-4.689 3.93-10.486 3.93-17.391c0-5.006-.749-9.394-2.246-13.163a30.748 30.748 0 0 0-6.479-10.055c-2.821-2.935-6.205-5.567-10.149-7.898c-3.945-2.33-8.394-4.531-13.347-6.602c-3.628-1.497-6.881-2.949-9.761-4.359c-2.879-1.41-5.327-2.848-7.342-4.316c-2.016-1.467-3.571-3.021-4.665-4.661c-1.094-1.64-1.641-3.495-1.641-5.567c0-1.899.489-3.61 1.468-5.135s2.362-2.834 4.147-3.927c1.785-1.094 3.973-1.942
1656.565-2.547c2.591-.604 5.471-.906 8.638-.906c2.304 0 4.737.173 7.299.518c2.563.345 5.14.877 7.732 1.597a53.669 53.669 0 0 1 7.558 2.719a41.7 41.7 0 0 1 6.781 3.797v-25.807c-4.204-1.611-8.797-2.805-13.778-3.582c-4.981-.777-10.697-1.165-17.147-1.165c-6.565 0-12.784.705-18.658 2.115c-5.874 1.409-11.043 3.61-15.506 6.602c-4.463 2.993-7.99 6.805-10.582 11.437c-2.591 4.632-3.887 10.17-3.887 16.615c0 8.228 2.375 15.248 7.127 21.06c4.751 5.811 11.963 10.731 21.638 14.759a291.458 291.458 0 0 1 10.625 4.575c3.283 1.496 6.119 3.049 8.509 4.66c2.39 1.611 4.276 3.366 5.658 5.265c1.382 1.899 2.073 4.057 2.073 6.474a9.901 9.901 0 0 1-1.296 4.963c-.863 1.524-2.174 2.848-3.93 3.97c-1.756 1.122-3.945 1.999-6.565 2.632c-2.62.633-5.687.95-9.2.95c-5.989 0-11.92-1.05-17.794-3.151c-5.875-2.1-11.317-5.25-16.327-9.451Zm-46.036-68.733H140V109H41v22.742h35.345V233h28.137V131.742Z"/></svg></span>a.ts</div><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 166<p>then normally this hook should push <strong>2 entries</strong> to <code>params.deps</code>:</p> 167<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 168<p><code>param.deps</code> will be passed to <code>resolve</code> hook later. You can also add new deps that is not related to the ast of your module as you wish, Farm will <code>resolve</code>, <code>load</code> these unrelated modules and add them to the module graph too.</p> 169<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="finalize_modules">finalize_modules<a href="#finalize_modules" class="hash-link" aria-label="Direct link to finalize_modules" title="Direct link to finalize_modules">â</a></h2> 170<ul> 171<li><strong>required: <code>false</code></strong></li> 172<li><strong>hook type: <code>serial</code></strong></li> 173<li><strong>default:</strong></li> 174</ul> 175<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 176<p>Do any thing you want before seal the module. Note that you can only modify <code>param.module</code>.</p> 177<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="build_end">build_end<a href="#build_end" class="hash-link" aria-label="Direct link to build_end" title="Direct link to build_end">â</a></h2> 178<ul> 179<li><strong>required: <code>false</code></strong></li> 180<li><strong>hook type: <code>parallel</code></strong></li> 181<li><strong>default:</strong></li> 182</ul> 183<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 184<p>Called when all dependencies starting from <code>config.input</code> are handled and <code>ModuleGraph</code> is successfully constructed, you can get the full resolved <code>ModuleGraph</code> here by <code>context.module_graph</code>.</p> 185<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.
18569H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p><code>build_end</code> is only called once for the first compilation. If you want to do something when ModuleGraph is updated in <code>HMR</code> or <code>Lazy Compilation</code>, you should use <a href="#module_graph_updated">module_graph_updated</a> hook.</p></div></div> 186<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="generate_start">generate_start<a href="#generate_start" class="hash-link" aria-label="Direct link to generate_start" title="Direct link to generate_start">â</a></h2> 187<ul> 188<li><strong>required: <code>false</code></strong></li> 189<li><strong>hook type: <code>parallel</code></strong></li> 190<li><strong>default:</strong></li> 191</ul> 192<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 193<p>Called before generate stage start.</p> 194<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="optimize_module_graph">optimize_module_graph<a href="#optimize_module_graph" class="hash-link" aria-label="Direct link to optimize_module_graph" title="Direct link to optimize_module_graph">â</a></h2> 195<ul> 196<li><strong>required: <code>false</code></strong></li> 197<li><strong>hook type: <code>serial</code></strong></li> 198<li><strong>default:</strong></li> 199</ul> 200<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 201<p>You can do optimization of the <code>module_graph</code> here. For internal plugins, Farm does tree shaking, minification in this hook.</p> 202<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="analyze_module_graph">analyze_module_graph<a href="#analyze_module_graph" class="hash-link" aria-label="Direct link to analyze_module_graph" title="Direct link to analyze_module_graph">â</a></h2> 203<ul> 204<li><strong>required: <code>false</code></strong></li> 205<li><strong>hook type: <code>first</code></strong></li> 206<li><strong>default:</strong></li> 207</ul> 208<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 209<p>Analyze <strong><code>dynamic import</code></strong> of the <code>module_graph</code>, and groups modules based on <strong><code>dynamic import</code></strong>, return the grouped modules.</p> 210<div class="theme-admonition theme-admonition-warning admonition_sYcm alert alert--warning"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>warning</div><div class="admonitionContent_nhfF"><p>Normally you should not implement this hook, unless you want to implement a full new bundling algorithm in Farm.</p></div></div> 211<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="partial_bundling">partial_bundling<a href="#partial_bundling" class="hash-link" aria-label="Direct link to partial_bundling" title="Direct link to partial_bundling">â</a></h2> 212<ul> 213<li><strong>required: <code>false</code></strong></li> 214<li><strong>hook type: <code>first</code></strong></li> 215<li><strong>default:</strong></li> 216</ul> 217<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
217<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 218<p>Bundle the <code>modules</code> to <code>Vec<ResourcePot></code> based on <code>module_group_graph</code> and <code>module_graph</code>. A <code>ResourcePot</code> is a structure that Farm uses to hold bundled modules, it will be emitted to final resources in <a href="#generate_resources">generate_resources</a> hook, you can treat a <code>ResourcePot</code> as <code>Chunk</code> of other tools.</p> 219<p>Note:</p> 220<ul> 221<li>This hook will be called in both <code>first compilation</code>, <code>HMR</code> and <code>Lazy Compilation</code>, make sure this hook does not contains side effects(for the same modules, always returns the same <code>Vec<ResourcePot></code>).</li> 222<li>You should set <code>module.resource_pot</code> in this hook.</li> 223</ul> 224<p>Refer to the <a href="https://github.com/farm-fe/farm/blob/main/crates/plugin_partial_bundling/src/lib.rs" target="_blank" rel="noopener noreferrer">internal implementation</a> of partial bundling in Farm for best practice. Refer to <a href="https://github.com/farm-fe/farm/blob/main/crates/plugin_partial_bundling/src/lib.rs" target="_blank" rel="noopener noreferrer">RFC-003 Partial Bundling</a> for how Farm designs bundling.</p> 225<div class="theme-admonition theme-admonition-warning admonition_sYcm alert alert--warning"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>warning</div><div class="admonitionContent_nhfF"><p>Normally you should not implement this hook, unless you want to implement a full new bundling algorithm in Farm. And If you override this hook, <code>config.partial_bundling</code> may not work unless you follow the same bundling spec as Farm.</p></div></div> 226<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="process_resource_pots">process_resource_pots<a href="#process_resource_pots" class="hash-link" aria-label="Direct link to process_resource_pots" title="Direct link to process_resource_pots">â</a></h2> 227<ul> 228<li><strong>required: <code>false</code></strong></li> 229<li><strong>hook type: <code>serial</code></strong></li> 230<li><strong>default:</strong></li> 231</ul> 232<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 233<p>Do some <strong>transformation</strong> of the <code>ResourcePots</code>. Note that ResourcePots are not rendered at this time, which means you can not get the rendered code of the <code>Resource Pot</code>, instead, you can only add, remove, transform the modules inside the <code>ResourcePot</code></p> 234<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="render_start">render_start<a href="#render_start" class="hash-link" aria-label="Direct link to render_start" title="Direct link to render_start">â</a></h2> 235<ul> 236<li><strong>required: <code>false</code></strong></li> 237<li><strong>hook type: <code>serial</code></strong></li> 238<li><strong>default:</strong></li> 239</ul> 240<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 241<p>Called before resource pots render. After rendering resource pots, executable <code>html</code>, <code>css</code>, <code>js</code>, etc files will be emitted.</p> 242<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.
24269H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p><code>render_start</code> is only called once for the first compilation. <code>HMR</code> or <code>Lazy Compilation</code> won't trigger <code>render_start</code> hook.</p></div></div> 243<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="render_resource_pot_modules">render_resource_pot_modules<a href="#render_resource_pot_modules" class="hash-link" aria-label="Direct link to render_resource_pot_modules" title="Direct link to render_resource_pot_modules">â</a></h2> 244<ul> 245<li><strong>required: <code>false</code></strong></li> 246<li><strong>hook type: <code>first</code></strong></li> 247<li><strong>default:</strong></li> 248</ul> 249<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 250<p>Render the given <code>ResourcePot</code> to <code>rendered_content</code> and <code>rendered_source_map_chain</code>. This hook is used to render <code>module's ast</code> to bundled code. If you just want to modify the bundled code, use <a href="#render_resource_pot">render_resource_pot</a> instead.</p> 251<p>If you really need to use this hook, refer to <a href="https://github.com/farm-fe/farm/blob/main/crates/plugin_runtime/src/lib.rs#L320" target="_blank" rel="noopener noreferrer">plugin_runtime</a> for best practice.</p> 252<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>Normally you should not override this hook for natively supported module types like <code>js/jsx/ts/tsx/css/html</code>, you should only use this hook when you ensure you want to override the default behavior for internal module types in Farm, or you want to support <strong>custom module types</strong>.</p></div></div> 253<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="render_resource_pot">render_resource_pot<a href="#render_resource_pot" class="hash-link" aria-label="Direct link to render_resource_pot" title="Direct link to render_resource_pot">â</a></h2> 254<ul> 255<li><strong>required: <code>false</code></strong></li> 256<li><strong>hook type: <code>serial</code></strong></li> 257<li><strong>default:</strong></li> 258</ul> 259<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 260<p>Transform the rendered bundled code for the given <code>ResourcePot</code>. Return <code>rendered content</code> and <code>source map</code>.</p> 261<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 262<p>In above example, we transformed the content of a css <code>Resource Pot</code>, replaced all <code><--layer--></code> to <code>replaced_code</code>.</p> 263<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="augment_resource_hash">augment_resource_hash<a href="#augment_resource_hash" class="hash-l
263ink" aria-label="Direct link to augment_resource_hash" title="Direct link to augment_resource_hash">â</a></h2> 264<ul> 265<li><strong>required: <code>false</code></strong></li> 266<li><strong>hook type: <code>serial</code></strong></li> 267<li><strong>default:</strong></li> 268</ul> 269<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 270<p>Append additional hash when generating resource from given resource pot.</p> 271<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="optimize_resource_pot">optimize_resource_pot<a href="#optimize_resource_pot" class="hash-link" aria-label="Direct link to optimize_resource_pot" title="Direct link to optimize_resource_pot">â</a></h2> 272<ul> 273<li><strong>required: <code>false</code></strong></li> 274<li><strong>hook type: <code>serial</code></strong></li> 275<li><strong>default:</strong></li> 276</ul> 277<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 278<p>Do some optimizations for the rendered resource pot. For example, minification. If you want to modify the rendered content of this hook, just modify <code>resource_pot.meta.rendered_content</code> and append sourcemap of this transformation in <code>resource_pot.meta.rendered_source_map_chain</code>.</p> 279<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>Optimizations like minification is handled internally by Farm, make sure that you really need to use this hook.</p></div></div> 280<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="generate_resources">generate_resources<a href="#generate_resources" class="hash-link" aria-label="Direct link to generate_resources" title="Direct link to generate_resources">â</a></h2> 281<ul> 282<li><strong>required: <code>false</code></strong></li> 283<li><strong>hook type: <code>first</code></strong></li> 284<li><strong>default:</strong></li> 285</ul> 286<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 287<p>Generate final resource for the give rendered resource pot. return <code>generated resource</code> and <code>optional source map resource</code>.</p> 288<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p>For natively supported <code>ModuleTypes</code> like <code>js/ts/jsx/tsx/css/html/static assets</code>, normally you do not need to implement this hook. Use this hook when you want to supp
288ort a new type of resource that not natively supported by Farm.</p></div></div> 289<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="finalize_resources">finalize_resources<a href="#finalize_resources" class="hash-link" aria-label="Direct link to finalize_resources" title="Direct link to finalize_resources">â</a></h2> 290<ul> 291<li><strong>required: <code>false</code></strong></li> 292<li><strong>hook type: <code>serial</code></strong></li> 293<li><strong>default:</strong></li> 294</ul> 295<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 296<p>Do some finalization work on the generated resources, for example, transform html based on the generated resources(insert <code><script></code>, <code><link></code> tags).</p> 297<p>You can also <strong><code>add</code></strong> or <strong><code>remove</code></strong> resources here.</p> 298<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="generate_end">generate_end<a href="#generate_end" class="hash-link" aria-label="Direct link to generate_end" title="Direct link to generate_end">â</a></h2> 299<ul> 300<li><strong>required: <code>false</code></strong></li> 301<li><strong>hook type: <code>parallel</code></strong></li> 302<li><strong>default:</strong></li> 303</ul> 304<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 305<p>Called when all generate stage done(including <code>finalize_resources</code>). You can do some cleanup work here.</p> 306<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="finish">finish<a href="#finish" class="hash-link" aria-label="Direct link to finish" title="Direct link to finish">â</a></h2> 307<ul> 308<li><strong>required: <code>false</code></strong></li> 309<li><strong>hook type: <code>parallel</code></strong></li> 310<li><strong>default:</strong></li> 311</ul> 312<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 313<p>Called when all compilation work done(including <code>build stage</code> and <code>generate stage</code>). You can do some cleanup work here.</p> 314<div class="theme-admonition theme-admonition-note admonition_sYcm alert alert--secondary"><div class="admonitionHeading_N1sA"><span class="admonitionIcon_UGXJ"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>note</div><div class="admonitionContent_nhfF"><p><code>finish</code> is only called once for the first compilation. <code>HMR</code> or <code>Lazy Compilation</code> won't trigger <code>finish</code> hook. You should use <a href="#update_finished">update_finished</a> hook instead.</p></div></div> 315<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="write_plugin_cache">write_plugin_cache<a href="#write_plugin_cache" class="hash-link" aria-label="Direct link to write_plugin_cache" title="Direct link to write_plugin_cache">â</a></h2> 316<ul> 317<li><strong>required: <code>false</code></strong></li> 318<li><strong>hook type: <code>serial</code></strong></li> 319<li><strong>default:</strong></li> 320</ul> 321<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
321<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 322<p>Extend <a href="/docs/advanced/persistent-cache"><code>persistent cache</code></a> writing for your plugin. <code>write_plugin_cache</code> is often used together with <a href="#plugin_cache_loaded">plugin_cache_loaded</a> to read and write persistent cache for plugin. Return the serialized bytes of your data.</p> 323<p>Example, writing cache for static assets:</p> 324<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 325<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="update_modules">update_modules<a href="#update_modules" class="hash-link" aria-label="Direct link to update_modules" title="Direct link to update_modules">â</a></h2> 326<ul> 327<li><strong>required: <code>false</code></strong></li> 328<li><strong>hook type: <code>serial</code></strong></li> 329<li><strong>default:</strong></li> 330</ul> 331<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 332<p>Called when calling compiler.update(module_paths). Useful to do some operations like clearing previous state or ignore some files when performing HMR</p> 333<ul> 334<li><code>paths</code> is paths that will be recompiled for this update</li> 335<li>return the new <code>paths</code>, later compilation will update the new returned paths.</li> 336</ul> 337<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="module_graph_updated">module_graph_updated<a href="#module_graph_updated" class="hash-link" aria-label="Direct link to module_graph_updated" title="Direct link to module_graph_updated">â</a></h2> 338<ul> 339<li><strong>required: <code>false</code></strong></li> 340<li><strong>hook type: <code>serial</code></strong></li> 341<li><strong>default:</strong></li> 342</ul> 343<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 344<p>Called when calling compiler.update(module_paths). Useful to do some operations like modifying the module graph.</p> 345<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="update_finished">update_finished<a href="#update_finished" class="hash-link" aria-label="Direct link to update_finished" title="Direct link to update_finished">â</a></h2> 346<ul> 347<li><strong>required: <code>false</code></strong></li> 348<li><strong>hook type: <code>serial</code></strong></li> 349<li><strong>default:</strong></li> 350</ul> 351<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 352<p>Called when calling compiler.update(module_paths). This hook is called after all compilation work is done, including the resources regeneration and finalization.</p> 353<h2 class="anchor anchorWithStickyNavbar_T_6Y" id="handle_persistent_cached_module">handle_persistent_cached_module<a href="#handle_persistent_cached_module" class="hash-link" aria-label="Direct link to handle_persistent_cached_module" title="Direct link to handle_persistent_cached_module">â</a></h2> 354<ul> 355<li><strong>required: <code>false</code></strong></li> 356<li><strong>hook type: <code>serial</code></strong></li> 357<li><strong>default:</strong></li> 358</ul> 359<div class="shiki-wrapper_eFVS"><div class="code-header_obPU"><button class="copy-button_MpeX"><svg class="copy-icon_DvHB" viewBox="0 0 24 24">
359<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg></button></div><div></div></div> 360<p>Called when persistent cache is enabled and the cache hit for the module. Return <code>true</code> to <strong>skip loading cache for this module</strong>.</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="row margin-top--sm theme-doc-footer-edit-meta-row"><div class="col"><a href="https://github.com/farm-fe/farm-fe.github.io/tree/main/docs/api/rust-plugin-api.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_L112" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_d2Ca"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/api/js-plugin-api"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Js Plugin Api</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/api/runtime-plugin-api"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Runtime Plugin API</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_vyNU thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#configuring-rust-plugins" class="table-of-contents__link toc-highlight">Configuring Rust Plugins</a></li><li><a href="#writing-rust-plugin" class="table-of-contents__link toc-highlight">Writing Rust Plugin</a></li><li><a href="#plugin-hooks-overview" class="table-of-contents__link toc-highlight">Plugin Hooks Overview</a></li><li><a href="#name" class="table-of-contents__link toc-highlight">name</a></li><li><a href="#priority" class="table-of-contents__link toc-highlight">priority</a></li><li><a href="#config" class="table-of-contents__link toc-highlight">config</a></li><li><a href="#plugin_cache_loaded" class="table-of-contents__link toc-highlight">plugin_cache_loaded</a></li><li><a href="#build_start" class="table-of-contents__link toc-highlight">build_start</a></li><li><a href="#resolve" class="table-of-contents__link toc-highlight">resolve</a></li><li><a href="#load" class="table-of-contents__link toc-highlight">load</a></li><li><a href="#transform" class="table-of-contents__link toc-highlight">transform</a></li><li><a href="#parse" class="table-of-contents__link toc-highlight">parse</a></li><li><a href="#process_module" class="table-of-contents__link toc-highlight">process_module</a></li><li><a href="#analyze_deps" class="table-of-contents__link toc-highlight">analyze_deps</a></li><li><a href="#finalize_modules" class="table-of-contents__link toc-highlight">finalize_modules</a></li><li><a href="#build_end" class="table-of-contents__link toc-highlight">build_end</a></li><li><a href="#generate_start" class="table-of-contents__link toc-highlight">generate_start</a></li><li><a href="#optimize_module_graph" class="table-of-contents__link toc-highlight">optimize_module_graph</a></li><li><a href="#analyze_module_graph" class="table-of-contents__link toc-highlight">analyze_module_graph</a></li><li><a href="#partial_bundling" class="table-of-contents__link toc-highlight">partial_bundling</a></li><li><a href="#process_resource_pots" class="table-of-contents__link toc-highlight">process_resource_pots</a></li><li><a href="#render_start" class="table-of-contents__link toc-highlight">render_start</a></li><li><a href="#render_resource_pot_modules" class="table-of-contents__link toc-highlight">render_resource_pot_modules</a></li><li><a href="#render_resource_pot" class="table-of-contents__link toc-highlight">render_resource_pot</a></li><li><a href="#augment_resource_hash" class="table-of-contents__link toc-highlight">augment_resource_hash</a></li><li>
360<a href="#optimize_resource_pot" class="table-of-contents__link toc-highlight">optimize_resource_pot</a></li><li><a href="#generate_resources" class="table-of-contents__link toc-highlight">generate_resources</a></li><li><a href="#finalize_resources" class="table-of-contents__link toc-highlight">finalize_resources</a></li><li><a href="#generate_end" class="table-of-contents__link toc-highlight">generate_end</a></li><li><a href="#finish" class="table-of-contents__link toc-highlight">finish</a></li><li><a href="#write_plugin_cache" class="table-of-contents__link toc-highlight">write_plugin_cache</a></li><li><a href="#update_modules" class="table-of-contents__link toc-highlight">update_modules</a></li><li><a href="#module_graph_updated" class="table-of-contents__link toc-highlight">module_graph_updated</a></li><li><a href="#update_finished" class="table-of-contents__link toc-highlight">update_finished</a></li><li><a href="#handle_persistent_cached_module" class="table-of-contents__link toc-highlight">handle_persistent_cached_module</a></li></ul></div></div></div></div></main></div></div></div><section class="py-8 bg-zinc-950 sm:py-10 lg:py-12 text-white z-50"><div class="px-4 mx-auto sm:px-6 lg:px-8 max-w-7xl"><div class="flex flex-col items-center sm:items-start gap-8 sm:flex-row sm:justify-between"><div class="flex flex-col items-center sm:items-start gap-4"><img class="h-12 w-36 sm:h-14 sm:w-40" src="https://www.farmfe.org/img/logo-farm.png" alt=""><span class="text-lg sm:text-xl font-bold text-center sm:text-left">Extremely Fast Web Build Tool Written in Rust</span></div><div class="w-full sm:w-auto"><div class="grid grid-cols-1 sm:grid-cols-3 gap-8 sm:gap-x-12"><div><p class="text-base text-gray-500 font-semibold mb-4">Guide</p><ul class="list-none space-y-3 p-0"><li><a href="/docs/quick-start" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> Quick Start </a></li><li><a href="/docs/why-farm" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> Introduction </a></li></ul></div><div><p class="text-base text-gray-500 font-semibold mb-4">Community</p><ul class="list-none space-y-3 p-0"><li><a href="https://github.com/farm-fe/farm?tab=readme-ov-file#chat-with-us" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> WeChat Group </a></li><li><a href="https://discord.com/invite/mDErq9aFnF" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> Discord </a></li></ul></div><div><p class="text-base text-gray-500 font-semibold mb-4">More</p><ul class="list-none space-y-3 p-0"><li><a href="https://github.com/farm-fe/farm" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> Github </a></li><li><a href="https://x.com/FarmFe71928" class="text-sm sm:text-base text-white transition-all duration-200 hover:text-opacity-80 focus:text-opacity-80"> Twitter </a></li></ul></div></div></div></div><div class="my-8 sm:my-12"></div><div class="flex flex-col items-center sm:flex-row sm:justify-between"><ul class="flex items-center space-x-4 mb-4 sm:mb-0 p-0"><a href="https://github.com/farm-fe/farm" target="_blank" rel="noopener noreferrer"><svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 sm:h-6 sm:w-6 text-white hover:text-gray-300"><path d="M7.49933 0.25C3.49635 0.25 0.25 3.49593 0.25 7.50024C0.25 10.703 2.32715 13.4206 5.2081 14.3797C5.57084 14.446 5.70302 14.2222 5.70302 14.0299C5.70302 13.8576 5.69679 13.4019 5.69323 12.797C3.67661 13.235 3.25112 11.825 3.25112 11.825C2.92132 10.9874 2.44599 10.7644 2.44599 10.7644C1.78773 10.3149 2.49584 10.3238 2.49584 10.3238C3.22353 10.375 3.60629 11.0711 3.60629 11.0711C4.25298 12.1788 5.30335 11.8588 5.71638 11.6732C5.78225 11.205 5.96962 10.8854 6.17658 10.7043C4.56675 10.5209 2.87415 9.89918 2.87415 7.12104C2.87415 6.32925 3.15677 5.68257 3.62053 5.17563C3.54576 4.99226 3.29697 4.25521 3.69174 3.25691C3.69174 3.25691 4.30015 3.06196 5.68522 3.99973C6.26337 3.83906 6.8838 3.75895 7.50022 3.75583C8.1162 3.75895 8.73619 3.83906 9.31523 3.99973C10.6994 3.06196 11.3069 3.25691 11.3069 3.25691C11.7026 4.25521 11.4538 4.99226 11.3795 5.17563C11.8441 5.68257 12.1245 6.32925 12.1245 7.12104C12.1245 9.9063 10.4292 10.5192 8.81452 10.6985C9.07444 10.9224 9.30633 11.3648 9.30633 12.0413C9.30633 13.0102 9.29742 13.7922 9.29742 14.0299C9.29742 14.2239 9.42828 14.4496 9.79591 14.3788C12.6746 13.4179 14.75 10.7025 14.75 7.50024C14.75 3.49593 11.5036 0.25 7.49933 0.25Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg></a><a href="https://x.com/FarmFe71928" target="_blank" rel="noopener noreferrer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" class="h-5 w-5 sm:h-6 sm:w-6 text-white hover:text-gray-300" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"></path></svg></a><a href="https://discord.com/invite/mDErq9aFnF" target="_blank" rel="noopener noreferrer"><svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 sm:h-6 sm:w-6 text-white hover:text-gray-300"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.07451 1.82584C5.03267 1.81926 4.99014 1.81825 4.94803 1.82284C4.10683 1.91446 2.82673 2.36828 2.07115 2.77808C2.02106 2.80525 1.97621 2.84112 1.93869 2.88402C1.62502 3.24266 1.34046 3.82836 1.11706 4.38186C0.887447 4.95076 0.697293 5.55032 0.588937 5.98354C0.236232 7.39369 0.042502 9.08728 0.0174948 10.6925C0.0162429 10.7729 0.0351883 10.8523 0.0725931 10.9234C0.373679 11.496 1.02015 12.027 1.66809 12.4152C2.32332 12.8078 3.08732 13.1182 3.70385 13.1778C3.85335 13.1922 4.00098 13.1358 4.10282 13.0255C4.2572 12.8581 4.5193 12.4676 4.71745 12.1643C4.80739 12.0267 4.89157 11.8953 4.95845 11.7901C5.62023 11.9106 6.45043 11.9801 7.50002 11.9801C8.54844 11.9801 9.37796 11.9107 10.0394 11.7905C10.1062 11.8957 10.1903 12.0269 10.2801 12.1643C10.4783 12.4676 10.7404 12.8581 10.8947 13.0255C10.9966 13.1358 11.1442 13.1922 11.2937 13.1778C11.9102 13.1182 12.6742 12.8078 13.3295 12.4152C13.9774 12.027 14.6239 11.496 14.925 10.9234C14.9624 10.8523 14.9813 10.7729 14.9801 10.6925C14.9551 9.08728 14.7613 7.39369 14.4086 5.98354C14.3003 5.55032 14.1101 4.95076 13.8805 4.38186C13.6571 3.82836 13.3725 3.24266 13.0589 2.88402C13.0214 2.84112 12.976
3605 2.80525 12.9264 2.77808C12.1708 2.36828 10.8907 1.91446 10.0495 1.82284C10.0074 1.81825 9.96489 1.81926 9.92305 1.82584C9.71676 1.85825 9.5391 1.96458 9.40809 2.06355C9.26977 2.16804 9.1413 2.29668 9.0304 2.42682C8.86968 2.61544 8.71437 2.84488 8.61428 3.06225C8.27237 3.03501 7.90138 3.02 7.5 3.02C7.0977 3.02 6.72593 3.03508 6.38337 3.06244C6.28328 2.84501 6.12792 2.61549 5.96716 2.42682C5.85626 2.29668 5.72778 2.16804 5.58947 2.06355C5.45846 1.96458 5.2808 1.85825 5.07451 1.82584ZM11.0181 11.5382C11.0395 11.5713 11.0615 11.6051 11.0838 11.6392C11.2169 11.843 11.3487 12.0385 11.4508 12.1809C11.8475 12.0916 12.352 11.8818 12.8361 11.5917C13.3795 11.2661 13.8098 10.8918 14.0177 10.5739C13.9852 9.06758 13.7993 7.50369 13.4773 6.21648C13.38 5.82759 13.2038 5.27021 12.9903 4.74117C12.7893 4.24326 12.5753 3.82162 12.388 3.5792C11.7376 3.24219 10.7129 2.88582 10.0454 2.78987C10.0308 2.79839 10.0113 2.81102 9.98675 2.82955C9.91863 2.881 9.84018 2.95666 9.76111 3.04945C9.71959 3.09817 9.68166 3.1471 9.64768 3.19449C9.953 3.25031 10.2253 3.3171 10.4662 3.39123C11.1499 3.6016 11.6428 3.89039 11.884 4.212C12.0431 4.42408 12.0001 4.72494 11.788 4.884C11.5759 5.04306 11.2751 5.00008 11.116 4.788C11.0572 4.70961 10.8001 4.4984 10.1838 4.30877C9.58933 4.12585 8.71356 3.98 7.5 3.98C6.28644 3.98 5.41067 4.12585 4.81616 4.30877C4.19988 4.4984 3.94279 4.70961 3.884 4.788C3.72494 5.00008 3.42408 5.04306 3.212 4.884C2.99992 4.72494 2.95694 4.42408 3.116 4.212C3.35721 3.89039 3.85011 3.6016 4.53383 3.39123C4.77418 3.31727 5.04571 3.25062 5.35016 3.19488C5.31611 3.14738 5.27808 3.09831 5.23645 3.04945C5.15738 2.95666 5.07893 2.881 5.01081 2.82955C4.98628 2.81102 4.96674 2.79839 4.95217 2.78987C4.28464 2.88582 3.25999 3.24219 2.60954 3.5792C2.42226 3.82162 2.20825 4.24326 2.00729 4.74117C1.79376 5.27021 1.61752 5.82759 1.52025 6.21648C1.19829 7.50369 1.01236 9.06758 0.97986 10.5739C1.18772 10.8918 1.61807 11.2661 2.16148 11.5917C2.64557 11.8818 3.15003 12.0916 3.5468 12.1809C3.64885 12.0385 3.78065 11.843 3.9138 11.6392C3.93626 11.6048 3.95838 11.5708 3.97996 11.5375C3.19521 11.2591 2.77361 10.8758 2.50064 10.4664C2.35359 10.2458 2.4132 9.94778 2.63377 9.80074C2.85435 9.65369 3.15236 9.71329 3.29941 9.93387C3.56077 10.3259 4.24355 11.0201 7.50002 11.0201C10.7565 11.0201 11.4392 10.326 11.7006 9.93386C11.8477 9.71329 12.1457 9.65369 12.3663 9.80074C12.5869 9.94779 12.6465 10.2458 12.4994 10.4664C12.2262 10.8762 11.8041 11.2598 11.0181 11.5382ZM4.08049 7.01221C4.32412 6.74984 4.65476 6.60162 5.00007 6.59998C5.34538 6.60162 5.67603 6.74984 5.91966 7.01221C6.16329 7.27459 6.30007 7.62974 6.30007 7.99998C6.30007 8.37021 6.16329 8.72536 5.91966 8.98774C5.67603 9.25011 5.34538 9.39833 5.00007 9.39998C4.65476 9.39833 4.32412 9.25011 4.08049 8.98774C3.83685 8.72536 3.70007 8.37021 3.70007 7.99998C3.70007 7.62974 3.83685 7.27459 4.08049 7.01221ZM9.99885 6.59998C9.65354 6.60162 9.3229 6.74984 9.07926 7.01221C8.83563 7.27459 8.69885 7.62974 8.69885 7.99998C8.69885 8.37021 8.83563 8.72536 9.07926 8.98774C9.3229 9.25011 9.65354 9.39833 9.99885 9.39998C10.3442 9.39833 10.6748 9.25011 10.9184 8.98774C11.1621 8.72536 11.2989 8.37021 11.2989 7.99998C11.2989 7.62974 11.1621 7.27459 10.9184 7.01221C10.6748 6.74984 10.3442 6.60162 9.99885 6.59998Z" fill="currentColor"></path></svg></a></ul><p class="text-xs sm:text-sm text-center text-gray-100">Copyright © 2024 Farm Community. Built with Docusaurus.</p></div></div></section></div> 361</body> 362</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.