1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["10209"],{46229:function(e,n,r){r.r(n),r.d(n,{metadata:function(){return t},default:function(){return p},frontMatter:function(){return s},contentTitle:function(){return o},toc:function(){return d},assets:function(){return c}});var t=JSON.parse('{"id":"babel-plugin-external-helpers","title":"@babel/plugin-external-helpers","description":"Usage","source":"@site/../docs/plugin-external-helpers.md","sourceDirName":".","slug":"/babel-plugin-external-helpers","permalink":"/docs/babel-plugin-external-helpers","draft":false,"unlisted":false,"editUrl":"https://github.com/babel/website/edit/main/docs/../docs/plugin-external-helpers.md","tags":[],"version":"current","frontMatter":{"id":"babel-plugin-external-helpers","title":"@babel/plugin-external-helpers","sidebar_label":"external-helpers"}}'),l=r(62540),a=r(43023),i=r(77779),u=r(98263);let s={id:"babel-plugin-external-helpers",title:"@babel/plugin-external-helpers",sidebar_label:"external-helpers"},o,c={},d=[{value:"Usage",id:"usage",level:2},{value:"With a configuration file (Recommended)",id:"with-a-configuration-file-recommended",level:3},{value:"Via CLI",id:"via-cli",level:3},{value:"Via Node API",id:"via-node-api",level:3}];function h(e){let n={code:"code",h2:"h2",h3:"h3",pre:"pre",...(0,a.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(i.A,{groupId:"npm2yarn",children:[(0,l.jsx)(u.A,{value:"npm",children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"npm install --save-dev @babel/plugin-external-helpers\n"})})}),(0,l.jsx)(u.A,{value:"yarn",label:"Yarn",children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"yarn add --dev @babel/plugin-external-helpers\n"})})}),(0,l.jsx)(u.A,{value:"pnpm",label:"pnpm",children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"pnpm add --save-dev @babel/plugin-external-helpers\n"})})}),(0,l.jsx)(u.A,{value:"bun",label:"Bun",children:(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-shell",children:"bun add --dev @babel/plugin-external-helpers\n"})})})]}),"\n",(0,l.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,l.jsx)(n.h3,{id:"with-a-configuration-file-recommended",children:"With a configuration file (Recommended)"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-json",metastring:'title="babel.config.json"',children:'{\n "plugins": ["@babel/plugin-external-helpers"]\n}\n'})}),"\n",(0,l.jsx)(n.h3,{id:"via-cli",children:"Via CLI"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-sh",metastring:'title="Shell"',children:"babel --plugins @babel/plugin-external-helpers script.js\n"})}),"\n",(0,l.jsx)(n.h3,{id:"via-node-api",children:"Via Node API"}),"\n",(0,l.jsx)(n.pre,{children:(0,l.jsx)(n.code,{className:"language-js",metastring:'title="JavaScript"',children:'require("@babel/core").transformSync("code", {\n plugins: ["@babel/plugin-external-helpers"]\n});\n'})})]})}function p(e={}){let{wrapper:n}={...(0,a.R)(),...e.components};return n?(0,l.jsx)(n,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}},98263:function(e,n,r){r.d(n,{A:function(){return u}});var t=r(62540);r(63696);var l=r(11750),a=r(23865);function i({children:e,className:n,hidden:r}){return(0,t.jsx)("div",{role:"tabpanel",className:(0,l.A)("tabItem_wHwb",n),hidden:r,children:e})}function u({children:e,className:n,value:r}){let{selectedValue:l,lazy:s}=(0,a.uc)(),o=r===l;return!o&&s?null:(0,t.jsx)(i,{className:n,hidden:!o,children:e})}},77779:function(e,n,r){r.d(n,{A:function(){return h}});var t=r(62540);r(63696);var l=r(11750),a=r(46065),i=r(23865),u=r(45194),s=r(83029);function o({className:e}){let{selectedValue:n,selectValue:r,tabValues:a,block:s}=(0,i.uc)(),c=[],{blockElementScrollPositionUntilNextRender:d}=(0,u.a_)(),h=e=>{let t=e.currentTarget,l=a[c.indexOf(t)].value;l!==n&&(d(t),r(l))},p=e=>{let n=null;switch(e.key){case"Enter":h(e);break;case"ArrowRight":{let r=c.indexOf(e.currentTarget)+1;n=c[r]??c[0];break}case"ArrowLeft":{let r=c.indexOf(e.currentTarget)-1;n=c[r]??c[c.length-1]}}n?.focus()};return(0,t.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,l.A)("tabs",{"tabs--block":s},e),children:a.map(({value:e,label:r,attributes:a})=>(0,t.jsx)("li",{role:"tab",tabIndex:n===e?0:-1,"aria-selected":n===e,ref:e=>{c.push(e)},onKeyDown:p,onClick:h,...a,className:(0,l.A)("tabs__item","tabItem_l0OV",a?.className,{"tabs__item--active":n===e}),children:r??e},e))})}function c({children:e}){return(0,t.jsx)("div",{className:"margin-top--md",children:e})}function d({className:e,children:n}){return(0,t.jsxs)("div",{className:(0,l.A)(a.G.tabs.container,"tabs-container","tabList_J5MA"),children:[(0,t.jsx)(o,{className:e}),(0,t.jsx)(c,{children:n})]})}function h(e){let n=(0,s.A)(),r=(0,i.OC)(e);return(0,t.jsx)(i.O_,{value:r,children:(0,t.jsx)(d,{className:e.className,children:(0,i.vT)(e.children)})},String(n))}},23865:function(e,n,r){r.d(n,{OC:function(){return h},O_:function(){return b},uc:function(){return f},vT:function(){return c}});var t=r(62540),l=r(63696),a=r(49519),i=r(6743),u=r(88511),s=r(15396),o=r(89030);function c(e){return l.Children.toArray(e).filter(e=>"\n"!==e)}function d({value:e,tabValues:n}){return n.some(n=>n.value===e)}function h(e){let n,{defaultValue:r,queryString:t=!1,groupId:c}=e,h=function(e){let{values:n,children:r}=e;return(0,l.useMemo)(()=>{let e=n??l.Children.toArray(r).flatMap(e=>{if(!e)return[];if((0,l.isValidElement)(e)&&function(e){let{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return[e];
1let n="string"==typeof e.type?e.type:e.type.name;throw Error(`Docusaurus error: Bad <Tabs> child <${n}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop. 2If you do not want to pass on a "value" prop to the direct children of <Tabs>, you can also pass an explicit <Tabs values={...}> prop.`)}).map(({props:{value:e,label:n,attributes:r,default:t}})=>({value:e,label:n,attributes:r,default:t})),t=(0,s.XI)(e,(e,n)=>e.value===n.value);if(t.length>0)throw Error(`Docusaurus error: Duplicate values "${t.map(e=>`'${e.value}'`).join(", ")}" found in <Tabs>. Every value needs to be unique.`);return e},[n,r])}(e),[p,f]=(0,l.useState)(()=>(function({defaultValue:e,tabValues:n}){if(0===n.length)throw Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!d({value:e,tabValues:n}))throw Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}let r=n.find(e=>e.default)??n[0];if(!r)throw Error("Unexpected error: 0 tabValues");return r.value})({defaultValue:r,tabValues:h})),[b,m]=function({queryString:e=!1,groupId:n}){let r=(0,a.W6)(),t=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,u.aZ)(t),(0,l.useCallback)(e=>{if(!t)return;let n=new URLSearchParams(r.location.search);n.set(t,e),r.replace({...r.location,search:n.toString()})},[t,r])]}({queryString:t,groupId:c}),[v,x]=function({groupId:e}){let n=e?`docusaurus.tab.${e}`:null,[r,t]=(0,o.Dv)(n);return[r,(0,l.useCallback)(e=>{n&&t.set(e)},[n,t])]}({groupId:c}),g=d({value:n=b??v,tabValues:h})?n:null;return(0,i.A)(()=>{g&&f(g)},[g]),{selectedValue:p,selectValue:(0,l.useCallback)(e=>{if(!d({value:e,tabValues:h}))throw Error(`Can't select invalid tab value=${e}`);f(e),m(e),x(e)},[m,x,h]),tabValues:h,lazy:e.lazy??!1,block:e.block??!1}}let p=(0,l.createContext)(null);function f(){let e=l.useContext(p);if(!e)throw Error("useTabsContext() must be used within a Tabs component");return e}function b(e){return(0,t.jsx)(p.Provider,{value:e.value,children:e.children})}},43023:function(e,n,r){r.d(n,{R:function(){return i},x:function(){return u}});var t=r(63696);let l={},a=t.createContext(l);function i(e){let n=t.useContext(a);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function u(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:i(e.components),t.createElement(a.Provider,{value:n},e.children)}}}]);
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.