"use strict";const r=new Set,s=(n,e)=>e.some(t=>typeof t=="string"?n===t||n.startsWith(`${t}/`):t instanceof RegExp?t.test(n):typeof t=="function"?t(n):!1),o=n=>({name:"externalize",setup(e){e.onResolve({filter:/.*/},t=>s(t.path,n)&&t.kind==="import-statement"?(r.add(t.path),{path:t.path,external:!0}):s(t.path,n)&&t.kind==="entry-point"?(r.add(t.path),{path:t.path,namespace:"externalized-modules"}):null),e.onLoad({filter:/.*/},t=>s(t.path,n)?{contents:""}:null)}}),a=({base:n})=>({name:"vite-plugin-remove-prefix",transform:e=>{if(r.size===0)return e;const t="@id/",u=new RegExp(`${n}${t}(${[...r].join("|")})`,"g");return u.test(e)?e.replace(u,(p,i)=>i):e}}),m=n=>({name:"vite-plugin-externalize",enforce:"pre",apply:"serve",config:e=>{var p,i;e.optimizeDeps??(e.optimizeDeps={}),(p=e.optimizeDeps).esbuildOptions??(p.esbuildOptions={}),(i=e.optimizeDeps.esbuildOptions).plugins??(i.plugins=[]);const t="externalize";return e.optimizeDeps.esbuildOptions.plugins.some(l=>l.name===t)||e.optimizeDeps.esbuildOptions.plugins.push(o(n.externals)),null},configResolved:e=>{e.plugins.push(a({base:e.base??"/"}))},resolveId:e=>r.has(e)?{id:e,external:!0}:s(e,n.externals)?(r.add(e),{id:e,external:!0}):null,load:e=>r.has(e)?{code:"export default {};"}:null});module.exports=m; //# sourceMappingURL=index.cjs.map