index.d.ts 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063
  1. /// <reference types="node" />
  2. import { t as ModuleRunnerTransport } from "./chunks/moduleRunnerTransport.js";
  3. import { CustomEventMap, InferCustomEventPayload, InferCustomEventPayload as hmrPayload_InferCustomEventPayload, InvalidatePayload } from "#types/customEvent";
  4. import { ConnectedPayload, CustomPayload, CustomPayload as hmrPayload_CustomPayload, ErrorPayload, FullReloadPayload, HMRPayload, HotPayload, HotPayload as hmrPayload_HotPayload, PrunePayload, Update, UpdatePayload } from "#types/hmrPayload";
  5. import * as Rolldown from "rolldown";
  6. import { CustomPluginOptions, ExistingRawSourceMap, FunctionPluginHooks, ImportKind, InputOption, InputOptions, LoadResult, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleType, ModuleTypeFilter, ObjectHook, OutputBundle, OutputChunk, OutputOptions, PartialResolvedId, PluginContext, PluginContextMeta, ResolveIdResult, RolldownOptions, RolldownOutput, RolldownWatcher, RollupError, RollupLog, SourceDescription, SourceMap, SourceMapInput, TransformPluginContext, VERSION as rolldownVersion, WatcherOptions } from "rolldown";
  7. import { parseAst as parseAst$1, parseAstAsync as parseAstAsync$1 } from "rolldown/parseAst";
  8. import * as Rollup from "#types/internal/rollupTypeCompat";
  9. import { esmExternalRequirePlugin } from "rolldown/plugins";
  10. import { ESTree, MinifyOptions, MinifyResult, ParseResult, ParserOptions, TransformOptions as rolldown_utils_TransformOptions, TransformResult as rolldown_utils_TransformResult, Visitor, VisitorObject, minify, minifySync, parse, parseSync } from "rolldown/utils";
  11. import { DevToolsConfig, ResolvedDevToolsConfig } from "#types/internal/devtoolsOptions";
  12. import { DepsOptimizerEsbuildOptions, EsbuildTarget, EsbuildTransformOptions, EsbuildTransformOptions as esbuildOptions_EsbuildTransformOptions, EsbuildTransformResult } from "#types/internal/esbuildOptions";
  13. import { ChunkMetadata, CustomPluginOptionsVite } from "#types/metadata";
  14. import * as http from "node:http";
  15. import { Agent, ClientRequest, ClientRequestArgs, OutgoingHttpHeaders, ServerResponse } from "node:http";
  16. import { Http2SecureServer } from "node:http2";
  17. import { EventEmitter } from "node:events";
  18. import * as fs from "node:fs";
  19. import { Server as HttpsServer, ServerOptions as HttpsServerOptions } from "node:https";
  20. import * as net from "node:net";
  21. import { Duplex, DuplexOptions, Stream } from "node:stream";
  22. import { FetchFunction, FetchFunctionOptions, FetchResult, FetchResult as moduleRunner_FetchResult, ModuleEvaluator, ModuleRunner, ModuleRunnerHmr, ModuleRunnerOptions } from "vite/module-runner";
  23. import { SecureContextOptions } from "node:tls";
  24. import { URL as url_URL } from "node:url";
  25. import { ZlibOptions } from "node:zlib";
  26. import { DevWatchOptions } from "rolldown/experimental";
  27. import { Terser, TerserMinifyOptions } from "#types/internal/terserOptions";
  28. import * as PostCSS from "postcss";
  29. import { ProcessOptions, Processor, Transformer } from "postcss";
  30. import { LessPreprocessorBaseOptions, SassModernPreprocessBaseOptions, StylusPreprocessorBaseOptions } from "#types/internal/cssPreprocessorOptions";
  31. import { LightningCSSOptions, LightningCSSOptions as lightningcssOptions_LightningCSSOptions } from "#types/internal/lightningcssOptions";
  32. import { withFilter } from "rolldown/filter";
  33. import { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap, KnownQueryTypeMap } from "#types/importGlob";
  34. //#endregion
  35. //#region src/types/alias.d.ts
  36. interface Alias {
  37. find: string | RegExp;
  38. replacement: string;
  39. /**
  40. * Instructs the plugin to use an alternative resolving algorithm,
  41. * rather than the Rollup's resolver.
  42. * @default null
  43. * @deprecated Use a custom plugin with resolveId hook and `enforce: 'pre'` instead
  44. */
  45. customResolver?: ResolverFunction | ResolverObject | null;
  46. }
  47. type MapToFunction<T> = T extends Function ? T : never;
  48. type ResolverFunction = MapToFunction<FunctionPluginHooks['resolveId']>;
  49. interface ResolverObject {
  50. buildStart?: FunctionPluginHooks['buildStart'];
  51. resolveId: ResolverFunction;
  52. }
  53. /**
  54. * Specifies an `Object`, or an `Array` of `Object`,
  55. * which defines aliases used to replace values in `import` or `require` statements.
  56. * With either format, the order of the entries is important,
  57. * in that the first defined rules are applied first.
  58. *
  59. * This is passed to \@rollup/plugin-alias as the "entries" field
  60. * https://github.com/rollup/plugins/tree/master/packages/alias#entries
  61. */
  62. type AliasOptions = readonly Alias[] | {
  63. [find: string]: string;
  64. };
  65. //#endregion
  66. //#region src/node/assetSource.d.ts
  67. /**
  68. * Defines which attributes of an HTML element should be treated as asset sources.
  69. * Used in `html.additionalAssetSources` configuration.
  70. */
  71. interface HtmlAssetSource {
  72. /**
  73. * Attributes that contain a single asset URL.
  74. * @example ['src', 'data-src-dark']
  75. */
  76. srcAttributes?: string[];
  77. /**
  78. * Attributes that contain srcset-format URLs.
  79. * @example ['srcset', 'imagesrcset']
  80. */
  81. srcsetAttributes?: string[];
  82. /**
  83. * Called before handling an attribute to determine if it should be processed.
  84. */
  85. filter?: (data: HtmlAssetSourceFilterData) => boolean;
  86. }
  87. interface HtmlAssetSourceFilterData {
  88. key: string;
  89. value: string;
  90. attributes: Record<string, string>;
  91. }
  92. //#endregion
  93. //#region src/types/commonjs.d.ts
  94. interface RollupCommonJSOptions {
  95. /**
  96. * A minimatch pattern, or array of patterns, which specifies the files in
  97. * the build the plugin should operate on. By default, all files with
  98. * extension `".cjs"` or those in `extensions` are included, but you can
  99. * narrow this list by only including specific files. These files will be
  100. * analyzed and transpiled if either the analysis does not find ES module
  101. * specific statements or `transformMixedEsModules` is `true`.
  102. * @default undefined
  103. */
  104. include?: string | RegExp | readonly (string | RegExp)[];
  105. /**
  106. * A minimatch pattern, or array of patterns, which specifies the files in
  107. * the build the plugin should _ignore_. By default, all files with
  108. * extensions other than those in `extensions` or `".cjs"` are ignored, but you
  109. * can exclude additional files. See also the `include` option.
  110. * @default undefined
  111. */
  112. exclude?: string | RegExp | readonly (string | RegExp)[];
  113. /**
  114. * For extensionless imports, search for extensions other than .js in the
  115. * order specified. Note that you need to make sure that non-JavaScript files
  116. * are transpiled by another plugin first.
  117. * @default [ '.js' ]
  118. */
  119. extensions?: ReadonlyArray<string>;
  120. /**
  121. * If true then uses of `global` won't be dealt with by this plugin
  122. * @default false
  123. */
  124. ignoreGlobal?: boolean;
  125. /**
  126. * If false, skips source map generation for CommonJS modules. This will
  127. * improve performance.
  128. * @default true
  129. */
  130. sourceMap?: boolean;
  131. /**
  132. * Some `require` calls cannot be resolved statically to be translated to
  133. * imports.
  134. * When this option is set to `false`, the generated code will either
  135. * directly throw an error when such a call is encountered or, when
  136. * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
  137. * configured dynamic require target.
  138. * Setting this option to `true` will instead leave the `require` call in the
  139. * code or use it as a fallback for `dynamicRequireTargets`.
  140. * @default false
  141. */
  142. ignoreDynamicRequires?: boolean;
  143. /**
  144. * Instructs the plugin whether to enable mixed module transformations. This
  145. * is useful in scenarios with modules that contain a mix of ES `import`
  146. * statements and CommonJS `require` expressions. Set to `true` if `require`
  147. * calls should be transformed to imports in mixed modules, or `false` if the
  148. * `require` expressions should survive the transformation. The latter can be
  149. * important if the code contains environment detection, or you are coding
  150. * for an environment with special treatment for `require` calls such as
  151. * ElectronJS. See also the `ignore` option.
  152. * @default false
  153. */
  154. transformMixedEsModules?: boolean;
  155. /**
  156. * By default, this plugin will try to hoist `require` statements as imports
  157. * to the top of each file. While this works well for many code bases and
  158. * allows for very efficient ESM output, it does not perfectly capture
  159. * CommonJS semantics as the order of side effects like log statements may
  160. * change. But it is especially problematic when there are circular `require`
  161. * calls between CommonJS modules as those often rely on the lazy execution of
  162. * nested `require` calls.
  163. *
  164. * Setting this option to `true` will wrap all CommonJS files in functions
  165. * which are executed when they are required for the first time, preserving
  166. * NodeJS semantics. Note that this can have an impact on the size and
  167. * performance of the generated code.
  168. *
  169. * The default value of `"auto"` will only wrap CommonJS files when they are
  170. * part of a CommonJS dependency cycle, e.g. an index file that is required by
  171. * many of its dependencies. All other CommonJS files are hoisted. This is the
  172. * recommended setting for most code bases.
  173. *
  174. * `false` will entirely prevent wrapping and hoist all files. This may still
  175. * work depending on the nature of cyclic dependencies but will often cause
  176. * problems.
  177. *
  178. * You can also provide a minimatch pattern, or array of patterns, to only
  179. * specify a subset of files which should be wrapped in functions for proper
  180. * `require` semantics.
  181. *
  182. * `"debug"` works like `"auto"` but after bundling, it will display a warning
  183. * containing a list of ids that have been wrapped which can be used as
  184. * minimatch pattern for fine-tuning.
  185. * @default "auto"
  186. */
  187. strictRequires?: boolean | string | RegExp | readonly (string | RegExp)[];
  188. /**
  189. * Sometimes you have to leave require statements unconverted. Pass an array
  190. * containing the IDs or a `id => boolean` function.
  191. * @default []
  192. */
  193. ignore?: ReadonlyArray<string> | ((id: string) => boolean);
  194. /**
  195. * In most cases, where `require` calls are inside a `try-catch` clause,
  196. * they should be left unconverted as it requires an optional dependency
  197. * that may or may not be installed beside the rolled up package.
  198. * Due to the conversion of `require` to a static `import` - the call is
  199. * hoisted to the top of the file, outside the `try-catch` clause.
  200. *
  201. * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
  202. * - `false`: All `require` calls inside a `try` will be converted as if the
  203. * `try-catch` clause is not there.
  204. * - `remove`: Remove all `require` calls from inside any `try` block.
  205. * - `string[]`: Pass an array containing the IDs to left unconverted.
  206. * - `((id: string) => boolean|'remove')`: Pass a function that controls
  207. * individual IDs.
  208. *
  209. * @default true
  210. */
  211. ignoreTryCatch?: boolean | 'remove' | ReadonlyArray<string> | ((id: string) => boolean | 'remove');
  212. /**
  213. * Controls how to render imports from external dependencies. By default,
  214. * this plugin assumes that all external dependencies are CommonJS. This
  215. * means they are rendered as default imports to be compatible with e.g.
  216. * NodeJS where ES modules can only import a default export from a CommonJS
  217. * dependency.
  218. *
  219. * If you set `esmExternals` to `true`, this plugin assumes that all
  220. * external dependencies are ES modules and respect the
  221. * `requireReturnsDefault` option. If that option is not set, they will be
  222. * rendered as namespace imports.
  223. *
  224. * You can also supply an array of ids to be treated as ES modules, or a
  225. * function that will be passed each external id to determine whether it is
  226. * an ES module.
  227. * @default false
  228. */
  229. esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean);
  230. /**
  231. * Controls what is returned when requiring an ES module from a CommonJS file.
  232. * When using the `esmExternals` option, this will also apply to external
  233. * modules. By default, this plugin will render those imports as namespace
  234. * imports i.e.
  235. *
  236. * ```js
  237. * // input
  238. * const foo = require('foo');
  239. *
  240. * // output
  241. * import * as foo from 'foo';
  242. * ```
  243. *
  244. * However, there are some situations where this may not be desired.
  245. * For these situations, you can change Rollup's behaviour either globally or
  246. * per module. To change it globally, set the `requireReturnsDefault` option
  247. * to one of the following values:
  248. *
  249. * - `false`: This is the default, requiring an ES module returns its
  250. * namespace. This is the only option that will also add a marker
  251. * `__esModule: true` to the namespace to support interop patterns in
  252. * CommonJS modules that are transpiled ES modules.
  253. * - `"namespace"`: Like `false`, requiring an ES module returns its
  254. * namespace, but the plugin does not add the `__esModule` marker and thus
  255. * creates more efficient code. For external dependencies when using
  256. * `esmExternals: true`, no additional interop code is generated.
  257. * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
  258. * Rollup: If a module has a default export and no named exports, requiring
  259. * that module returns the default export. In all other cases, the namespace
  260. * is returned. For external dependencies when using `esmExternals: true`, a
  261. * corresponding interop helper is added.
  262. * - `"preferred"`: If a module has a default export, requiring that module
  263. * always returns the default export, no matter whether additional named
  264. * exports exist. This is similar to how previous versions of this plugin
  265. * worked. Again for external dependencies when using `esmExternals: true`,
  266. * an interop helper is added.
  267. * - `true`: This will always try to return the default export on require
  268. * without checking if it actually exists. This can throw at build time if
  269. * there is no default export. This is how external dependencies are handled
  270. * when `esmExternals` is not used. The advantage over the other options is
  271. * that, like `false`, this does not add an interop helper for external
  272. * dependencies, keeping the code lean.
  273. *
  274. * To change this for individual modules, you can supply a function for
  275. * `requireReturnsDefault` instead. This function will then be called once for
  276. * each required ES module or external dependency with the corresponding id
  277. * and allows you to return different values for different modules.
  278. * @default false
  279. */
  280. requireReturnsDefault?: boolean | 'auto' | 'preferred' | 'namespace' | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace');
  281. /**
  282. * @default "auto"
  283. */
  284. defaultIsModuleExports?: boolean | 'auto' | ((id: string) => boolean | 'auto');
  285. /**
  286. * Some modules contain dynamic `require` calls, or require modules that
  287. * contain circular dependencies, which are not handled well by static
  288. * imports. Including those modules as `dynamicRequireTargets` will simulate a
  289. * CommonJS (NodeJS-like) environment for them with support for dynamic
  290. * dependencies. It also enables `strictRequires` for those modules.
  291. *
  292. * Note: In extreme cases, this feature may result in some paths being
  293. * rendered as absolute in the final bundle. The plugin tries to avoid
  294. * exposing paths from the local machine, but if you are `dynamicRequirePaths`
  295. * with paths that are far away from your project's folder, that may require
  296. * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
  297. */
  298. dynamicRequireTargets?: string | ReadonlyArray<string>;
  299. /**
  300. * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
  301. * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
  302. * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
  303. * home directory name. By default, it uses the current working directory.
  304. */
  305. dynamicRequireRoot?: string;
  306. }
  307. //#endregion
  308. //#region src/types/dynamicImportVars.d.ts
  309. interface RollupDynamicImportVarsOptions {
  310. /**
  311. * Files to include in this plugin (default all).
  312. * @default []
  313. */
  314. include?: string | RegExp | (string | RegExp)[];
  315. /**
  316. * Files to exclude in this plugin (default none).
  317. * @default []
  318. */
  319. exclude?: string | RegExp | (string | RegExp)[];
  320. /**
  321. * @deprecated This option is no-op and will be removed in future versions.
  322. */
  323. warnOnError?: boolean;
  324. }
  325. //#endregion
  326. //#region src/types/anymatch.d.ts
  327. type AnymatchFn = (testString: string) => boolean;
  328. type AnymatchPattern = string | RegExp | AnymatchFn;
  329. type AnymatchMatcher = AnymatchPattern | AnymatchPattern[];
  330. //#endregion
  331. //#region src/types/chokidar.d.ts
  332. declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
  333. options: WatchOptions;
  334. /**
  335. * Constructs a new FSWatcher instance with optional WatchOptions parameter.
  336. */
  337. constructor(options?: WatchOptions);
  338. /**
  339. * When called, requests that the Node.js event loop not exit so long as the fs.FSWatcher is active.
  340. * Calling watcher.ref() multiple times will have no effect.
  341. */
  342. ref(): this;
  343. /**
  344. * When called, the active fs.FSWatcher object will not require the Node.js event loop to remain active.
  345. * If there is no other activity keeping the event loop running, the process may exit before the fs.FSWatcher object's callback is invoked.
  346. * Calling watcher.unref() multiple times will have no effect.
  347. */
  348. unref(): this;
  349. /**
  350. * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
  351. * string.
  352. */
  353. add(paths: string | ReadonlyArray<string>): this;
  354. /**
  355. * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
  356. * string.
  357. */
  358. unwatch(paths: string | ReadonlyArray<string>): this;
  359. /**
  360. * Returns an object representing all the paths on the file system being watched by this
  361. * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
  362. * the `cwd` option was used), and the values are arrays of the names of the items contained in
  363. * each directory.
  364. */
  365. getWatched(): {
  366. [directory: string]: string[];
  367. };
  368. /**
  369. * Removes all listeners from watched files.
  370. */
  371. close(): Promise<void>;
  372. on(event: 'add' | 'addDir' | 'change', listener: (path: string, stats?: fs.Stats) => void): this;
  373. on(event: 'all', listener: (eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir', path: string, stats?: fs.Stats) => void): this;
  374. /**
  375. * Error occurred
  376. */
  377. on(event: 'error', listener: (error: Error) => void): this;
  378. /**
  379. * Exposes the native Node `fs.FSWatcher events`
  380. */
  381. on(event: 'raw', listener: (eventName: string, path: string, details: any) => void): this;
  382. /**
  383. * Fires when the initial scan is complete
  384. */
  385. on(event: 'ready', listener: () => void): this;
  386. on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this;
  387. on(event: string, listener: (...args: any[]) => void): this;
  388. }
  389. interface WatchOptions {
  390. /**
  391. * Indicates whether the process should continue to run as long as files are being watched. If
  392. * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
  393. * even if the process continues to run.
  394. */
  395. persistent?: boolean;
  396. /**
  397. * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
  398. * be ignored. The whole relative or absolute path is tested, not just filename. If a function
  399. * with two arguments is provided, it gets called twice per path - once with a single argument
  400. * (the path), second time with two arguments (the path and the
  401. * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
  402. */
  403. ignored?: AnymatchMatcher;
  404. /**
  405. * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
  406. * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
  407. */
  408. ignoreInitial?: boolean;
  409. /**
  410. * When `false`, only the symlinks themselves will be watched for changes instead of following
  411. * the link references and bubbling events through the link's path.
  412. */
  413. followSymlinks?: boolean;
  414. /**
  415. * The base directory from which watch `paths` are to be derived. Paths emitted with events will
  416. * be relative to this.
  417. */
  418. cwd?: string;
  419. /**
  420. * If set to true then the strings passed to .watch() and .add() are treated as literal path
  421. * names, even if they look like globs.
  422. *
  423. * @default false
  424. */
  425. disableGlobbing?: boolean;
  426. /**
  427. * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
  428. * utilization, consider setting this to `false`. It is typically necessary to **set this to
  429. * `true` to successfully watch files over a network**, and it may be necessary to successfully
  430. * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
  431. * the `useFsEvents` default.
  432. */
  433. usePolling?: boolean;
  434. /**
  435. * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
  436. * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
  437. * OS X, `usePolling: true` becomes the default.
  438. */
  439. useFsEvents?: boolean;
  440. /**
  441. * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
  442. * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
  443. * provided even in cases where it wasn't already available from the underlying watch events.
  444. */
  445. alwaysStat?: boolean;
  446. /**
  447. * If set, limits how many levels of subdirectories will be traversed.
  448. */
  449. depth?: number;
  450. /**
  451. * Interval of file system polling.
  452. */
  453. interval?: number;
  454. /**
  455. * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
  456. * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
  457. */
  458. binaryInterval?: number;
  459. /**
  460. * Indicates whether to watch files that don't have read permissions if possible. If watching
  461. * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
  462. * silently.
  463. */
  464. ignorePermissionErrors?: boolean;
  465. /**
  466. * `true` if `useFsEvents` and `usePolling` are `false`. Automatically filters out artifacts
  467. * that occur when using editors that use "atomic writes" instead of writing directly to the
  468. * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
  469. * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
  470. * you can override it by setting `atomic` to a custom value, in milliseconds.
  471. */
  472. atomic?: boolean | number;
  473. /**
  474. * can be set to an object in order to adjust timing params:
  475. */
  476. awaitWriteFinish?: AwaitWriteFinishOptions | boolean;
  477. }
  478. interface AwaitWriteFinishOptions {
  479. /**
  480. * Amount of time in milliseconds for a file size to remain constant before emitting its event.
  481. */
  482. stabilityThreshold?: number;
  483. /**
  484. * File size polling interval.
  485. */
  486. pollInterval?: number;
  487. }
  488. //#endregion
  489. //#region src/types/connect.d.ts
  490. declare namespace Connect {
  491. export type ServerHandle = HandleFunction | http.Server;
  492. export class IncomingMessage extends http.IncomingMessage {
  493. originalUrl?: http.IncomingMessage['url'] | undefined;
  494. }
  495. export type NextFunction = (err?: any) => void;
  496. export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void;
  497. export type NextHandleFunction = (req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
  498. export type ErrorHandleFunction = (err: any, req: IncomingMessage, res: http.ServerResponse, next: NextFunction) => void;
  499. export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction;
  500. export interface ServerStackItem {
  501. route: string;
  502. handle: ServerHandle;
  503. }
  504. export interface Server extends NodeJS.EventEmitter {
  505. (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void;
  506. route: string;
  507. stack: ServerStackItem[];
  508. /**
  509. * Utilize the given middleware `handle` to the given `route`,
  510. * defaulting to _/_. This "route" is the mount-point for the
  511. * middleware, when given a value other than _/_ the middleware
  512. * is only effective when that segment is present in the request's
  513. * pathname.
  514. *
  515. * For example if we were to mount a function at _/admin_, it would
  516. * be invoked on _/admin_, and _/admin/settings_, however it would
  517. * not be invoked for _/_, or _/posts_.
  518. */
  519. use(fn: NextHandleFunction): Server;
  520. use(fn: HandleFunction): Server;
  521. use(route: string, fn: NextHandleFunction): Server;
  522. use(route: string, fn: HandleFunction): Server;
  523. /**
  524. * Handle server requests, punting them down
  525. * the middleware stack.
  526. */
  527. handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void;
  528. /**
  529. * Listen for connections.
  530. *
  531. * This method takes the same arguments
  532. * as node's `http.Server#listen()`.
  533. *
  534. * HTTP and HTTPS:
  535. *
  536. * If you run your application both as HTTP
  537. * and HTTPS you may wrap them individually,
  538. * since your Connect "server" is really just
  539. * a JavaScript `Function`.
  540. *
  541. * var connect = require('connect')
  542. * , http = require('http')
  543. * , https = require('https');
  544. *
  545. * var app = connect();
  546. *
  547. * http.createServer(app).listen(80);
  548. * https.createServer(options, app).listen(443);
  549. */
  550. listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server;
  551. listen(port: number, hostname?: string, callback?: Function): http.Server;
  552. listen(path: string, callback?: Function): http.Server;
  553. listen(handle: any, listeningListener?: Function): http.Server;
  554. }
  555. }
  556. //#endregion
  557. //#region src/shared/forwardConsole.d.ts
  558. type ForwardConsoleLogLevel = "error" | "warn" | "info" | "log" | "debug" | (string & {});
  559. interface ForwardConsoleOptions {
  560. unhandledErrors?: boolean;
  561. logLevels?: ForwardConsoleLogLevel[];
  562. }
  563. interface ResolvedForwardConsoleOptions {
  564. enabled: boolean;
  565. unhandledErrors: boolean;
  566. logLevels: ForwardConsoleLogLevel[];
  567. }
  568. //#endregion
  569. //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_ms@2.1.3/node_modules/http-proxy-3/dist/lib/http-proxy/index.d.ts
  570. interface ProxyTargetDetailed {
  571. host: string;
  572. port: number;
  573. protocol?: string;
  574. hostname?: string;
  575. socketPath?: string;
  576. key?: string;
  577. passphrase?: string;
  578. pfx?: Buffer | string;
  579. cert?: string;
  580. ca?: string;
  581. ciphers?: string;
  582. secureProtocol?: string;
  583. }
  584. type ProxyType = "ws" | "web";
  585. type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
  586. type ProxyTargetUrl = URL | string | {
  587. port: number;
  588. host: string;
  589. protocol?: string;
  590. };
  591. type NormalizeProxyTarget<T extends ProxyTargetUrl> = Exclude<T, string> | URL;
  592. interface ServerOptions$3 {
  593. /** URL string to be parsed with the url module. */
  594. target?: ProxyTarget;
  595. /** URL string to be parsed with the url module or a URL object. */
  596. forward?: ProxyTargetUrl;
  597. /** Object to be passed to http(s).request. */
  598. agent?: any;
  599. /** Object to be passed to https.createServer(). */
  600. ssl?: any;
  601. /** If you want to proxy websockets. */
  602. ws?: boolean;
  603. /** Adds x- forward headers. */
  604. xfwd?: boolean;
  605. /** Verify SSL certificate. */
  606. secure?: boolean;
  607. /** Explicitly specify if we are proxying to another proxy. */
  608. toProxy?: boolean;
  609. /** Specify whether you want to prepend the target's path to the proxy path. */
  610. prependPath?: boolean;
  611. /** Specify whether you want to ignore the proxy path of the incoming request. */
  612. ignorePath?: boolean;
  613. /** Local interface string to bind for outgoing connections. */
  614. localAddress?: string;
  615. /** Changes the origin of the host header to the target URL. */
  616. changeOrigin?: boolean;
  617. /** specify whether you want to keep letter case of response header key */
  618. preserveHeaderKeyCase?: boolean;
  619. /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
  620. auth?: string;
  621. /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
  622. hostRewrite?: string;
  623. /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
  624. autoRewrite?: boolean;
  625. /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
  626. protocolRewrite?: string;
  627. /** rewrites domain of set-cookie headers. */
  628. cookieDomainRewrite?: false | string | {
  629. [oldDomain: string]: string;
  630. };
  631. /** rewrites path of set-cookie headers. Default: false */
  632. cookiePathRewrite?: false | string | {
  633. [oldPath: string]: string;
  634. };
  635. /** object with extra headers to be added to target requests. */
  636. headers?: {
  637. [header: string]: string | string[] | undefined;
  638. };
  639. /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
  640. proxyTimeout?: number;
  641. /** Timeout (in milliseconds) for incoming requests */
  642. timeout?: number;
  643. /** Specify whether you want to follow redirects. Default: false */
  644. followRedirects?: boolean;
  645. /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
  646. selfHandleResponse?: boolean;
  647. /** Buffer */
  648. buffer?: Stream;
  649. /** Explicitly set the method type of the ProxyReq */
  650. method?: string;
  651. /**
  652. * Optionally override the trusted CA certificates.
  653. * This is passed to https.request.
  654. */
  655. ca?: string;
  656. /** Optional fetch implementation to use instead of global fetch, use this to activate fetch-based proxying,
  657. * for example to proxy HTTP/2 requests
  658. */
  659. fetch?: typeof fetch;
  660. /** Optional configuration object for fetch-based proxy requests.
  661. * Use this to customize fetch request and response handling.
  662. * For custom fetch implementations, use the `fetch` property.*/
  663. fetchOptions?: FetchOptions;
  664. }
  665. interface FetchOptions {
  666. /** Fetch request options */
  667. requestOptions?: RequestInit;
  668. /** Called before making the fetch request */
  669. onBeforeRequest?: (requestOptions: RequestInit, req: http.IncomingMessage, res: http.ServerResponse, options: NormalizedServerOptions) => void | Promise<void>;
  670. /** Called after receiving the fetch response */
  671. onAfterResponse?: (response: Response, req: http.IncomingMessage, res: http.ServerResponse, options: NormalizedServerOptions) => void | Promise<void>;
  672. }
  673. interface NormalizedServerOptions extends ServerOptions$3 {
  674. target?: NormalizeProxyTarget<ProxyTarget>;
  675. forward?: NormalizeProxyTarget<ProxyTargetUrl>;
  676. }
  677. type ErrorCallback<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error> = (err: TError, req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse> | net.Socket, target?: ProxyTargetUrl) => void;
  678. type ProxyServerEventMap<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error> = {
  679. error: Parameters<ErrorCallback<TIncomingMessage, TServerResponse, TError>>;
  680. start: [req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, target: ProxyTargetUrl];
  681. open: [socket: net.Socket];
  682. proxyReq: [proxyReq: http.ClientRequest, req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, options: ServerOptions$3, socket: net.Socket];
  683. proxyRes: [proxyRes: InstanceType<TIncomingMessage>, req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>];
  684. proxyReqWs: [proxyReq: http.ClientRequest, req: InstanceType<TIncomingMessage>, socket: net.Socket, options: ServerOptions$3, head: any];
  685. econnreset: [err: Error, req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, target: ProxyTargetUrl];
  686. end: [req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, proxyRes: InstanceType<TIncomingMessage>];
  687. close: [proxyRes: InstanceType<TIncomingMessage>, proxySocket: net.Socket, proxyHead: any];
  688. };
  689. type ProxyMethodArgs<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error> = {
  690. ws: [req: InstanceType<TIncomingMessage>, socket: any, head: any, ...args: [options?: ServerOptions$3, callback?: ErrorCallback<TIncomingMessage, TServerResponse, TError>] | [callback?: ErrorCallback<TIncomingMessage, TServerResponse, TError>]];
  691. web: [req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, ...args: [options: ServerOptions$3, callback?: ErrorCallback<TIncomingMessage, TServerResponse, TError>] | [callback?: ErrorCallback<TIncomingMessage, TServerResponse, TError>]];
  692. };
  693. type PassFunctions<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error> = {
  694. ws: (req: InstanceType<TIncomingMessage>, socket: net.Socket, options: NormalizedServerOptions, head: Buffer | undefined, server: ProxyServer<TIncomingMessage, TServerResponse, TError>, cb?: ErrorCallback<TIncomingMessage, TServerResponse, TError>) => unknown;
  695. web: (req: InstanceType<TIncomingMessage>, res: InstanceType<TServerResponse>, options: NormalizedServerOptions, head: Buffer | undefined, server: ProxyServer<TIncomingMessage, TServerResponse, TError>, cb?: ErrorCallback<TIncomingMessage, TServerResponse, TError>) => unknown;
  696. };
  697. declare class ProxyServer<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error> extends EventEmitter<ProxyServerEventMap<TIncomingMessage, TServerResponse, TError>> {
  698. /**
  699. * Used for proxying WS(S) requests
  700. * @param req - Client request.
  701. * @param socket - Client socket.
  702. * @param head - Client head.
  703. * @param options - Additional options.
  704. */
  705. readonly ws: (...args: ProxyMethodArgs<TIncomingMessage, TServerResponse, TError>["ws"]) => void;
  706. /**
  707. * Used for proxying regular HTTP(S) requests
  708. * @param req - Client request.
  709. * @param res - Client response.
  710. * @param options - Additional options.
  711. */
  712. readonly web: (...args: ProxyMethodArgs<TIncomingMessage, TServerResponse, TError>["web"]) => void;
  713. private options;
  714. private webPasses;
  715. private wsPasses;
  716. private _server?;
  717. /**
  718. * Creates the proxy server with specified options.
  719. * @param options - Config object passed to the proxy
  720. */
  721. constructor(options?: ServerOptions$3);
  722. /**
  723. * Creates the proxy server with specified options.
  724. * @param options Config object passed to the proxy
  725. * @returns Proxy object with handlers for `ws` and `web` requests
  726. */
  727. static createProxyServer<TIncomingMessage extends typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse, TError = Error>(options?: ServerOptions$3): ProxyServer<TIncomingMessage, TServerResponse, TError>;
  728. /**
  729. * Creates the proxy server with specified options.
  730. * @param options Config object passed to the proxy
  731. * @returns Proxy object with handlers for `ws` and `web` requests
  732. */
  733. static createServer<TIncomingMessage extends typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse, TError = Error>(options?: ServerOptions$3): ProxyServer<TIncomingMessage, TServerResponse, TError>;
  734. /**
  735. * Creates the proxy server with specified options.
  736. * @param options Config object passed to the proxy
  737. * @returns Proxy object with handlers for `ws` and `web` requests
  738. */
  739. static createProxy<TIncomingMessage extends typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse, TError = Error>(options?: ServerOptions$3): ProxyServer<TIncomingMessage, TServerResponse, TError>;
  740. createRightProxy: <PT extends ProxyType>(type: PT) => Function;
  741. onError: (err: TError) => void;
  742. /**
  743. * A function that wraps the object in a webserver, for your convenience
  744. * @param port - Port to listen on
  745. * @param hostname - The hostname to listen on
  746. */
  747. listen: (port: number, hostname?: string) => this;
  748. address: () => string | net.AddressInfo | null | undefined;
  749. /**
  750. * A function that closes the inner webserver and stops listening on given port
  751. */
  752. close: (cb?: Function) => void;
  753. before: <PT extends ProxyType>(type: PT, passName: string, cb: PassFunctions<TIncomingMessage, TServerResponse, TError>[PT]) => void;
  754. after: <PT extends ProxyType>(type: PT, passName: string, cb: PassFunctions<TIncomingMessage, TServerResponse, TError>[PT]) => void;
  755. }
  756. //#endregion
  757. //#region ../../node_modules/.pnpm/http-proxy-3@1.23.3_ms@2.1.3/node_modules/http-proxy-3/dist/lib/http-proxy/passes/ws-incoming.d.ts
  758. declare function numOpenSockets(): number;
  759. declare namespace index_d_exports {
  760. export { ErrorCallback, ProxyServer, ProxyTarget, ProxyTargetUrl, ServerOptions$3 as ServerOptions, createProxyServer as createProxy, createProxyServer, createProxyServer as createServer, ProxyServer as default, numOpenSockets };
  761. }
  762. /**
  763. * Creates the proxy server.
  764. *
  765. * Examples:
  766. *
  767. * httpProxy.createProxyServer({ .. }, 8000)
  768. * // => '{ web: [Function], ws: [Function] ... }'
  769. *
  770. * @param {Object} Options Config object passed to the proxy
  771. *
  772. * @return {Object} Proxy Proxy object with handlers for `ws` and `web` requests
  773. *
  774. * @api public
  775. */
  776. declare function createProxyServer<TIncomingMessage extends typeof http.IncomingMessage = typeof http.IncomingMessage, TServerResponse extends typeof http.ServerResponse = typeof http.ServerResponse, TError = Error>(options?: ServerOptions$3): ProxyServer<TIncomingMessage, TServerResponse, TError>;
  777. //#endregion
  778. //#region src/node/server/middlewares/proxy.d.ts
  779. interface ProxyOptions extends ServerOptions$3 {
  780. /**
  781. * rewrite path
  782. */
  783. rewrite?: (path: string) => string;
  784. /**
  785. * configure the proxy server (e.g. listen to events)
  786. */
  787. configure?: (proxy: ProxyServer, options: ProxyOptions) => void;
  788. /**
  789. * webpack-dev-server style bypass function
  790. */
  791. bypass?: (req: http.IncomingMessage, res: http.ServerResponse | undefined, options: ProxyOptions) => void | null | undefined | false | string | Promise<void | null | undefined | boolean | string>;
  792. /**
  793. * rewrite the Origin header of a WebSocket request to match the target
  794. *
  795. * **Exercise caution as rewriting the Origin can leave the proxying open to [CSRF attacks](https://owasp.org/www-community/attacks/csrf).**
  796. */
  797. rewriteWsOrigin?: boolean | undefined;
  798. }
  799. //#endregion
  800. //#region src/node/http.d.ts
  801. interface CommonServerOptions {
  802. /**
  803. * Specify server port. Note if the port is already being used, Vite will
  804. * automatically try the next available port so this may not be the actual
  805. * port the server ends up listening on.
  806. */
  807. port?: number;
  808. /**
  809. * If enabled, vite will exit if specified port is already in use
  810. */
  811. strictPort?: boolean;
  812. /**
  813. * Specify which IP addresses the server should listen on.
  814. * Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
  815. */
  816. host?: string | boolean;
  817. /**
  818. * The hostnames that Vite is allowed to respond to.
  819. * `localhost` and subdomains under `.localhost` and all IP addresses are allowed by default.
  820. * When using HTTPS, this check is skipped.
  821. *
  822. * If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname.
  823. * For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
  824. *
  825. * If set to `true`, the server is allowed to respond to requests for any hosts.
  826. * This is not recommended as it will be vulnerable to DNS rebinding attacks.
  827. */
  828. allowedHosts?: string[] | true;
  829. /**
  830. * Enable TLS + HTTP/2.
  831. * Note: this downgrades to TLS only when the proxy option is also used.
  832. */
  833. https?: HttpsServerOptions;
  834. /**
  835. * Open browser window on startup
  836. */
  837. open?: boolean | string;
  838. /**
  839. * Configure custom proxy rules for the dev server. Expects an object
  840. * of `{ key: options }` pairs.
  841. * Uses [`http-proxy-3`](https://github.com/sagemathinc/http-proxy-3).
  842. * Full options [here](https://github.com/sagemathinc/http-proxy-3#options).
  843. *
  844. * Example `vite.config.js`:
  845. * ``` js
  846. * module.exports = {
  847. * proxy: {
  848. * // string shorthand: /foo -> http://localhost:4567/foo
  849. * '/foo': 'http://localhost:4567',
  850. * // with options
  851. * '/api': {
  852. * target: 'http://jsonplaceholder.typicode.com',
  853. * changeOrigin: true,
  854. * rewrite: path => path.replace(/^\/api/, '')
  855. * }
  856. * }
  857. * }
  858. * ```
  859. */
  860. proxy?: Record<string, string | ProxyOptions>;
  861. /**
  862. * Configure CORS for the dev server.
  863. * Uses https://github.com/expressjs/cors.
  864. *
  865. * When enabling this option, **we recommend setting a specific value
  866. * rather than `true`** to avoid exposing the source code to untrusted origins.
  867. *
  868. * Set to `true` to allow all methods from any origin, or configure separately
  869. * using an object.
  870. *
  871. * @default { origin: /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/ }
  872. */
  873. cors?: CorsOptions | boolean;
  874. /**
  875. * Specify server response headers.
  876. */
  877. headers?: OutgoingHttpHeaders;
  878. }
  879. /**
  880. * https://github.com/expressjs/cors#configuration-options
  881. */
  882. interface CorsOptions {
  883. /**
  884. * Configures the Access-Control-Allow-Origin CORS header.
  885. *
  886. * **We recommend setting a specific value rather than
  887. * `true`** to avoid exposing the source code to untrusted origins.
  888. */
  889. origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
  890. methods?: string | string[];
  891. allowedHeaders?: string | string[];
  892. exposedHeaders?: string | string[];
  893. credentials?: boolean;
  894. maxAge?: number;
  895. preflightContinue?: boolean;
  896. optionsSuccessStatus?: number;
  897. }
  898. type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
  899. //#endregion
  900. //#region src/node/optimizer/index.d.ts
  901. type ExportsData = {
  902. hasModuleSyntax: boolean;
  903. exports: readonly string[];
  904. jsxLoader?: boolean;
  905. };
  906. interface DepsOptimizer {
  907. init: () => Promise<void>;
  908. initState: "idle" | "initializing" | "initialized";
  909. metadata: DepOptimizationMetadata;
  910. scanProcessing?: Promise<void>;
  911. registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
  912. run: () => void;
  913. isOptimizedDepFile: (id: string) => boolean;
  914. isOptimizedDepUrl: (url: string) => boolean;
  915. getOptimizedDepId: (depInfo: OptimizedDepInfo) => string;
  916. close: () => Promise<void>;
  917. options: DepOptimizationOptions;
  918. }
  919. interface DepOptimizationConfig {
  920. /**
  921. * Force optimize listed dependencies (must be resolvable import paths).
  922. * Supports experimental glob patterns for deep imports.
  923. */
  924. include?: string[];
  925. /**
  926. * Do not optimize these dependencies (must be resolvable import paths,
  927. * cannot be globs).
  928. */
  929. exclude?: string[];
  930. /**
  931. * Forces ESM interop when importing these dependencies. Some legacy
  932. * packages advertise themselves as ESM but use `require` internally
  933. * @experimental
  934. */
  935. needsInterop?: string[];
  936. /**
  937. * Options to pass to esbuild during the dep scanning and optimization
  938. *
  939. * Certain options are omitted since changing them would not be compatible
  940. * with Vite's dep optimization.
  941. *
  942. * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
  943. * - `plugins` are merged with Vite's dep plugin
  944. *
  945. * https://esbuild.github.io/api
  946. *
  947. * @deprecated Use `rolldownOptions` instead.
  948. */
  949. esbuildOptions?: DepsOptimizerEsbuildOptions;
  950. /**
  951. * @deprecated Use `rolldownOptions` instead.
  952. */
  953. rollupOptions?: Omit<RolldownOptions, "input" | "logLevel" | "output"> & {
  954. output?: Omit<OutputOptions, "format" | "sourcemap" | "dir" | "banner">;
  955. };
  956. /**
  957. * Options to pass to rolldown during the dep scanning and optimization
  958. *
  959. * Certain options are omitted since changing them would not be compatible
  960. * with Vite's dep optimization.
  961. *
  962. * - `plugins` are merged with Vite's dep plugin
  963. */
  964. rolldownOptions?: Omit<RolldownOptions, "input" | "logLevel" | "output"> & {
  965. output?: Omit<OutputOptions, "format" | "sourcemap" | "dir" | "banner">;
  966. };
  967. /**
  968. * List of file extensions that can be optimized. A corresponding esbuild
  969. * plugin must exist to handle the specific extension.
  970. *
  971. * By default, Vite can optimize `.mjs`, `.js`, `.ts`, and `.mts` files. This option
  972. * allows specifying additional extensions.
  973. *
  974. * @experimental
  975. */
  976. extensions?: string[];
  977. /**
  978. * Deps optimization during build was removed in Vite 5.1. This option is
  979. * now redundant and will be removed in a future version. Switch to using
  980. * `optimizeDeps.noDiscovery` and an empty or undefined `optimizeDeps.include`.
  981. * true or 'dev' disables the optimizer, false or 'build' leaves it enabled.
  982. * @default 'build'
  983. * @deprecated
  984. * @experimental
  985. */
  986. disabled?: boolean | "build" | "dev";
  987. /**
  988. * Automatic dependency discovery. When `noDiscovery` is true, only dependencies
  989. * listed in `include` will be optimized. The scanner isn't run for cold start
  990. * in this case. CJS-only dependencies must be present in `include` during dev.
  991. * @default false
  992. */
  993. noDiscovery?: boolean;
  994. /**
  995. * When enabled, it will hold the first optimized deps results until all static
  996. * imports are crawled on cold start. This avoids the need for full-page reloads
  997. * when new dependencies are discovered and they trigger the generation of new
  998. * common chunks. If all dependencies are found by the scanner plus the explicitly
  999. * defined ones in `include`, it is better to disable this option to let the
  1000. * browser process more requests in parallel.
  1001. * @default true
  1002. * @experimental
  1003. */
  1004. holdUntilCrawlEnd?: boolean;
  1005. /**
  1006. * When enabled, Vite will not throw an error when an outdated optimized
  1007. * dependency is requested. Enabling this option may cause a single module
  1008. * to have a multiple reference.
  1009. * @default false
  1010. * @experimental
  1011. */
  1012. ignoreOutdatedRequests?: boolean;
  1013. }
  1014. type DepOptimizationOptions = DepOptimizationConfig & {
  1015. /**
  1016. * By default, Vite will crawl your `index.html` to detect dependencies that
  1017. * need to be pre-bundled. If `build.rolldownOptions.input` is specified, Vite
  1018. * will crawl those entry points instead.
  1019. *
  1020. * If neither of these fit your needs, you can specify custom entries using
  1021. * this option - the value should be a tinyglobby pattern or array of patterns
  1022. * (https://github.com/SuperchupuDev/tinyglobby) that are relative from
  1023. * vite project root. This will overwrite default entries inference.
  1024. */
  1025. entries?: string | string[];
  1026. /**
  1027. * Force dep pre-optimization regardless of whether deps have changed.
  1028. * @experimental
  1029. */
  1030. force?: boolean;
  1031. };
  1032. interface OptimizedDepInfo {
  1033. id: string;
  1034. file: string;
  1035. src?: string;
  1036. needsInterop?: boolean;
  1037. browserHash?: string;
  1038. fileHash?: string;
  1039. /**
  1040. * During optimization, ids can still be resolved to their final location
  1041. * but the bundles may not yet be saved to disk
  1042. */
  1043. processing?: Promise<void>;
  1044. /**
  1045. * ExportData cache, discovered deps will parse the src entry to get exports
  1046. * data used both to define if interop is needed and when pre-bundling
  1047. */
  1048. exportsData?: Promise<ExportsData>;
  1049. isDynamicEntry?: boolean;
  1050. }
  1051. interface DepOptimizationMetadata {
  1052. /**
  1053. * The main hash is determined by user config and dependency lockfiles.
  1054. * This is checked on server startup to avoid unnecessary re-bundles.
  1055. */
  1056. hash: string;
  1057. /**
  1058. * This hash is determined by dependency lockfiles.
  1059. * This is checked on server startup to avoid unnecessary re-bundles.
  1060. */
  1061. lockfileHash: string;
  1062. /**
  1063. * This hash is determined by user config.
  1064. * This is checked on server startup to avoid unnecessary re-bundles.
  1065. */
  1066. configHash: string;
  1067. /**
  1068. * The browser hash is determined by the main hash plus additional dependencies
  1069. * discovered at runtime. This is used to invalidate browser requests to
  1070. * optimized deps.
  1071. */
  1072. browserHash: string;
  1073. /**
  1074. * Metadata for each already optimized dependency
  1075. */
  1076. optimized: Record<string, OptimizedDepInfo>;
  1077. /**
  1078. * Metadata for non-entry optimized chunks and dynamic imports
  1079. */
  1080. chunks: Record<string, OptimizedDepInfo>;
  1081. /**
  1082. * Metadata for each newly discovered dependency after processing
  1083. */
  1084. discovered: Record<string, OptimizedDepInfo>;
  1085. /**
  1086. * OptimizedDepInfo list
  1087. */
  1088. depInfoList: OptimizedDepInfo[];
  1089. }
  1090. /**
  1091. * Scan and optimize dependencies within a project.
  1092. * Used by Vite CLI when running `vite optimize`.
  1093. *
  1094. * @deprecated the optimization process runs automatically and does not need to be called
  1095. */
  1096. export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean): Promise<DepOptimizationMetadata>;
  1097. //#endregion
  1098. //#region src/node/server/bundledDev.d.ts
  1099. type MemoryFile = {
  1100. source: string | Uint8Array;
  1101. etag?: string;
  1102. };
  1103. declare class MemoryFiles {
  1104. private files;
  1105. get size(): number;
  1106. get(file: string): MemoryFile | undefined;
  1107. set(file: string, content: MemoryFile | (() => MemoryFile)): void;
  1108. has(file: string): boolean;
  1109. clear(): void;
  1110. }
  1111. declare class BundledDev {
  1112. private environment;
  1113. private _devEngine;
  1114. /** the vite client and the rolldown runtime; set before the first build so `hasBuildOutput` can count them */
  1115. private staticFiles;
  1116. private initialBuildCompleted;
  1117. private _closed;
  1118. private clients;
  1119. private debouncedFullReload;
  1120. private fullReloadPending;
  1121. private reloadNeededClientIds;
  1122. private debouncedReloadNeededFlush;
  1123. private lastBuildError;
  1124. memoryFiles: MemoryFiles;
  1125. constructor(environment: DevEnvironment);
  1126. private get devEngine();
  1127. private pendingPayloadFilenames;
  1128. get hasBuildOutput(): boolean;
  1129. listen(): Promise<void>;
  1130. private waitForInitialBuildFinish;
  1131. private ensureOutputAndFlushReloadNeeded;
  1132. triggerBundleRegenerationIfStale(): Promise<boolean>;
  1133. triggerLazyBundling(moduleId: string | null, clientId: string | null): Promise<{
  1134. code: string;
  1135. filename: string;
  1136. } | undefined>;
  1137. /**
  1138. * Called when the client reports that it evaluated a payload (the line appended
  1139. * by `payloadDeliveredAck`). Only then is the payload recorded on the server's
  1140. * per-client ship map, so later chunks may omit a module only if the client
  1141. * already registered it.
  1142. *
  1143. * Note: the payload filename is unique across all clients.
  1144. */
  1145. markPayloadDelivered(filename: string): void;
  1146. close(): Promise<void>;
  1147. private storeStaticFiles;
  1148. private storeOutputFiles;
  1149. private getRolldownOptions;
  1150. private handleHmrOutput;
  1151. }
  1152. //#endregion
  1153. //#region src/node/server/transformRequest.d.ts
  1154. interface TransformResult {
  1155. code: string;
  1156. map: SourceMap | {
  1157. mappings: "";
  1158. } | null;
  1159. ssr?: boolean;
  1160. etag?: string;
  1161. deps?: string[];
  1162. dynamicDeps?: string[];
  1163. }
  1164. interface TransformOptions {
  1165. /**
  1166. * @deprecated inferred from environment
  1167. */
  1168. ssr?: boolean;
  1169. }
  1170. //#endregion
  1171. //#region src/node/server/moduleGraph.d.ts
  1172. declare class EnvironmentModuleNode {
  1173. environment: string;
  1174. /**
  1175. * Public served url path, starts with /
  1176. */
  1177. url: string;
  1178. /**
  1179. * Resolved file system path + query
  1180. */
  1181. id: string | null;
  1182. file: string | null;
  1183. type: "js" | "css" | "asset";
  1184. info?: ModuleInfo;
  1185. meta?: Record<string, any>;
  1186. importers: Set<EnvironmentModuleNode>;
  1187. importedModules: Set<EnvironmentModuleNode>;
  1188. acceptedHmrDeps: Set<EnvironmentModuleNode>;
  1189. acceptedHmrExports: Set<string> | null;
  1190. importedBindings: Map<string, Set<string>> | null;
  1191. isSelfAccepting?: boolean;
  1192. transformResult: TransformResult | null;
  1193. ssrModule: Record<string, any> | null;
  1194. ssrError: Error | null;
  1195. lastHMRTimestamp: number;
  1196. lastInvalidationTimestamp: number;
  1197. /**
  1198. * @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
  1199. */
  1200. constructor(url: string, environment: string, setIsSelfAccepting?: boolean);
  1201. }
  1202. type ResolvedUrl = [url: string, resolvedId: string, meta: object | null | undefined];
  1203. declare class EnvironmentModuleGraph {
  1204. environment: string;
  1205. urlToModuleMap: Map<string, EnvironmentModuleNode>;
  1206. idToModuleMap: Map<string, EnvironmentModuleNode>;
  1207. etagToModuleMap: Map<string, EnvironmentModuleNode>;
  1208. fileToModulesMap: Map<string, Set<EnvironmentModuleNode>>;
  1209. constructor(environment: string, resolveId: (url: string) => Promise<PartialResolvedId | null>);
  1210. getModuleByUrl(rawUrl: string): Promise<EnvironmentModuleNode | undefined>;
  1211. getModuleById(id: string): EnvironmentModuleNode | undefined;
  1212. getModulesByFile(file: string): Set<EnvironmentModuleNode> | undefined;
  1213. onFileChange(file: string): void;
  1214. onFileDelete(file: string): void;
  1215. invalidateModule(mod: EnvironmentModuleNode, seen?: Set<EnvironmentModuleNode>, timestamp?: number, isHmr?: boolean, softInvalidate?: boolean): void;
  1216. invalidateAll(): void;
  1217. /**
  1218. * Update the module graph based on a module's updated imports information
  1219. * If there are dependencies that no longer have any importers, they are
  1220. * returned as a Set.
  1221. *
  1222. * @param staticImportedUrls Subset of `importedModules` where they're statically imported in code.
  1223. * This is only used for soft invalidations so `undefined` is fine but may cause more runtime processing.
  1224. */
  1225. updateModuleInfo(mod: EnvironmentModuleNode, importedModules: Set<string | EnvironmentModuleNode>, importedBindings: Map<string, Set<string>> | null, acceptedModules: Set<string | EnvironmentModuleNode>, acceptedExports: Set<string> | null, isSelfAccepting: boolean, staticImportedUrls?: Set<string>): Promise<Set<EnvironmentModuleNode> | undefined>;
  1226. ensureEntryFromUrl(rawUrl: string, setIsSelfAccepting?: boolean): Promise<EnvironmentModuleNode>;
  1227. createFileOnlyEntry(file: string): EnvironmentModuleNode;
  1228. resolveUrl(url: string): Promise<ResolvedUrl>;
  1229. updateModuleTransformResult(mod: EnvironmentModuleNode, result: TransformResult | null): void;
  1230. getModuleByEtag(etag: string): EnvironmentModuleNode | undefined;
  1231. }
  1232. //#endregion
  1233. //#region src/node/server/mixedModuleGraph.d.ts
  1234. declare class ModuleNode {
  1235. _moduleGraph: ModuleGraph;
  1236. _clientModule: EnvironmentModuleNode | undefined;
  1237. _ssrModule: EnvironmentModuleNode | undefined;
  1238. constructor(moduleGraph: ModuleGraph, clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode);
  1239. _get<T extends keyof EnvironmentModuleNode>(prop: T): EnvironmentModuleNode[T];
  1240. _set<T extends keyof EnvironmentModuleNode>(prop: T, value: EnvironmentModuleNode[T]): void;
  1241. _wrapModuleSet(prop: ModuleSetNames, module: EnvironmentModuleNode | undefined): Set<ModuleNode>;
  1242. _getModuleSetUnion(prop: "importedModules" | "importers"): Set<ModuleNode>;
  1243. _getModuleInfoUnion(prop: "info"): ModuleInfo | undefined;
  1244. _getModuleObjectUnion(prop: "meta"): Record<string, any> | undefined;
  1245. get url(): string;
  1246. set url(value: string);
  1247. get id(): string | null;
  1248. set id(value: string | null);
  1249. get file(): string | null;
  1250. set file(value: string | null);
  1251. get type(): "js" | "css" | "asset";
  1252. get info(): ModuleInfo | undefined;
  1253. get meta(): Record<string, any> | undefined;
  1254. get importers(): Set<ModuleNode>;
  1255. get clientImportedModules(): Set<ModuleNode>;
  1256. get ssrImportedModules(): Set<ModuleNode>;
  1257. get importedModules(): Set<ModuleNode>;
  1258. get acceptedHmrDeps(): Set<ModuleNode>;
  1259. get acceptedHmrExports(): Set<string> | null;
  1260. get importedBindings(): Map<string, Set<string>> | null;
  1261. get isSelfAccepting(): boolean | undefined;
  1262. get transformResult(): TransformResult | null;
  1263. set transformResult(value: TransformResult | null);
  1264. get ssrTransformResult(): TransformResult | null;
  1265. set ssrTransformResult(value: TransformResult | null);
  1266. get ssrModule(): Record<string, any> | null;
  1267. get ssrError(): Error | null;
  1268. get lastHMRTimestamp(): number;
  1269. set lastHMRTimestamp(value: number);
  1270. get lastInvalidationTimestamp(): number;
  1271. get invalidationState(): TransformResult | "HARD_INVALIDATED" | undefined;
  1272. get ssrInvalidationState(): TransformResult | "HARD_INVALIDATED" | undefined;
  1273. }
  1274. declare class ModuleGraph {
  1275. urlToModuleMap: Map<string, ModuleNode>;
  1276. idToModuleMap: Map<string, ModuleNode>;
  1277. etagToModuleMap: Map<string, ModuleNode>;
  1278. fileToModulesMap: Map<string, Set<ModuleNode>>;
  1279. private moduleNodeCache;
  1280. constructor(moduleGraphs: {
  1281. client: () => EnvironmentModuleGraph;
  1282. ssr: () => EnvironmentModuleGraph;
  1283. });
  1284. getModuleById(id: string): ModuleNode | undefined;
  1285. getModuleByUrl(url: string, _ssr?: boolean): Promise<ModuleNode | undefined>;
  1286. getModulesByFile(file: string): Set<ModuleNode> | undefined;
  1287. onFileChange(file: string): void;
  1288. onFileDelete(file: string): void;
  1289. invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>, timestamp?: number, isHmr?: boolean, softInvalidate?: boolean): void;
  1290. invalidateAll(): void;
  1291. ensureEntryFromUrl(rawUrl: string, ssr?: boolean, setIsSelfAccepting?: boolean): Promise<ModuleNode>;
  1292. createFileOnlyEntry(file: string): ModuleNode;
  1293. resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
  1294. updateModuleTransformResult(mod: ModuleNode, result: TransformResult | null, ssr?: boolean): void;
  1295. getModuleByEtag(etag: string): ModuleNode | undefined;
  1296. getBackwardCompatibleBrowserModuleNode(clientModule: EnvironmentModuleNode): ModuleNode;
  1297. getBackwardCompatibleServerModuleNode(ssrModule: EnvironmentModuleNode): ModuleNode;
  1298. getBackwardCompatibleModuleNode(mod: EnvironmentModuleNode): ModuleNode;
  1299. getBackwardCompatibleModuleNodeDual(clientModule?: EnvironmentModuleNode, ssrModule?: EnvironmentModuleNode): ModuleNode;
  1300. }
  1301. type ModuleSetNames = "acceptedHmrDeps" | "importedModules";
  1302. //#endregion
  1303. //#region src/node/server/hmr.d.ts
  1304. interface WsOptions {
  1305. protocol?: string;
  1306. host?: string;
  1307. port?: number;
  1308. clientPort?: number;
  1309. path?: string;
  1310. timeout?: number;
  1311. server?: HttpServer;
  1312. }
  1313. interface HmrOptions {
  1314. /**
  1315. * @deprecated Use `server.ws.protocol` instead.
  1316. */
  1317. protocol?: string;
  1318. /**
  1319. * @deprecated Use `server.ws.host` instead.
  1320. */
  1321. host?: string;
  1322. /**
  1323. * @deprecated Use `server.ws.port` instead.
  1324. */
  1325. port?: number;
  1326. /**
  1327. * @deprecated Use `server.ws.clientPort` instead.
  1328. */
  1329. clientPort?: number;
  1330. /**
  1331. * @deprecated Use `server.ws.path` instead.
  1332. */
  1333. path?: string;
  1334. /**
  1335. * @deprecated Use `server.ws.timeout` instead.
  1336. */
  1337. timeout?: number;
  1338. overlay?: boolean;
  1339. /**
  1340. * @deprecated Use `server.ws.server` instead.
  1341. */
  1342. server?: HttpServer;
  1343. }
  1344. interface HotUpdateOptions {
  1345. type: "create" | "update" | "delete";
  1346. file: string;
  1347. timestamp: number;
  1348. modules: Array<EnvironmentModuleNode>;
  1349. read: () => string | Promise<string>;
  1350. server: ViteDevServer;
  1351. }
  1352. interface HmrContext {
  1353. file: string;
  1354. timestamp: number;
  1355. modules: Array<ModuleNode>;
  1356. read: () => string | Promise<string>;
  1357. server: ViteDevServer;
  1358. }
  1359. interface HotChannelClient {
  1360. send(payload: hmrPayload_HotPayload): void;
  1361. }
  1362. type HotChannelListener<T extends string = string> = (data: InferCustomEventPayload<T>, client: HotChannelClient) => void;
  1363. interface HotChannel<Api = any> {
  1364. /**
  1365. * When true, the fs access check is skipped in fetchModule.
  1366. * Set this for transports that is not exposed over the network.
  1367. */
  1368. skipFsCheck?: boolean;
  1369. /**
  1370. * Broadcast events to all clients
  1371. */
  1372. send?(payload: hmrPayload_HotPayload): void;
  1373. /**
  1374. * Handle custom event emitted by `import.meta.hot.send`
  1375. */
  1376. on?<T extends string>(event: T, listener: HotChannelListener<T>): void;
  1377. on?(event: "connection", listener: () => void): void;
  1378. /**
  1379. * Unregister event listener
  1380. */
  1381. off?(event: string, listener: Function): void;
  1382. /**
  1383. * Start listening for messages
  1384. */
  1385. listen?(): void;
  1386. /**
  1387. * Disconnect all clients, called when server is closed or restarted.
  1388. */
  1389. close?(): Promise<unknown> | void;
  1390. api?: Api;
  1391. }
  1392. interface NormalizedHotChannelClient {
  1393. /**
  1394. * Send event to the client
  1395. */
  1396. send(payload: hmrPayload_HotPayload): void;
  1397. /**
  1398. * Send custom event
  1399. */
  1400. send(event: string, payload?: hmrPayload_CustomPayload["data"]): void;
  1401. }
  1402. interface NormalizedHotChannel<Api = any> {
  1403. /**
  1404. * Broadcast events to all clients
  1405. */
  1406. send(payload: hmrPayload_HotPayload): void;
  1407. /**
  1408. * Send custom event
  1409. */
  1410. send<T extends string>(event: T, payload?: InferCustomEventPayload<T>): void;
  1411. /**
  1412. * Handle custom event emitted by `import.meta.hot.send`
  1413. */
  1414. on<T extends string>(event: T, listener: (data: InferCustomEventPayload<T>, client: NormalizedHotChannelClient) => void): void;
  1415. /**
  1416. * @deprecated use `vite:client:connect` event instead
  1417. */
  1418. on(event: "connection", listener: () => void): void;
  1419. /**
  1420. * Unregister event listener
  1421. */
  1422. off(event: string, listener: Function): void;
  1423. handleInvoke(payload: hmrPayload_HotPayload): Promise<{
  1424. result: any;
  1425. } | {
  1426. error: any;
  1427. }>;
  1428. /**
  1429. * Start listening for messages
  1430. */
  1431. listen(): void;
  1432. /**
  1433. * Disconnect all clients, called when server is closed or restarted.
  1434. */
  1435. close(): Promise<unknown> | void;
  1436. api?: Api;
  1437. }
  1438. type ServerHotChannelApi = {
  1439. innerEmitter: EventEmitter;
  1440. outsideEmitter: EventEmitter;
  1441. };
  1442. type ServerHotChannel = HotChannel<ServerHotChannelApi>;
  1443. type NormalizedServerHotChannel = NormalizedHotChannel<ServerHotChannelApi>;
  1444. export declare function createServerHotChannel(): ServerHotChannel;
  1445. //#endregion
  1446. //#region src/node/server/pluginContainer.d.ts
  1447. type SkipInformation = {
  1448. id: string;
  1449. importer: string | undefined;
  1450. plugin: Plugin;
  1451. called?: boolean;
  1452. };
  1453. declare class EnvironmentPluginContainer<Env extends Environment = Environment> {
  1454. private _pluginContextMap;
  1455. private _resolvedRolldownOptions?;
  1456. private _processesing;
  1457. private _seenResolves;
  1458. private _moduleNodeToLoadAddedImports;
  1459. getSortedPluginHooks: PluginHookUtils["getSortedPluginHooks"];
  1460. getSortedPlugins: PluginHookUtils["getSortedPlugins"];
  1461. moduleGraph: EnvironmentModuleGraph | undefined;
  1462. watchFiles: Set<string>;
  1463. minimalContext: MinimalPluginContext$1<Env>;
  1464. private _started;
  1465. private _buildStartPromise;
  1466. private _closed;
  1467. private _updateModuleLoadAddedImports;
  1468. private _getAddedImports;
  1469. getModuleInfo(id: string): ModuleInfo | null;
  1470. private handleHookPromise;
  1471. get options(): InputOptions;
  1472. resolveRolldownOptions(): Promise<InputOptions>;
  1473. private _getPluginContext;
  1474. private hookParallel;
  1475. buildStart(_options?: InputOptions): Promise<void>;
  1476. resolveId(rawId: string, importer?: string | undefined, options?: {
  1477. kind?: ImportKind;
  1478. attributes?: Record<string, string>;
  1479. custom?: CustomPluginOptions;
  1480. /** @deprecated use `skipCalls` instead */
  1481. skip?: Set<Plugin>;
  1482. skipCalls?: readonly SkipInformation[];
  1483. isEntry?: boolean;
  1484. }): Promise<PartialResolvedId | null>;
  1485. load(id: string): Promise<LoadResult | null>;
  1486. transform(code: string, id: string, options?: {
  1487. inMap?: SourceDescription["map"];
  1488. moduleType?: string;
  1489. }): Promise<{
  1490. code: string;
  1491. map: SourceMap | {
  1492. mappings: "";
  1493. } | null;
  1494. moduleType?: ModuleType;
  1495. }>;
  1496. watchChange(id: string, change: {
  1497. event: "create" | "update" | "delete";
  1498. }): Promise<void>;
  1499. close(): Promise<void>;
  1500. }
  1501. declare class BasicMinimalPluginContext<Meta = PluginContextMeta> {
  1502. meta: Meta;
  1503. private _logger;
  1504. constructor(meta: Meta, _logger: Logger);
  1505. get pluginName(): string;
  1506. debug(rawLog: string | RollupLog | (() => string | RollupLog)): void;
  1507. info(rawLog: string | RollupLog | (() => string | RollupLog)): void;
  1508. warn(rawLog: string | RollupLog | (() => string | RollupLog)): void;
  1509. error(e: string | RollupError): never;
  1510. private _normalizeRawLog;
  1511. }
  1512. declare class MinimalPluginContext$1<T extends Environment = Environment> extends BasicMinimalPluginContext implements MinimalPluginContext {
  1513. environment: T;
  1514. constructor(meta: PluginContextMeta, environment: T);
  1515. }
  1516. declare class PluginContainer {
  1517. private environments;
  1518. constructor(environments: Record<string, Environment>);
  1519. private _getEnvironment;
  1520. private _getPluginContainer;
  1521. getModuleInfo(id: string): ModuleInfo | null;
  1522. get options(): InputOptions;
  1523. buildStart(_options?: InputOptions): Promise<void>;
  1524. watchChange(id: string, change: {
  1525. event: "create" | "update" | "delete";
  1526. }): Promise<void>;
  1527. resolveId(rawId: string, importer?: string, options?: {
  1528. attributes?: Record<string, string>;
  1529. custom?: CustomPluginOptions;
  1530. /** @deprecated use `skipCalls` instead */
  1531. skip?: Set<Plugin>;
  1532. skipCalls?: readonly SkipInformation[];
  1533. ssr?: boolean;
  1534. isEntry?: boolean;
  1535. }): Promise<PartialResolvedId | null>;
  1536. load(id: string, options?: {
  1537. ssr?: boolean;
  1538. }): Promise<LoadResult | null>;
  1539. transform(code: string, id: string, options?: {
  1540. ssr?: boolean;
  1541. environment?: Environment;
  1542. inMap?: SourceDescription["map"];
  1543. }): Promise<{
  1544. code: string;
  1545. map: SourceMap | {
  1546. mappings: "";
  1547. } | null;
  1548. }>;
  1549. close(): Promise<void>;
  1550. }
  1551. //#endregion
  1552. //#region src/types/ws.d.ts
  1553. // WebSocket socket.
  1554. declare class WebSocket extends EventEmitter {
  1555. /** The connection is not yet open. */
  1556. static readonly CONNECTING: 0;
  1557. /** The connection is open and ready to communicate. */
  1558. static readonly OPEN: 1;
  1559. /** The connection is in the process of closing. */
  1560. static readonly CLOSING: 2;
  1561. /** The connection is closed. */
  1562. static readonly CLOSED: 3;
  1563. binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments';
  1564. readonly bufferedAmount: number;
  1565. readonly extensions: string;
  1566. /** Indicates whether the websocket is paused */
  1567. readonly isPaused: boolean;
  1568. readonly protocol: string;
  1569. /** The current state of the connection */
  1570. readonly readyState: typeof WebSocket.CONNECTING | typeof WebSocket.OPEN | typeof WebSocket.CLOSING | typeof WebSocket.CLOSED;
  1571. readonly url: string;
  1572. /** The connection is not yet open. */
  1573. readonly CONNECTING: 0;
  1574. /** The connection is open and ready to communicate. */
  1575. readonly OPEN: 1;
  1576. /** The connection is in the process of closing. */
  1577. readonly CLOSING: 2;
  1578. /** The connection is closed. */
  1579. readonly CLOSED: 3;
  1580. onopen: ((event: WebSocket.Event) => void) | null;
  1581. onerror: ((event: WebSocket.ErrorEvent) => void) | null;
  1582. onclose: ((event: WebSocket.CloseEvent) => void) | null;
  1583. onmessage: ((event: WebSocket.MessageEvent) => void) | null;
  1584. constructor(address: null);
  1585. constructor(address: string | url_URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
  1586. constructor(address: string | url_URL, protocols?: string | string[], options?: WebSocket.ClientOptions | ClientRequestArgs);
  1587. close(code?: number, data?: string | Buffer): void;
  1588. ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
  1589. pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void;
  1590. send(data: any, cb?: (err?: Error) => void): void;
  1591. send(data: any, options: {
  1592. mask?: boolean | undefined;
  1593. binary?: boolean | undefined;
  1594. compress?: boolean | undefined;
  1595. fin?: boolean | undefined;
  1596. }, cb?: (err?: Error) => void): void;
  1597. terminate(): void;
  1598. /**
  1599. * Pause the websocket causing it to stop emitting events. Some events can still be
  1600. * emitted after this is called, until all buffered data is consumed. This method
  1601. * is a noop if the ready state is `CONNECTING` or `CLOSED`.
  1602. */
  1603. pause(): void;
  1604. /**
  1605. * Make a paused socket resume emitting events. This method is a noop if the ready
  1606. * state is `CONNECTING` or `CLOSED`.
  1607. */
  1608. resume(): void;
  1609. // HTML5 WebSocket events
  1610. addEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void, options?: WebSocket.EventListenerOptions): void;
  1611. addEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void, options?: WebSocket.EventListenerOptions): void;
  1612. addEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void, options?: WebSocket.EventListenerOptions): void;
  1613. addEventListener(method: 'open', cb: (event: WebSocket.Event) => void, options?: WebSocket.EventListenerOptions): void;
  1614. removeEventListener(method: 'message', cb: (event: WebSocket.MessageEvent) => void): void;
  1615. removeEventListener(method: 'close', cb: (event: WebSocket.CloseEvent) => void): void;
  1616. removeEventListener(method: 'error', cb: (event: WebSocket.ErrorEvent) => void): void;
  1617. removeEventListener(method: 'open', cb: (event: WebSocket.Event) => void): void;
  1618. // Events
  1619. on(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
  1620. on(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
  1621. on(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
  1622. on(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
  1623. on(event: 'open', listener: (this: WebSocket) => void): this;
  1624. on(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
  1625. on(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
  1626. on(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
  1627. once(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
  1628. once(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
  1629. once(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
  1630. once(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
  1631. once(event: 'open', listener: (this: WebSocket) => void): this;
  1632. once(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
  1633. once(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
  1634. once(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
  1635. off(event: 'close', listener: (this: WebSocket, code: number, reason: Buffer) => void): this;
  1636. off(event: 'error', listener: (this: WebSocket, err: Error) => void): this;
  1637. off(event: 'upgrade', listener: (this: WebSocket, request: http.IncomingMessage) => void): this;
  1638. off(event: 'message', listener: (this: WebSocket, data: WebSocket.RawData, isBinary: boolean) => void): this;
  1639. off(event: 'open', listener: (this: WebSocket) => void): this;
  1640. off(event: 'ping' | 'pong', listener: (this: WebSocket, data: Buffer) => void): this;
  1641. off(event: 'unexpected-response', listener: (this: WebSocket, request: ClientRequest, response: http.IncomingMessage) => void): this;
  1642. off(event: string | symbol, listener: (this: WebSocket, ...args: any[]) => void): this;
  1643. addListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
  1644. addListener(event: 'error', listener: (err: Error) => void): this;
  1645. addListener(event: 'upgrade', listener: (request: http.IncomingMessage) => void): this;
  1646. addListener(event: 'message', listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
  1647. addListener(event: 'open', listener: () => void): this;
  1648. addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
  1649. addListener(event: 'unexpected-response', listener: (request: ClientRequest, response: http.IncomingMessage) => void): this;
  1650. addListener(event: string | symbol, listener: (...args: any[]) => void): this;
  1651. removeListener(event: 'close', listener: (code: number, reason: Buffer) => void): this;
  1652. removeListener(event: 'error', listener: (err: Error) => void): this;
  1653. removeListener(event: 'upgrade', listener: (request: http.IncomingMessage) => void): this;
  1654. removeListener(event: 'message', listener: (data: WebSocket.RawData, isBinary: boolean) => void): this;
  1655. removeListener(event: 'open', listener: () => void): this;
  1656. removeListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this;
  1657. removeListener(event: 'unexpected-response', listener: (request: ClientRequest, response: http.IncomingMessage) => void): this;
  1658. removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
  1659. }
  1660. declare const WebSocketAlias: typeof WebSocket;
  1661. interface WebSocketAlias extends WebSocket {}
  1662. declare namespace WebSocket {
  1663. /**
  1664. * Data represents the raw message payload received over the WebSocket.
  1665. */
  1666. type RawData = Buffer | ArrayBuffer | Buffer[];
  1667. /**
  1668. * Data represents the message payload received over the WebSocket.
  1669. */
  1670. type Data = string | Buffer | ArrayBuffer | Buffer[];
  1671. /**
  1672. * CertMeta represents the accepted types for certificate & key data.
  1673. */
  1674. type CertMeta = string | string[] | Buffer | Buffer[];
  1675. /**
  1676. * VerifyClientCallbackSync is a synchronous callback used to inspect the
  1677. * incoming message. The return value (boolean) of the function determines
  1678. * whether or not to accept the handshake.
  1679. */
  1680. type VerifyClientCallbackSync = (info: {
  1681. origin: string;
  1682. secure: boolean;
  1683. req: http.IncomingMessage;
  1684. }) => boolean;
  1685. /**
  1686. * VerifyClientCallbackAsync is an asynchronous callback used to inspect the
  1687. * incoming message. The return value (boolean) of the function determines
  1688. * whether or not to accept the handshake.
  1689. */
  1690. type VerifyClientCallbackAsync = (info: {
  1691. origin: string;
  1692. secure: boolean;
  1693. req: http.IncomingMessage;
  1694. }, callback: (res: boolean, code?: number, message?: string, headers?: OutgoingHttpHeaders) => void) => void;
  1695. interface ClientOptions extends SecureContextOptions {
  1696. protocol?: string | undefined;
  1697. followRedirects?: boolean | undefined;
  1698. generateMask?(mask: Buffer): void;
  1699. handshakeTimeout?: number | undefined;
  1700. maxRedirects?: number | undefined;
  1701. perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
  1702. localAddress?: string | undefined;
  1703. protocolVersion?: number | undefined;
  1704. headers?: {
  1705. [key: string]: string;
  1706. } | undefined;
  1707. origin?: string | undefined;
  1708. agent?: Agent | undefined;
  1709. host?: string | undefined;
  1710. family?: number | undefined;
  1711. checkServerIdentity?(servername: string, cert: CertMeta): boolean;
  1712. rejectUnauthorized?: boolean | undefined;
  1713. maxPayload?: number | undefined;
  1714. skipUTF8Validation?: boolean | undefined;
  1715. }
  1716. interface PerMessageDeflateOptions {
  1717. serverNoContextTakeover?: boolean | undefined;
  1718. clientNoContextTakeover?: boolean | undefined;
  1719. serverMaxWindowBits?: number | undefined;
  1720. clientMaxWindowBits?: number | undefined;
  1721. zlibDeflateOptions?: {
  1722. flush?: number | undefined;
  1723. finishFlush?: number | undefined;
  1724. chunkSize?: number | undefined;
  1725. windowBits?: number | undefined;
  1726. level?: number | undefined;
  1727. memLevel?: number | undefined;
  1728. strategy?: number | undefined;
  1729. dictionary?: Buffer | Buffer[] | DataView | undefined;
  1730. info?: boolean | undefined;
  1731. } | undefined;
  1732. zlibInflateOptions?: ZlibOptions | undefined;
  1733. threshold?: number | undefined;
  1734. concurrencyLimit?: number | undefined;
  1735. }
  1736. interface Event {
  1737. type: string;
  1738. target: WebSocket;
  1739. }
  1740. interface ErrorEvent {
  1741. error: any;
  1742. message: string;
  1743. type: string;
  1744. target: WebSocket;
  1745. }
  1746. interface CloseEvent {
  1747. wasClean: boolean;
  1748. code: number;
  1749. reason: string;
  1750. type: string;
  1751. target: WebSocket;
  1752. }
  1753. interface MessageEvent {
  1754. data: Data;
  1755. type: string;
  1756. target: WebSocket;
  1757. }
  1758. interface EventListenerOptions {
  1759. once?: boolean | undefined;
  1760. }
  1761. interface ServerOptions {
  1762. host?: string | undefined;
  1763. port?: number | undefined;
  1764. backlog?: number | undefined;
  1765. server?: http.Server | HttpsServer | undefined;
  1766. verifyClient?: VerifyClientCallbackAsync | VerifyClientCallbackSync | undefined;
  1767. handleProtocols?: (protocols: Set<string>, request: http.IncomingMessage) => string | false;
  1768. path?: string | undefined;
  1769. noServer?: boolean | undefined;
  1770. clientTracking?: boolean | undefined;
  1771. perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined;
  1772. maxPayload?: number | undefined;
  1773. skipUTF8Validation?: boolean | undefined;
  1774. WebSocket?: typeof WebSocket.WebSocket | undefined;
  1775. }
  1776. interface AddressInfo {
  1777. address: string;
  1778. family: string;
  1779. port: number;
  1780. }
  1781. // WebSocket Server
  1782. class Server<T extends WebSocket = WebSocket> extends EventEmitter {
  1783. options: ServerOptions;
  1784. path: string;
  1785. clients: Set<T>;
  1786. constructor(options?: ServerOptions, callback?: () => void);
  1787. address(): AddressInfo | string;
  1788. close(cb?: (err?: Error) => void): void;
  1789. handleUpgrade(request: http.IncomingMessage, socket: Duplex, upgradeHead: Buffer, callback: (client: T, request: http.IncomingMessage) => void): void;
  1790. shouldHandle(request: http.IncomingMessage): boolean | Promise<boolean>;
  1791. // Events
  1792. on(event: 'connection', cb: (this: Server<T>, socket: T, request: http.IncomingMessage) => void): this;
  1793. on(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
  1794. on(event: 'headers', cb: (this: Server<T>, headers: string[], request: http.IncomingMessage) => void): this;
  1795. on(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
  1796. on(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
  1797. once(event: 'connection', cb: (this: Server<T>, socket: T, request: http.IncomingMessage) => void): this;
  1798. once(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
  1799. once(event: 'headers', cb: (this: Server<T>, headers: string[], request: http.IncomingMessage) => void): this;
  1800. once(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
  1801. once(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
  1802. off(event: 'connection', cb: (this: Server<T>, socket: T, request: http.IncomingMessage) => void): this;
  1803. off(event: 'error', cb: (this: Server<T>, error: Error) => void): this;
  1804. off(event: 'headers', cb: (this: Server<T>, headers: string[], request: http.IncomingMessage) => void): this;
  1805. off(event: 'close' | 'listening', cb: (this: Server<T>) => void): this;
  1806. off(event: string | symbol, listener: (this: Server<T>, ...args: any[]) => void): this;
  1807. addListener(event: 'connection', cb: (client: T, request: http.IncomingMessage) => void): this;
  1808. addListener(event: 'error', cb: (err: Error) => void): this;
  1809. addListener(event: 'headers', cb: (headers: string[], request: http.IncomingMessage) => void): this;
  1810. addListener(event: 'close' | 'listening', cb: () => void): this;
  1811. addListener(event: string | symbol, listener: (...args: any[]) => void): this;
  1812. removeListener(event: 'connection', cb: (client: T) => void): this;
  1813. removeListener(event: 'error', cb: (err: Error) => void): this;
  1814. removeListener(event: 'headers', cb: (headers: string[], request: http.IncomingMessage) => void): this;
  1815. removeListener(event: 'close' | 'listening', cb: () => void): this;
  1816. removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
  1817. }
  1818. const WebSocketServer: typeof Server;
  1819. interface WebSocketServer extends Server {}
  1820. const WebSocket: typeof WebSocketAlias;
  1821. interface WebSocket extends WebSocketAlias {}
  1822. // WebSocket stream
  1823. function createWebSocketStream(websocket: WebSocket, options?: DuplexOptions): Duplex;
  1824. }
  1825. //#endregion
  1826. //#region src/node/server/ws.d.ts
  1827. type WebSocketCustomListener<T> = (data: T, client: WebSocketClient) => void;
  1828. declare const isWebSocketServer: unique symbol;
  1829. interface WebSocketServer extends NormalizedHotChannel {
  1830. /**
  1831. * Handle custom event emitted by `import.meta.hot.send`
  1832. */
  1833. on: WebSocket.Server["on"] & {
  1834. <T extends string>(event: T, listener: WebSocketCustomListener<hmrPayload_InferCustomEventPayload<T>>): void;
  1835. };
  1836. /**
  1837. * Unregister event listener.
  1838. */
  1839. off: WebSocket.Server["off"] & {
  1840. (event: string, listener: Function): void;
  1841. };
  1842. /**
  1843. * Listen on port and host
  1844. */
  1845. listen(): void;
  1846. /**
  1847. * Disconnect all clients and terminate the server.
  1848. */
  1849. close(): Promise<void>;
  1850. [isWebSocketServer]: true;
  1851. /**
  1852. * Get all connected clients.
  1853. */
  1854. clients: Set<WebSocketClient>;
  1855. }
  1856. interface WebSocketClient extends NormalizedHotChannelClient {
  1857. /**
  1858. * The raw WebSocket instance
  1859. * @advanced
  1860. */
  1861. socket: WebSocket;
  1862. }
  1863. //#endregion
  1864. //#region src/node/server/environment.d.ts
  1865. interface DevEnvironmentContext {
  1866. hot: boolean;
  1867. transport?: HotChannel | WebSocketServer;
  1868. options?: EnvironmentOptions;
  1869. remoteRunner?: {
  1870. inlineSourceMap?: boolean;
  1871. };
  1872. depsOptimizer?: DepsOptimizer;
  1873. }
  1874. export declare class DevEnvironment extends BaseEnvironment {
  1875. mode: "dev";
  1876. moduleGraph: EnvironmentModuleGraph;
  1877. depsOptimizer?: DepsOptimizer;
  1878. get pluginContainer(): EnvironmentPluginContainer<DevEnvironment>;
  1879. /**
  1880. * Hot channel for this environment. If not provided or disabled,
  1881. * it will be a noop channel that does nothing.
  1882. *
  1883. * @example
  1884. * environment.hot.send({ type: 'full-reload' })
  1885. */
  1886. hot: NormalizedHotChannel;
  1887. bundledDev?: BundledDev;
  1888. constructor(name: string, config: ResolvedConfig, context: DevEnvironmentContext);
  1889. init(options?: {
  1890. watcher?: FSWatcher;
  1891. /**
  1892. * the previous instance used for the environment with the same name
  1893. *
  1894. * when using, the consumer should check if it's an instance generated from the same class or factory function
  1895. */
  1896. previousInstance?: DevEnvironment;
  1897. }): Promise<void>;
  1898. /**
  1899. * When the dev server is restarted, the methods are called in the following order:
  1900. * - new instance `init`
  1901. * - previous instance `close`
  1902. * - new instance `listen`
  1903. */
  1904. listen(server: ViteDevServer): Promise<void>;
  1905. /**
  1906. * Called by the module runner to retrieve information about the specified
  1907. * module. Internally calls `transformRequest` and wraps the result in the
  1908. * format that the module runner understands.
  1909. * This method is not meant to be called manually.
  1910. */
  1911. fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<moduleRunner_FetchResult>;
  1912. reloadModule(module: EnvironmentModuleNode): Promise<void>;
  1913. transformRequest(url: string): Promise<TransformResult | null>;
  1914. warmupRequest(url: string): Promise<void>;
  1915. protected invalidateModule(m: {
  1916. path: string;
  1917. message?: string;
  1918. firstInvalidatedBy: string;
  1919. }, _client: NormalizedHotChannelClient): void;
  1920. close(): Promise<void>;
  1921. /**
  1922. * Calling `await environment.waitForRequestsIdle(id)` will wait until all static imports
  1923. * are processed after the first transformRequest call. If called from a load or transform
  1924. * plugin hook, the id needs to be passed as a parameter to avoid deadlocks.
  1925. * Calling this function after the first static imports section of the module graph has been
  1926. * processed will resolve immediately.
  1927. * @experimental
  1928. */
  1929. waitForRequestsIdle(ignoredId?: string): Promise<void>;
  1930. }
  1931. //#endregion
  1932. //#region src/node/optimizer/scan.d.ts
  1933. declare class ScanEnvironment extends BaseEnvironment {
  1934. mode: "scan";
  1935. get pluginContainer(): EnvironmentPluginContainer;
  1936. init(): Promise<void>;
  1937. }
  1938. //#endregion
  1939. //#region src/node/environment.d.ts
  1940. type Environment = DevEnvironment | BuildEnvironment | ScanEnvironment | UnknownEnvironment;
  1941. /**
  1942. * Creates a function that hides the complexities of a WeakMap with an initial value
  1943. * to implement object metadata. Used by plugins to implement cross hooks per
  1944. * environment metadata
  1945. *
  1946. * @experimental
  1947. */
  1948. export declare function perEnvironmentState<State>(initial: (environment: Environment) => State): (context: PluginContext) => State;
  1949. //#endregion
  1950. //#region src/node/plugins/html.d.ts
  1951. interface HtmlTagDescriptor {
  1952. tag: string;
  1953. /**
  1954. * attribute values will be escaped automatically if needed
  1955. */
  1956. attrs?: Record<string, string | boolean | undefined>;
  1957. children?: string | HtmlTagDescriptor[];
  1958. /**
  1959. * default: 'head-prepend'
  1960. */
  1961. injectTo?: "head" | "body" | "head-prepend" | "body-prepend";
  1962. }
  1963. type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
  1964. html: string;
  1965. tags: HtmlTagDescriptor[];
  1966. };
  1967. interface IndexHtmlTransformContext {
  1968. /**
  1969. * public path when served
  1970. */
  1971. path: string;
  1972. /**
  1973. * filename on disk
  1974. */
  1975. filename: string;
  1976. server?: ViteDevServer;
  1977. bundle?: OutputBundle;
  1978. chunk?: OutputChunk;
  1979. originalUrl?: string;
  1980. }
  1981. type IndexHtmlTransformHook = (this: MinimalPluginContextWithoutEnvironment, html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
  1982. type IndexHtmlTransform = IndexHtmlTransformHook | {
  1983. order?: "pre" | "post" | null;
  1984. handler: IndexHtmlTransformHook;
  1985. };
  1986. //#endregion
  1987. //#region src/node/plugins/pluginFilter.d.ts
  1988. type StringFilter<Value = string | RegExp> = Value | Array<Value> | {
  1989. include?: Value | Array<Value>;
  1990. exclude?: Value | Array<Value>;
  1991. };
  1992. //#endregion
  1993. //#region src/node/shortcuts.d.ts
  1994. type BindCLIShortcutsOptions<Server = ViteDevServer | PreviewServer> = {
  1995. /**
  1996. * Print a one-line shortcuts "help" hint to the terminal
  1997. */
  1998. print?: boolean;
  1999. /**
  2000. * Custom shortcuts to run when a key is pressed. These shortcuts take priority
  2001. * over the default shortcuts if they have the same keys (except the `h` key).
  2002. * To disable a default shortcut, define the same key but with `action: undefined`.
  2003. */
  2004. customShortcuts?: CLIShortcut<Server>[];
  2005. };
  2006. type CLIShortcut<Server = ViteDevServer | PreviewServer> = {
  2007. key: string;
  2008. description: string;
  2009. action?(server: Server): void | Promise<void>;
  2010. };
  2011. //#endregion
  2012. //#region src/node/typeUtils.d.ts
  2013. type RequiredExceptFor<T, K extends keyof T> = Pick<T, K> & Required<Omit<T, K>>;
  2014. //#endregion
  2015. //#region src/node/preview.d.ts
  2016. interface PreviewOptions extends CommonServerOptions {}
  2017. interface ResolvedPreviewOptions extends RequiredExceptFor<PreviewOptions, "host" | "https" | "proxy"> {}
  2018. interface PreviewServer {
  2019. /**
  2020. * The resolved vite config object
  2021. */
  2022. config: ResolvedConfig;
  2023. /**
  2024. * Stop the server.
  2025. */
  2026. close(): Promise<void>;
  2027. /**
  2028. * A connect app instance.
  2029. * - Can be used to attach custom middlewares to the preview server.
  2030. * - Can also be used as the handler function of a custom http server
  2031. * or as a middleware in any connect-style Node.js frameworks
  2032. *
  2033. * https://github.com/senchalabs/connect#use-middleware
  2034. */
  2035. middlewares: Connect.Server;
  2036. /**
  2037. * native Node http server instance
  2038. */
  2039. httpServer: HttpServer;
  2040. /**
  2041. * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
  2042. * if the server is not listening on any port.
  2043. */
  2044. resolvedUrls: ResolvedServerUrls | null;
  2045. /**
  2046. * Print server urls
  2047. */
  2048. printUrls(): void;
  2049. /**
  2050. * Bind CLI shortcuts
  2051. */
  2052. bindCLIShortcuts(options?: BindCLIShortcutsOptions<PreviewServer>): void;
  2053. }
  2054. type PreviewServerHook = (this: MinimalPluginContextWithoutEnvironment, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
  2055. type ClosePreviewServerHook = (this: MinimalPluginContextWithoutEnvironment) => void | Promise<void>;
  2056. /**
  2057. * Starts the Vite server in preview mode, to simulate a production deployment
  2058. */
  2059. export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewServer>;
  2060. //#endregion
  2061. //#region src/node/plugin.d.ts
  2062. /**
  2063. * Vite plugins extends the Rollup plugin interface with a few extra
  2064. * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
  2065. * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
  2066. * plugin, since some Rollup features do not make sense in an unbundled
  2067. * dev server context. That said, as long as a rollup plugin doesn't have strong
  2068. * coupling between its bundle phase and output phase hooks then it should
  2069. * just work (that means, most of them).
  2070. *
  2071. * By default, the plugins are run during both serve and build. When a plugin
  2072. * is applied during serve, it will only run **non output plugin hooks** (see
  2073. * rollup type definition of {@link rollup#PluginHooks}). You can think of the
  2074. * dev server as only running `const bundle = rollup.rollup()` but never calling
  2075. * `bundle.generate()`.
  2076. *
  2077. * A plugin that expects to have different behavior depending on serve/build can
  2078. * export a factory function that receives the command being run via options.
  2079. *
  2080. * If a plugin should be applied only for server or build, a function format
  2081. * config file can be used to conditional determine the plugins to use.
  2082. *
  2083. * The current environment can be accessed from the context for the all non-global
  2084. * hooks (it is not available in config, configResolved, configureServer, etc).
  2085. * It can be a dev, build, or scan environment.
  2086. * Plugins can use this.environment.mode === 'dev' to guard for dev specific APIs.
  2087. */
  2088. interface PluginContextExtension {
  2089. /**
  2090. * Vite-specific environment instance
  2091. */
  2092. environment: Environment;
  2093. }
  2094. interface PluginContextMetaExtension {
  2095. viteVersion: string;
  2096. }
  2097. interface ConfigPluginContext extends Omit<MinimalPluginContext, "meta" | "environment"> {
  2098. meta: Omit<PluginContextMeta, "watchMode">;
  2099. }
  2100. interface MinimalPluginContextWithoutEnvironment extends Omit<MinimalPluginContext, "environment"> {}
  2101. declare module "rolldown" {
  2102. interface MinimalPluginContext extends PluginContextExtension {}
  2103. interface PluginContextMeta extends PluginContextMetaExtension {}
  2104. }
  2105. /**
  2106. * There are two types of plugins in Vite. App plugins and environment plugins.
  2107. * Environment Plugins are defined by a constructor function that will be called
  2108. * once per each environment allowing users to have completely different plugins
  2109. * for each of them. The constructor gets the resolved environment after the server
  2110. * and builder has already been created simplifying config access and cache
  2111. * management for environment specific plugins.
  2112. * Environment Plugins are closer to regular rollup plugins. They can't define
  2113. * app level hooks (like config, configResolved, configureServer, etc).
  2114. */
  2115. interface Plugin<A = any> extends Rolldown.Plugin<A> {
  2116. /**
  2117. * Perform custom handling of HMR updates.
  2118. * The handler receives an options containing changed filename, timestamp, a
  2119. * list of modules affected by the file change, and the dev server instance.
  2120. *
  2121. * - The hook can return a filtered list of modules to narrow down the update.
  2122. * e.g. for a Vue SFC, we can narrow down the part to update by comparing
  2123. * the descriptors.
  2124. *
  2125. * - The hook can also return an empty array and then perform custom updates
  2126. * by sending a custom hmr payload via environment.hot.send().
  2127. *
  2128. * - If the hook doesn't return a value, the hmr update will be performed as
  2129. * normal.
  2130. */
  2131. hotUpdate?: ObjectHook<(this: MinimalPluginContext & {
  2132. environment: DevEnvironment;
  2133. }, options: HotUpdateOptions) => Array<EnvironmentModuleNode> | void | Promise<Array<EnvironmentModuleNode> | void>>;
  2134. /**
  2135. * extend hooks with ssr flag
  2136. */
  2137. resolveId?: ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: {
  2138. kind?: ImportKind;
  2139. custom?: CustomPluginOptions;
  2140. ssr?: boolean | undefined;
  2141. isEntry: boolean;
  2142. }) => Promise<ResolveIdResult> | ResolveIdResult, {
  2143. filter?: {
  2144. id?: StringFilter<RegExp>;
  2145. };
  2146. }>;
  2147. load?: ObjectHook<(this: PluginContext, id: string, options?: {
  2148. ssr?: boolean | undefined;
  2149. }) => Promise<LoadResult> | LoadResult, {
  2150. filter?: {
  2151. id?: StringFilter;
  2152. };
  2153. }>;
  2154. transform?: ObjectHook<(this: TransformPluginContext, code: string, id: string, options?: {
  2155. moduleType: ModuleType;
  2156. ssr?: boolean | undefined;
  2157. }) => Promise<Rolldown.TransformResult> | Rolldown.TransformResult, {
  2158. filter?: {
  2159. id?: StringFilter;
  2160. code?: StringFilter;
  2161. moduleType?: ModuleTypeFilter;
  2162. };
  2163. }>;
  2164. /**
  2165. * Opt-in this plugin into the shared plugins pipeline.
  2166. * For backward-compatibility, plugins are re-recreated for each environment
  2167. * during `vite build --app`
  2168. * We have an opt-in per plugin, and a general `builder.sharedPlugins`
  2169. * In a future major, we'll flip the default to be shared by default
  2170. * @experimental
  2171. */
  2172. sharedDuringBuild?: boolean;
  2173. /**
  2174. * Opt-in this plugin into per-environment buildStart and buildEnd during dev.
  2175. * For backward-compatibility, the buildStart hook is called only once during
  2176. * dev, for the client environment. Plugins can opt-in to be called
  2177. * per-environment, aligning with the build hook behavior.
  2178. * @experimental
  2179. */
  2180. perEnvironmentStartEndDuringDev?: boolean;
  2181. /**
  2182. * Opt-in this plugin into per-environment watchChange during dev.
  2183. * For backward-compatibility, the watchChange hook is called only once during
  2184. * dev, for the client environment. Plugins can opt-in to be called
  2185. * per-environment, aligning with the watchChange hook behavior.
  2186. * @experimental
  2187. */
  2188. perEnvironmentWatchChangeDuringDev?: boolean;
  2189. /**
  2190. * Enforce plugin invocation tier similar to webpack loaders. Hooks ordering
  2191. * is still subject to the `order` property in the hook object.
  2192. *
  2193. * Plugin invocation order:
  2194. * - alias resolution
  2195. * - `enforce: 'pre'` plugins
  2196. * - vite core plugins
  2197. * - normal plugins
  2198. * - vite build plugins
  2199. * - `enforce: 'post'` plugins
  2200. * - vite build post plugins
  2201. */
  2202. enforce?: "pre" | "post";
  2203. /**
  2204. * Apply the plugin only for serve or build, or on certain conditions.
  2205. */
  2206. apply?: "serve" | "build" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean);
  2207. /**
  2208. * Define environments where this plugin should be active
  2209. * By default, the plugin is active in all environments
  2210. * @experimental
  2211. */
  2212. applyToEnvironment?: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption;
  2213. /**
  2214. * Modify vite config before it's resolved. The hook can either mutate the
  2215. * passed-in config directly, or return a partial config object that will be
  2216. * deeply merged into existing config.
  2217. *
  2218. * Note: User plugins are resolved before running this hook so injecting other
  2219. * plugins inside the `config` hook will have no effect.
  2220. */
  2221. config?: ObjectHook<(this: ConfigPluginContext, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, "plugins"> | null | void | Promise<Omit<UserConfig, "plugins"> | null | void>>;
  2222. /**
  2223. * Modify environment configs before it's resolved. The hook can either mutate the
  2224. * passed-in environment config directly, or return a partial config object that will be
  2225. * deeply merged into existing config.
  2226. * This hook is called for each environment with a partially resolved environment config
  2227. * that already accounts for the default environment config values set at the root level.
  2228. * If plugins need to modify the config of a given environment, they should do it in this
  2229. * hook instead of the config hook. Leaving the config hook only for modifying the root
  2230. * default environment config.
  2231. */
  2232. configEnvironment?: ObjectHook<(this: ConfigPluginContext, name: string, config: EnvironmentOptions, env: ConfigEnv & {
  2233. /**
  2234. * Whether this environment is SSR environment and `ssr.target` is set to `'webworker'`.
  2235. * Only intended to be used for backward compatibility.
  2236. */
  2237. isSsrTargetWebworker?: boolean;
  2238. }) => EnvironmentOptions | null | void | Promise<EnvironmentOptions | null | void>>;
  2239. /**
  2240. * Use this hook to read and store the final resolved vite config.
  2241. */
  2242. configResolved?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, config: ResolvedConfig) => void | Promise<void>>;
  2243. /**
  2244. * Configure the vite server. The hook receives the {@link ViteDevServer}
  2245. * instance. This can also be used to store a reference to the server
  2246. * for use in other hooks.
  2247. *
  2248. * The hooks will be called before internal middlewares are applied. A hook
  2249. * can return a post hook that will be called after internal middlewares
  2250. * are applied. Hook can be async functions and will be called in series.
  2251. */
  2252. configureServer?: ObjectHook<ServerHook>;
  2253. /**
  2254. * Configure the preview server. The hook receives the {@link PreviewServer}
  2255. * instance. This can also be used to store a reference to the server
  2256. * for use in other hooks.
  2257. *
  2258. * The hooks are called before other middlewares are applied. A hook can
  2259. * return a post hook that will be called after other middlewares are
  2260. * applied. Hooks can be async functions and will be called in series.
  2261. */
  2262. configurePreviewServer?: ObjectHook<PreviewServerHook>;
  2263. /**
  2264. * Run logic when the server is restarted or closed. The hook receives a
  2265. * `reason` that is `'restart'` when the server is restarting and `'close'`
  2266. * when it is closing.
  2267. *
  2268. * The hooks are called after the server is torn down. Hooks can be async
  2269. * functions and will be called in parallel.
  2270. */
  2271. closeServer?: ObjectHook<CloseServerHook>;
  2272. /**
  2273. * Same as `closeServer` but for the preview server. The preview server never
  2274. * restarts, so no `reason` is provided.
  2275. */
  2276. closePreviewServer?: ObjectHook<ClosePreviewServerHook>;
  2277. /**
  2278. * Transform index.html.
  2279. * The hook receives the following arguments:
  2280. *
  2281. * - html: string
  2282. * - ctx: IndexHtmlTransformContext, which contains:
  2283. * - path: public path when served
  2284. * - filename: filename on disk
  2285. * - server?: ViteDevServer (only present during serve)
  2286. * - bundle?: rollup.OutputBundle (only present during build)
  2287. * - chunk?: rollup.OutputChunk
  2288. * - originalUrl?: string
  2289. *
  2290. * It can either return a transformed string, or a list of html tag
  2291. * descriptors that will be injected into the `<head>` or `<body>`.
  2292. *
  2293. * By default the transform is applied **after** vite's internal html
  2294. * transform. If you need to apply the transform before vite, use an object:
  2295. * `{ order: 'pre', handler: hook }`
  2296. */
  2297. transformIndexHtml?: IndexHtmlTransform;
  2298. /**
  2299. * Build Environments
  2300. *
  2301. * @experimental
  2302. */
  2303. buildApp?: ObjectHook<BuildAppHook>;
  2304. /**
  2305. * Perform custom handling of HMR updates.
  2306. * The handler receives a context containing changed filename, timestamp, a
  2307. * list of modules affected by the file change, and the dev server instance.
  2308. *
  2309. * - The hook can return a filtered list of modules to narrow down the update.
  2310. * e.g. for a Vue SFC, we can narrow down the part to update by comparing
  2311. * the descriptors.
  2312. *
  2313. * - The hook can also return an empty array and then perform custom updates
  2314. * by sending a custom hmr payload via server.ws.send().
  2315. *
  2316. * - If the hook doesn't return a value, the hmr update will be performed as
  2317. * normal.
  2318. */
  2319. handleHotUpdate?: ObjectHook<(this: MinimalPluginContextWithoutEnvironment, ctx: HmrContext) => Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>>;
  2320. /**
  2321. * This hook is not supported by Rolldown yet. But the type is declared for compatibility.
  2322. *
  2323. * @deprecated This hook is **not** deprecated. It is marked as deprecated just to make it clear that this hook is currently a no-op.
  2324. */
  2325. shouldTransformCachedModule?: ObjectHook<(this: PluginContext, options: {
  2326. code: string;
  2327. id: string;
  2328. meta: CustomPluginOptions;
  2329. moduleSideEffects: boolean | "no-treeshake";
  2330. }) => boolean | null | void>;
  2331. }
  2332. type HookHandler<T> = T extends ObjectHook<infer H> ? H : T;
  2333. type PluginWithRequiredHook<K extends keyof Plugin> = Plugin & { [P in K]: NonNullable<Plugin[P]>; };
  2334. type Thenable<T> = T | Promise<T>;
  2335. type FalsyPlugin = false | null | undefined;
  2336. type PluginOption = Thenable<Plugin | {
  2337. name: string;
  2338. } | FalsyPlugin | PluginOption[]>;
  2339. /**
  2340. * @experimental
  2341. */
  2342. export declare function perEnvironmentPlugin(name: string, applyToEnvironment: (environment: PartialEnvironment) => boolean | Promise<boolean> | PluginOption): Plugin;
  2343. //#endregion
  2344. //#region src/node/watch.d.ts
  2345. /**
  2346. * Watch options for the dev server. Accepts both chokidar options and Rolldown
  2347. * watch options. The chokidar options are used by the chokidar watcher, while
  2348. * the Rolldown options are used by the Rolldown file watcher when bundled dev
  2349. * mode is enabled.
  2350. */
  2351. type ServerWatchOptions = WatchOptions & Omit<DevWatchOptions, "enabled" | "skipWrite">;
  2352. //#endregion
  2353. //#region src/node/server/index.d.ts
  2354. interface ServerOptions$1 extends CommonServerOptions {
  2355. /**
  2356. * Configure HMR-specific options (port, host, path & protocol)
  2357. */
  2358. hmr?: HmrOptions | boolean;
  2359. /**
  2360. * Configure WebSocket connection options.
  2361. * Set to `false` to disable the WebSocket server and connection.
  2362. */
  2363. ws?: WsOptions | false;
  2364. /**
  2365. * Warm-up files to transform and cache the results in advance. This improves the
  2366. * initial page load during server starts and prevents transform waterfalls.
  2367. */
  2368. warmup?: {
  2369. /**
  2370. * The files to be transformed and used on the client-side. Supports glob patterns.
  2371. */
  2372. clientFiles?: string[];
  2373. /**
  2374. * The files to be transformed and used in SSR. Supports glob patterns.
  2375. */
  2376. ssrFiles?: string[];
  2377. };
  2378. /**
  2379. * File system watcher options, or null to disable FS watching.
  2380. *
  2381. * Accepts chokidar options
  2382. * (https://github.com/paulmillr/chokidar/tree/3.6.0#api), which are used by
  2383. * the chokidar watcher, and Rolldown watch options, which are used by the
  2384. * Rolldown file watcher when bundled dev mode is enabled.
  2385. */
  2386. watch?: ServerWatchOptions | null;
  2387. /**
  2388. * Create Vite dev server to be used as a middleware in an existing server
  2389. * @default false
  2390. */
  2391. middlewareMode?: boolean | {
  2392. /**
  2393. * Parent server instance to attach to
  2394. *
  2395. * This is needed to proxy WebSocket connections to the parent server.
  2396. */
  2397. server: HttpServer;
  2398. };
  2399. /**
  2400. * Options for files served via '/\@fs/'.
  2401. */
  2402. fs?: FileSystemServeOptions;
  2403. /**
  2404. * Origin for the generated asset URLs.
  2405. *
  2406. * @example `http://127.0.0.1:8080`
  2407. */
  2408. origin?: string;
  2409. /**
  2410. * Pre-transform known direct imports
  2411. * @default true
  2412. */
  2413. preTransformRequests?: boolean;
  2414. /**
  2415. * Whether or not to ignore-list source files in the dev server sourcemap, used to populate
  2416. * the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
  2417. *
  2418. * By default, it excludes all paths containing `node_modules`. You can pass `false` to
  2419. * disable this behavior, or, for full control, a function that takes the source path and
  2420. * sourcemap path and returns whether to ignore the source path.
  2421. */
  2422. sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
  2423. /**
  2424. * Backward compatibility. The buildStart and buildEnd hooks were called only once for
  2425. * the client environment. This option enables per-environment buildStart and buildEnd hooks.
  2426. * @default false
  2427. * @experimental
  2428. */
  2429. perEnvironmentStartEndDuringDev?: boolean;
  2430. /**
  2431. * Backward compatibility. The watchChange hook was called only once for the client environment.
  2432. * This option enables per-environment watchChange hooks.
  2433. * @default false
  2434. * @experimental
  2435. */
  2436. perEnvironmentWatchChangeDuringDev?: boolean;
  2437. /**
  2438. * Run HMR tasks, by default the HMR propagation is done in parallel for all environments
  2439. * @experimental
  2440. */
  2441. hotUpdateEnvironments?: (server: ViteDevServer, hmr: (environment: DevEnvironment) => Promise<void>) => Promise<void>;
  2442. forwardConsole?: boolean | ForwardConsoleOptions;
  2443. }
  2444. interface ResolvedServerOptions extends Omit<RequiredExceptFor<ServerOptions$1, "host" | "https" | "proxy" | "hmr" | "ws" | "watch" | "origin" | "hotUpdateEnvironments">, "fs" | "middlewareMode" | "sourcemapIgnoreList" | "forwardConsole"> {
  2445. fs: Required<FileSystemServeOptions>;
  2446. middlewareMode: NonNullable<ServerOptions$1["middlewareMode"]>;
  2447. sourcemapIgnoreList: Exclude<ServerOptions$1["sourcemapIgnoreList"], false | undefined>;
  2448. forwardConsole: ResolvedForwardConsoleOptions;
  2449. }
  2450. interface FileSystemServeOptions {
  2451. /**
  2452. * Strictly restrict file accessing outside of allowing paths.
  2453. *
  2454. * Set to `false` to disable the warning
  2455. *
  2456. * @default true
  2457. */
  2458. strict?: boolean;
  2459. /**
  2460. * Restrict accessing files outside the allowed directories.
  2461. *
  2462. * Accepts absolute path or a path relative to project root.
  2463. * Will try to search up for workspace root by default.
  2464. */
  2465. allow?: string[];
  2466. /**
  2467. * Restrict accessing files that matches the patterns.
  2468. *
  2469. * This will have higher priority than `allow`.
  2470. * picomatch patterns are supported.
  2471. *
  2472. * @default ['.env', '.env.*', '*.{crt,pem,key,p12,pfx,cer,der}', '.npmrc', '.yarnrc.yml', '**\/.git/**']
  2473. */
  2474. deny?: string[];
  2475. }
  2476. type ServerHook = (this: MinimalPluginContextWithoutEnvironment, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
  2477. interface CloseServerHookContext {
  2478. /**
  2479. * Whether the server is being restarted (e.g. a config change or
  2480. * `server.restart()`) or closed (e.g. the `q` shortcut, SIGTERM, stdin
  2481. * ending, or `server.close()`).
  2482. */
  2483. reason: "restart" | "close";
  2484. }
  2485. type CloseServerHook = (this: MinimalPluginContextWithoutEnvironment, context: CloseServerHookContext) => void | Promise<void>;
  2486. type HttpServer = http.Server | Http2SecureServer;
  2487. interface ViteDevServer {
  2488. /**
  2489. * The resolved vite config object
  2490. */
  2491. config: ResolvedConfig;
  2492. /**
  2493. * A connect app instance.
  2494. * - Can be used to attach custom middlewares to the dev server.
  2495. * - Can also be used as the handler function of a custom http server
  2496. * or as a middleware in any connect-style Node.js frameworks
  2497. *
  2498. * https://github.com/senchalabs/connect#use-middleware
  2499. */
  2500. middlewares: Connect.Server;
  2501. /**
  2502. * native Node http server instance
  2503. * will be null in middleware mode
  2504. */
  2505. httpServer: HttpServer | null;
  2506. /**
  2507. * Chokidar watcher instance. If `config.server.watch` is set to `null`,
  2508. * it will not watch any files and calling `add` or `unwatch` will have no effect.
  2509. * https://github.com/paulmillr/chokidar/tree/3.6.0#api
  2510. */
  2511. watcher: FSWatcher;
  2512. /**
  2513. * WebSocket server with `send(payload)` method
  2514. */
  2515. ws: WebSocketServer;
  2516. /**
  2517. * An alias to `server.environments.client.hot`.
  2518. * If you want to interact with all environments, loop over `server.environments`.
  2519. */
  2520. hot: NormalizedHotChannel;
  2521. /**
  2522. * Rollup plugin container that can run plugin hooks on a given file
  2523. */
  2524. pluginContainer: PluginContainer;
  2525. /**
  2526. * Module execution environments attached to the Vite server.
  2527. */
  2528. environments: Record<"client" | "ssr" | (string & {}), DevEnvironment>;
  2529. /**
  2530. * Module graph that tracks the import relationships, url to file mapping
  2531. * and hmr state.
  2532. */
  2533. moduleGraph: ModuleGraph;
  2534. /**
  2535. * The resolved urls Vite prints on the CLI (URL-encoded). Returns `null`
  2536. * in middleware mode or if the server is not listening on any port.
  2537. */
  2538. resolvedUrls: ResolvedServerUrls | null;
  2539. /**
  2540. * Programmatically resolve, load and transform a URL and get the result
  2541. * without going through the http request pipeline.
  2542. */
  2543. transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
  2544. /**
  2545. * Same as `transformRequest` but only warm up the URLs so the next request
  2546. * will already be cached. The function will never throw as it handles and
  2547. * reports errors internally.
  2548. */
  2549. warmupRequest(url: string, options?: TransformOptions): Promise<void>;
  2550. /**
  2551. * Apply vite built-in HTML transforms and any plugin HTML transforms.
  2552. */
  2553. transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
  2554. /**
  2555. * Transform module code into SSR format.
  2556. */
  2557. ssrTransform(code: string, inMap: SourceMap | {
  2558. mappings: "";
  2559. } | null, url: string, originalCode?: string): Promise<TransformResult | null>;
  2560. /**
  2561. * Load a given URL as an instantiated module for SSR.
  2562. */
  2563. ssrLoadModule(url: string, opts?: {
  2564. fixStacktrace?: boolean;
  2565. }): Promise<Record<string, any>>;
  2566. /**
  2567. * Returns a fixed version of the given stack
  2568. */
  2569. ssrRewriteStacktrace(stack: string): string;
  2570. /**
  2571. * Mutates the given SSR error by rewriting the stacktrace
  2572. */
  2573. ssrFixStacktrace(e: Error): void;
  2574. /**
  2575. * Triggers HMR for a module in the module graph. You can use the `server.moduleGraph`
  2576. * API to retrieve the module to be reloaded. If `hmr` is false, this is a no-op.
  2577. */
  2578. reloadModule(module: ModuleNode): Promise<void>;
  2579. /**
  2580. * Start the server.
  2581. */
  2582. listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
  2583. /**
  2584. * Stop the server.
  2585. */
  2586. close(): Promise<void>;
  2587. /**
  2588. * Print server urls
  2589. */
  2590. printUrls(): void;
  2591. /**
  2592. * Bind CLI shortcuts
  2593. */
  2594. bindCLIShortcuts(options?: BindCLIShortcutsOptions<ViteDevServer>): void;
  2595. /**
  2596. * Restart the server.
  2597. *
  2598. * @param forceOptimize - force the optimizer to re-bundle, same as --force cli flag
  2599. */
  2600. restart(forceOptimize?: boolean): Promise<void>;
  2601. /**
  2602. * Open browser
  2603. */
  2604. openBrowser(): void;
  2605. /**
  2606. * Calling `await server.waitForRequestsIdle(id)` will wait until all static imports
  2607. * are processed. If called from a load or transform plugin hook, the id needs to be
  2608. * passed as a parameter to avoid deadlocks. Calling this function after the first
  2609. * static imports section of the module graph has been processed will resolve immediately.
  2610. */
  2611. waitForRequestsIdle: (ignoredId?: string) => Promise<void>;
  2612. }
  2613. interface ResolvedServerUrls {
  2614. local: string[];
  2615. network: string[];
  2616. /**
  2617. * Names of the network interface that each {@link ResolvedServerUrls.network}
  2618. * URL is bound to, in the same order as `network`. An entry is `undefined`
  2619. * when the interface name is not known, for example when an explicit `host`
  2620. * is set.
  2621. */
  2622. networkInterfaceNames?: (string | undefined)[];
  2623. }
  2624. export declare function createServer(inlineConfig?: InlineConfig | ResolvedConfig): Promise<ViteDevServer>;
  2625. //#endregion
  2626. //#region src/node/logger.d.ts
  2627. type LogType = "error" | "warn" | "info";
  2628. type LogLevel = LogType | "silent";
  2629. interface Logger {
  2630. info(msg: string, options?: LogOptions): void;
  2631. warn(msg: string, options?: LogOptions): void;
  2632. warnOnce(msg: string, options?: LogOptions): void;
  2633. error(msg: string, options?: LogErrorOptions): void;
  2634. clearScreen(type: LogType): void;
  2635. hasErrorLogged(error: Error | RollupError): boolean;
  2636. hasWarned: boolean;
  2637. }
  2638. interface LogOptions {
  2639. clear?: boolean;
  2640. timestamp?: boolean;
  2641. environment?: string;
  2642. }
  2643. interface LogErrorOptions extends LogOptions {
  2644. error?: Error | RollupError | null;
  2645. }
  2646. interface LoggerOptions {
  2647. prefix?: string;
  2648. allowClearScreen?: boolean;
  2649. customLogger?: Logger;
  2650. console?: Console;
  2651. }
  2652. export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
  2653. //#endregion
  2654. //#region src/node/baseEnvironment.d.ts
  2655. declare class PartialEnvironment {
  2656. name: string;
  2657. getTopLevelConfig(): ResolvedConfig;
  2658. config: ResolvedConfig & ResolvedEnvironmentOptions;
  2659. logger: Logger;
  2660. constructor(name: string, topLevelConfig: ResolvedConfig, options?: ResolvedEnvironmentOptions);
  2661. }
  2662. declare class BaseEnvironment extends PartialEnvironment {
  2663. get plugins(): readonly Plugin[];
  2664. constructor(name: string, config: ResolvedConfig, options?: ResolvedEnvironmentOptions);
  2665. }
  2666. /**
  2667. * This class discourages users from inversely checking the `mode`
  2668. * to determine the type of environment, e.g.
  2669. *
  2670. * ```js
  2671. * const isDev = environment.mode !== 'build' // bad
  2672. * const isDev = environment.mode === 'dev' // good
  2673. * ```
  2674. *
  2675. * You should also not check against `"unknown"` specifically. It's
  2676. * a placeholder for more possible environment types.
  2677. */
  2678. declare class UnknownEnvironment extends BaseEnvironment {
  2679. mode: "unknown";
  2680. }
  2681. //#endregion
  2682. //#region src/node/plugins/resolve.d.ts
  2683. interface EnvironmentResolveOptions {
  2684. /**
  2685. * @default ['browser', 'module', 'jsnext:main', 'jsnext']
  2686. */
  2687. mainFields?: string[];
  2688. conditions?: string[];
  2689. externalConditions?: string[];
  2690. /**
  2691. * @default ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
  2692. */
  2693. extensions?: string[];
  2694. dedupe?: string[];
  2695. /**
  2696. * Prevent listed dependencies from being externalized and will get bundled in build.
  2697. * Only works in server environments for now. Previously this was `ssr.noExternal`.
  2698. * @experimental
  2699. */
  2700. noExternal?: string | RegExp | (string | RegExp)[] | true;
  2701. /**
  2702. * Externalize the given dependencies and their transitive dependencies.
  2703. * Only works in server environments for now. Previously this was `ssr.external`.
  2704. * @experimental
  2705. */
  2706. external?: string[] | true;
  2707. /**
  2708. * Array of strings or regular expressions that indicate what modules are builtin for the environment.
  2709. */
  2710. builtins?: (string | RegExp)[];
  2711. }
  2712. interface ResolveOptions extends EnvironmentResolveOptions {
  2713. /**
  2714. * @default false
  2715. */
  2716. preserveSymlinks?: boolean;
  2717. /**
  2718. * Enable tsconfig paths resolution
  2719. *
  2720. * @default false
  2721. */
  2722. tsconfigPaths?: boolean;
  2723. }
  2724. interface ResolvePluginOptions {
  2725. root: string;
  2726. isBuild: boolean;
  2727. isProduction: boolean;
  2728. packageCache?: PackageCache;
  2729. /**
  2730. * src code mode also attempts the following:
  2731. * - resolving /xxx as URLs
  2732. * - resolving bare imports from optimized deps
  2733. */
  2734. asSrc?: boolean;
  2735. tryIndex?: boolean;
  2736. tryPrefix?: string;
  2737. preferRelative?: boolean;
  2738. isRequire?: boolean;
  2739. scan?: boolean;
  2740. /**
  2741. * Enable when `legacy.inconsistentCjsInterop` is true. See that option for more details.
  2742. */
  2743. legacyInconsistentCjsInterop?: boolean;
  2744. }
  2745. interface InternalResolveOptions extends Required<ResolveOptions>, ResolvePluginOptions {}
  2746. //#endregion
  2747. //#region src/node/packages.d.ts
  2748. /** Cache for package.json resolution and package.json contents */
  2749. type PackageCache = Map<string, PackageData>;
  2750. interface PackageData {
  2751. dir: string;
  2752. hasSideEffects: (id: string) => boolean | "no-treeshake" | null;
  2753. setResolvedCache: (key: string, entry: string, options: InternalResolveOptions) => void;
  2754. getResolvedCache: (key: string, options: InternalResolveOptions) => string | undefined;
  2755. data: {
  2756. [field: string]: any;
  2757. name: string;
  2758. type: string;
  2759. version: string;
  2760. main: string;
  2761. module: string;
  2762. browser: string | Record<string, string | false>;
  2763. exports: string | Record<string, any> | string[];
  2764. imports: Record<string, any>;
  2765. dependencies: Record<string, string>;
  2766. };
  2767. }
  2768. //#endregion
  2769. //#region src/node/plugins/license.d.ts
  2770. interface LicenseOptions {
  2771. /**
  2772. * The output file name of the license file relative to the output directory.
  2773. * Specify a path that ends with `.json` to output the raw JSON metadata.
  2774. *
  2775. * @default '.vite/license.md'
  2776. */
  2777. fileName: string;
  2778. }
  2779. //#endregion
  2780. //#region src/node/plugins/terser.d.ts
  2781. interface TerserOptions extends TerserMinifyOptions {
  2782. /**
  2783. * Vite-specific option to specify the max number of workers to spawn
  2784. * when minifying files with terser.
  2785. *
  2786. * @default number of CPUs minus 1
  2787. */
  2788. maxWorkers?: number;
  2789. }
  2790. //#endregion
  2791. //#region src/node/build.d.ts
  2792. interface BuildEnvironmentOptions {
  2793. /**
  2794. * Compatibility transform target. The transform is performed with esbuild
  2795. * and the lowest supported target is es2015. Note this only handles
  2796. * syntax transformation and does not cover polyfills
  2797. *
  2798. * Default: 'baseline-widely-available' - transpile targeting browsers that
  2799. * are included in the Baseline Widely Available on 2026-01-01.
  2800. * (Chrome 111+, Edge 111+, Firefox 114+, Safari 16.4+).
  2801. *
  2802. * Another special value is 'esnext' - which only performs minimal transpiling
  2803. * (for minification compat).
  2804. *
  2805. * For custom targets, see https://esbuild.github.io/api/#target and
  2806. * https://esbuild.github.io/content-types/#javascript for more details.
  2807. * @default 'baseline-widely-available'
  2808. */
  2809. target?: "baseline-widely-available" | EsbuildTarget | false;
  2810. /**
  2811. * whether to inject module preload polyfill.
  2812. * Note: does not apply to library mode.
  2813. * @default true
  2814. * @deprecated use `modulePreload.polyfill` instead
  2815. */
  2816. polyfillModulePreload?: boolean;
  2817. /**
  2818. * Configure module preload
  2819. * Note: does not apply to library mode.
  2820. * @default true
  2821. */
  2822. modulePreload?: boolean | ModulePreloadOptions;
  2823. /**
  2824. * Directory relative from `root` where build output will be placed. If the
  2825. * directory exists, it will be removed before the build.
  2826. * @default 'dist'
  2827. */
  2828. outDir?: string;
  2829. /**
  2830. * Directory relative from `outDir` where the built js/css/image assets will
  2831. * be placed.
  2832. * @default 'assets'
  2833. */
  2834. assetsDir?: string;
  2835. /**
  2836. * Static asset files smaller than this number (in bytes) will be inlined as
  2837. * base64 strings. If a callback is passed, a boolean can be returned to opt-in
  2838. * or opt-out of inlining. If nothing is returned the default logic applies.
  2839. *
  2840. * Default limit is `4096` (4 KiB). Set to `0` to disable.
  2841. * @default 4096
  2842. */
  2843. assetsInlineLimit?: number | ((filePath: string, content: Buffer) => boolean | undefined);
  2844. /**
  2845. * Whether to code-split CSS. When enabled, CSS in async chunks will be
  2846. * inlined as strings in the chunk and inserted via dynamically created
  2847. * style tags when the chunk is loaded.
  2848. * @default true
  2849. */
  2850. cssCodeSplit?: boolean;
  2851. /**
  2852. * An optional separate target for CSS minification.
  2853. * As esbuild only supports configuring targets to mainstream
  2854. * browsers, users may need this option when they are targeting
  2855. * a niche browser that comes with most modern JavaScript features
  2856. * but has poor CSS support, e.g. Android WeChat WebView, which
  2857. * doesn't support the #RGBA syntax.
  2858. * When `build.cssMinify` is `lightningcss` (the default), this
  2859. * option takes precedence over `css.lightningcss.targets` for the
  2860. * minification step.
  2861. * @default target
  2862. */
  2863. cssTarget?: EsbuildTarget | false;
  2864. /**
  2865. * Override CSS minification specifically instead of defaulting to `build.minify`,
  2866. * so you can configure minification for JS and CSS separately.
  2867. * @default 'lightningcss', but false if build.minify is disabled for client build
  2868. */
  2869. cssMinify?: boolean | "lightningcss" | "esbuild";
  2870. /**
  2871. * If `true`, a separate sourcemap file will be created. If 'inline', the
  2872. * sourcemap will be appended to the resulting output file as data URI.
  2873. * 'hidden' works like `true` except that the corresponding sourcemap
  2874. * comments in the bundled files are suppressed.
  2875. * @default false
  2876. */
  2877. sourcemap?: boolean | "inline" | "hidden";
  2878. /**
  2879. * Set to `false` to disable minification, or specify the minifier to use.
  2880. * Available options are 'oxc' or 'terser' or 'esbuild'.
  2881. * @default 'oxc' for client build, false for SSR build
  2882. */
  2883. minify?: boolean | "oxc" | "terser" | "esbuild";
  2884. /**
  2885. * Options for terser
  2886. * https://terser.org/docs/api-reference#minify-options
  2887. *
  2888. * In addition, you can also pass a `maxWorkers: number` option to specify the
  2889. * max number of workers to spawn. Defaults to the number of CPUs minus 1.
  2890. */
  2891. terserOptions?: TerserOptions;
  2892. /**
  2893. * Whether to use import maps feature to optimize chunk caching efficiency.
  2894. * @default false
  2895. * @experimental
  2896. */
  2897. chunkImportMap?: boolean;
  2898. /**
  2899. * Alias to `rolldownOptions`
  2900. * @deprecated Use `rolldownOptions` instead.
  2901. */
  2902. rollupOptions?: RolldownOptions;
  2903. /**
  2904. * Will be merged with internal rolldown options.
  2905. * https://rolldown.rs/reference/Interface.RolldownOptions
  2906. */
  2907. rolldownOptions?: RolldownOptions;
  2908. /**
  2909. * Options to pass on to `@rollup/plugin-commonjs`
  2910. * @deprecated This option is no-op and will be removed in future versions.
  2911. */
  2912. commonjsOptions?: RollupCommonJSOptions;
  2913. /**
  2914. * Options to pass on to `@rollup/plugin-dynamic-import-vars`
  2915. */
  2916. dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
  2917. /**
  2918. * Whether to write bundle to disk
  2919. * @default true
  2920. */
  2921. write?: boolean;
  2922. /**
  2923. * Empty outDir on write.
  2924. * @default true when outDir is a sub directory of project root
  2925. */
  2926. emptyOutDir?: boolean | null;
  2927. /**
  2928. * Copy the public directory to outDir on write.
  2929. * @default true
  2930. */
  2931. copyPublicDir?: boolean;
  2932. /**
  2933. * Whether to emit a `.vite/license.md` file that includes all bundled dependencies'
  2934. * licenses. Pass an object to customize the output file name.
  2935. * @default false
  2936. */
  2937. license?: boolean | LicenseOptions;
  2938. /**
  2939. * Whether to emit a .vite/manifest.json in the output dir to map hash-less filenames
  2940. * to their hashed versions. Useful when you want to generate your own HTML
  2941. * instead of using the one generated by Vite.
  2942. *
  2943. * Example:
  2944. *
  2945. * ```json
  2946. * {
  2947. * "main.js": {
  2948. * "file": "main.68fe3fad.js",
  2949. * "css": "main.e6b63442.css",
  2950. * "imports": [...],
  2951. * "dynamicImports": [...]
  2952. * }
  2953. * }
  2954. * ```
  2955. * @default false
  2956. */
  2957. manifest?: boolean | string;
  2958. /**
  2959. * Build in library mode. The value should be the global name of the lib in
  2960. * UMD mode. This will produce esm + cjs + umd bundle formats with default
  2961. * configurations that are suitable for distributing libraries.
  2962. * @default false
  2963. */
  2964. lib?: LibraryOptions | false;
  2965. /**
  2966. * Produce SSR oriented build. Note this requires specifying SSR entry via
  2967. * `rolldownOptions.input`.
  2968. * @default false
  2969. */
  2970. ssr?: boolean | string;
  2971. /**
  2972. * Generate SSR manifest for determining style links and asset preload
  2973. * directives in production.
  2974. * @default false
  2975. */
  2976. ssrManifest?: boolean | string;
  2977. /**
  2978. * Emit assets during SSR.
  2979. * @default false
  2980. */
  2981. ssrEmitAssets?: boolean;
  2982. /**
  2983. * Emit assets during build. Frameworks can set environments.ssr.build.emitAssets
  2984. * By default, it is true for the client and false for other environments.
  2985. */
  2986. emitAssets?: boolean;
  2987. /**
  2988. * Set to false to disable reporting compressed chunk sizes.
  2989. * Can slightly improve build speed.
  2990. * @default true
  2991. */
  2992. reportCompressedSize?: boolean;
  2993. /**
  2994. * Adjust chunk size warning limit (in kB).
  2995. * @default 500
  2996. */
  2997. chunkSizeWarningLimit?: number;
  2998. /**
  2999. * Rollup watch options
  3000. * https://rollupjs.org/configuration-options/#watch
  3001. * @default null
  3002. */
  3003. watch?: WatcherOptions | null;
  3004. /**
  3005. * create the Build Environment instance
  3006. */
  3007. createEnvironment?: (name: string, config: ResolvedConfig) => Promise<BuildEnvironment> | BuildEnvironment;
  3008. }
  3009. type BuildOptions = BuildEnvironmentOptions;
  3010. interface LibraryOptions {
  3011. /**
  3012. * Path of library entry.
  3013. * Defaults to the top-level `input` option when omitted.
  3014. */
  3015. entry?: InputOption;
  3016. /**
  3017. * The name of the exposed global variable. Required when the `formats` option includes
  3018. * `umd` or `iife`
  3019. */
  3020. name?: string;
  3021. /**
  3022. * Output bundle formats. Defaults to `['es', 'umd']` for a single entry, or
  3023. * `['es', 'cjs']` for multiple entries (`umd` and `iife` do not support
  3024. * multiple entries).
  3025. * @default ['es', 'umd']
  3026. */
  3027. formats?: LibraryFormats[];
  3028. /**
  3029. * The name of the package file output. The default file name is the name option
  3030. * of the project package.json. It can also be defined as a function taking the
  3031. * format as an argument.
  3032. */
  3033. fileName?: string | ((format: ModuleFormat, entryName: string) => string);
  3034. /**
  3035. * The name of the CSS file output if the library imports CSS. Defaults to the
  3036. * same value as `build.lib.fileName` if it's set a string, otherwise it falls
  3037. * back to the name option of the project package.json.
  3038. */
  3039. cssFileName?: string;
  3040. }
  3041. type LibraryFormats = "es" | "cjs" | "umd" | "iife";
  3042. interface ModulePreloadOptions {
  3043. /**
  3044. * Whether to inject a module preload polyfill.
  3045. * Note: does not apply to library mode.
  3046. * @default true
  3047. */
  3048. polyfill?: boolean;
  3049. /**
  3050. * Resolve the list of dependencies to preload for a given dynamic import
  3051. * @experimental
  3052. */
  3053. resolveDependencies?: ResolveModulePreloadDependenciesFn;
  3054. }
  3055. interface ResolvedModulePreloadOptions {
  3056. polyfill: boolean;
  3057. resolveDependencies?: ResolveModulePreloadDependenciesFn;
  3058. }
  3059. type ResolveModulePreloadDependenciesFn = (filename: string, deps: string[], context: {
  3060. hostId: string;
  3061. hostType: "html" | "js";
  3062. }) => string[];
  3063. interface ResolvedBuildEnvironmentOptions extends Required<Omit<BuildEnvironmentOptions, "polyfillModulePreload">> {
  3064. modulePreload: false | ResolvedModulePreloadOptions;
  3065. }
  3066. interface ResolvedBuildOptions extends Required<Omit<BuildOptions, "polyfillModulePreload">> {
  3067. modulePreload: false | ResolvedModulePreloadOptions;
  3068. }
  3069. /**
  3070. * Bundles a single environment for production.
  3071. * Returns a Promise containing the build result.
  3072. */
  3073. export declare function build(inlineConfig?: InlineConfig): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
  3074. type RenderBuiltAssetUrl = (filename: string, type: {
  3075. type: "asset" | "public";
  3076. hostId: string;
  3077. hostType: "js" | "css" | "html";
  3078. ssr: boolean;
  3079. }) => string | {
  3080. relative?: boolean;
  3081. runtime?: string;
  3082. } | undefined;
  3083. export declare class BuildEnvironment extends BaseEnvironment {
  3084. mode: "build";
  3085. isBuilt: boolean;
  3086. constructor(name: string, config: ResolvedConfig, setup?: {
  3087. options?: EnvironmentOptions;
  3088. });
  3089. init(): Promise<void>;
  3090. }
  3091. interface ViteBuilder {
  3092. environments: Record<string, BuildEnvironment>;
  3093. config: ResolvedConfig;
  3094. buildApp(): Promise<void>;
  3095. build(environment: BuildEnvironment): Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
  3096. runDevTools(): Promise<void>;
  3097. }
  3098. interface BuilderOptions {
  3099. /**
  3100. * Whether to share the config instance among environments to align with the behavior of dev server.
  3101. *
  3102. * @default false
  3103. * @experimental
  3104. */
  3105. sharedConfigBuild?: boolean;
  3106. /**
  3107. * Whether to share the plugin instances among environments to align with the behavior of dev server.
  3108. *
  3109. * @default false
  3110. * @experimental
  3111. */
  3112. sharedPlugins?: boolean;
  3113. buildApp?: (builder: ViteBuilder) => Promise<void>;
  3114. }
  3115. type ResolvedBuilderOptions = Required<BuilderOptions>;
  3116. /**
  3117. * Creates a ViteBuilder to orchestrate building multiple environments.
  3118. * @experimental
  3119. */
  3120. export declare function createBuilder(inlineConfig?: InlineConfig, useLegacyBuilder?: null | boolean): Promise<ViteBuilder>;
  3121. type BuildAppHook = (this: MinimalPluginContextWithoutEnvironment, builder: ViteBuilder) => Promise<void>;
  3122. //#endregion
  3123. //#region src/node/idResolver.d.ts
  3124. type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: string, aliasOnly?: boolean) => Promise<string | undefined>;
  3125. /**
  3126. * Create an internal resolver to be used in special scenarios, e.g.
  3127. * optimizer and handling css @imports
  3128. */
  3129. export declare function createIdResolver(config: ResolvedConfig, options?: Partial<InternalResolveOptions>): ResolveIdFn;
  3130. //#endregion
  3131. //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.28_tsx@4.23.15_yaml@2.9.0/node_modules/postcss-load-config/src/index.d.ts
  3132. type ConfigPlugin = Transformer | PostCSS.Plugin | Processor;
  3133. interface Config {
  3134. parser?: string | ProcessOptions['parser'] | false;
  3135. stringifier?: string | ProcessOptions['stringifier'] | false;
  3136. syntax?: string | ProcessOptions['syntax'] | false;
  3137. map?: string | false;
  3138. from?: string;
  3139. to?: string;
  3140. plugins?: Array<ConfigPlugin | false> | Record<string, object | false>;
  3141. }
  3142. //#endregion
  3143. //#region src/node/plugins/css.d.ts
  3144. interface CSSOptions {
  3145. /**
  3146. * Using lightningcss is an experimental option to handle CSS modules,
  3147. * assets and imports via Lightning CSS. It requires to install it as a
  3148. * peer dependency.
  3149. *
  3150. * @default 'postcss'
  3151. * @experimental
  3152. */
  3153. transformer?: "postcss" | "lightningcss";
  3154. /**
  3155. * https://github.com/css-modules/postcss-modules
  3156. */
  3157. modules?: CSSModulesOptions | false;
  3158. /**
  3159. * Options for preprocessors.
  3160. *
  3161. * In addition to options specific to each processors, Vite supports `additionalData` option.
  3162. * The `additionalData` option can be used to inject extra code for each style content.
  3163. */
  3164. preprocessorOptions?: {
  3165. scss?: SassPreprocessorOptions;
  3166. sass?: SassPreprocessorOptions;
  3167. less?: LessPreprocessorOptions;
  3168. styl?: StylusPreprocessorOptions;
  3169. stylus?: StylusPreprocessorOptions;
  3170. };
  3171. /**
  3172. * If this option is set, preprocessors will run in workers when possible.
  3173. * `true` means the number of CPUs minus 1.
  3174. *
  3175. * @default true
  3176. */
  3177. preprocessorMaxWorkers?: number | true;
  3178. postcss?: string | (PostCSS.ProcessOptions & {
  3179. plugins?: PostCSS.AcceptedPlugin[];
  3180. });
  3181. /**
  3182. * Enables css sourcemaps during dev
  3183. * @default false
  3184. * @experimental
  3185. */
  3186. devSourcemap?: boolean;
  3187. /**
  3188. * @experimental
  3189. */
  3190. lightningcss?: lightningcssOptions_LightningCSSOptions;
  3191. }
  3192. interface CSSModulesOptions {
  3193. getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
  3194. scopeBehaviour?: "global" | "local";
  3195. globalModulePaths?: RegExp[];
  3196. exportGlobals?: boolean;
  3197. generateScopedName?: string | ((name: string, filename: string, css: string) => string);
  3198. hashPrefix?: string;
  3199. /**
  3200. * default: undefined
  3201. */
  3202. localsConvention?: "camelCase" | "camelCaseOnly" | "dashes" | "dashesOnly" | ((originalClassName: string, generatedClassName: string, inputFile: string) => string);
  3203. }
  3204. type ResolvedCSSOptions = Omit<CSSOptions, "lightningcss"> & Required<Pick<CSSOptions, "transformer" | "devSourcemap">> & {
  3205. lightningcss?: lightningcssOptions_LightningCSSOptions;
  3206. };
  3207. interface PreprocessCSSResult {
  3208. code: string;
  3209. map?: SourceMapInput;
  3210. modules?: Record<string, string>;
  3211. deps?: Set<string>;
  3212. }
  3213. /**
  3214. * @experimental
  3215. */
  3216. export declare function preprocessCSS(code: string, filename: string, config: ResolvedConfig): Promise<PreprocessCSSResult>;
  3217. export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
  3218. type PreprocessorAdditionalDataResult = string | {
  3219. content: string;
  3220. map?: ExistingRawSourceMap;
  3221. };
  3222. type PreprocessorAdditionalData = string | ((source: string, filename: string) => PreprocessorAdditionalDataResult | Promise<PreprocessorAdditionalDataResult>);
  3223. type SassPreprocessorOptions = {
  3224. additionalData?: PreprocessorAdditionalData;
  3225. } & SassModernPreprocessBaseOptions;
  3226. type LessPreprocessorOptions = {
  3227. additionalData?: PreprocessorAdditionalData;
  3228. } & LessPreprocessorBaseOptions;
  3229. type StylusPreprocessorOptions = {
  3230. additionalData?: PreprocessorAdditionalData;
  3231. } & StylusPreprocessorBaseOptions;
  3232. //#endregion
  3233. //#region src/node/plugins/esbuild.d.ts
  3234. interface ESBuildOptions extends esbuildOptions_EsbuildTransformOptions {
  3235. include?: string | RegExp | ReadonlyArray<string | RegExp>;
  3236. exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
  3237. jsxInject?: string;
  3238. /**
  3239. * This option is not respected. Use `build.minify` instead.
  3240. */
  3241. minify?: never;
  3242. }
  3243. type ESBuildTransformResult = Omit<EsbuildTransformResult, "map"> & {
  3244. map: SourceMap;
  3245. };
  3246. export declare function transformWithEsbuild(code: string, filename: string, options?: esbuildOptions_EsbuildTransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher, ignoreEsbuildWarning?: boolean): Promise<ESBuildTransformResult>;
  3247. //#endregion
  3248. //#region src/node/plugins/json.d.ts
  3249. interface JsonOptions {
  3250. /**
  3251. * Generate a named export for every property of the JSON object
  3252. * @default true
  3253. */
  3254. namedExports?: boolean;
  3255. /**
  3256. * Generate performant output as JSON.parse("stringified").
  3257. *
  3258. * When set to 'auto', the data will be stringified only if the data is bigger than 10kB.
  3259. * @default 'auto'
  3260. */
  3261. stringify?: boolean | "auto";
  3262. }
  3263. //#endregion
  3264. //#region src/node/plugins/oxc.d.ts
  3265. interface OxcOptions extends Omit<rolldown_utils_TransformOptions, "cwd" | "sourceType" | "lang" | "sourcemap" | "helpers" | "inject" | "tsconfig" | "inputMap"> {
  3266. include?: string | RegExp | ReadonlyArray<string | RegExp>;
  3267. exclude?: string | RegExp | ReadonlyArray<string | RegExp>;
  3268. jsxInject?: string;
  3269. jsxRefreshInclude?: string | RegExp | ReadonlyArray<string | RegExp>;
  3270. jsxRefreshExclude?: string | RegExp | ReadonlyArray<string | RegExp>;
  3271. }
  3272. export declare function transformWithOxc(code: string, filename: string, options?: rolldown_utils_TransformOptions, inMap?: object, config?: ResolvedConfig, watcher?: FSWatcher): Promise<Omit<rolldown_utils_TransformResult, "errors">>;
  3273. //#endregion
  3274. //#region src/node/ssr/index.d.ts
  3275. type SSRTarget = "node" | "webworker";
  3276. type SsrDepOptimizationConfig = DepOptimizationConfig;
  3277. interface SSROptions {
  3278. noExternal?: string | RegExp | (string | RegExp)[] | true;
  3279. external?: string[] | true;
  3280. /**
  3281. * Define the target for the ssr build. The browser field in package.json
  3282. * is ignored for node but used if webworker is the target
  3283. * This option will be removed in a future major version
  3284. * @default 'node'
  3285. */
  3286. target?: SSRTarget;
  3287. /**
  3288. * Control over which dependencies are optimized during SSR and esbuild options
  3289. * During build:
  3290. * no external CJS dependencies are optimized by default
  3291. * During dev:
  3292. * explicit no external CJS dependencies are optimized by default
  3293. * @experimental
  3294. */
  3295. optimizeDeps?: SsrDepOptimizationConfig;
  3296. resolve?: {
  3297. /**
  3298. * Conditions that are used in the plugin pipeline. The default value is the root config's `resolve.conditions`.
  3299. *
  3300. * Use this to override the default ssr conditions for the ssr build.
  3301. *
  3302. * @default rootConfig.resolve.conditions
  3303. */
  3304. conditions?: string[];
  3305. /**
  3306. * Conditions that are used during ssr import (including `ssrLoadModule`) of externalized dependencies.
  3307. *
  3308. * @default ['node', 'module-sync']
  3309. */
  3310. externalConditions?: string[];
  3311. mainFields?: string[];
  3312. };
  3313. }
  3314. interface ResolvedSSROptions extends SSROptions {
  3315. target: SSRTarget;
  3316. optimizeDeps: SsrDepOptimizationConfig;
  3317. }
  3318. //#endregion
  3319. //#region src/node/config.d.ts
  3320. interface ConfigEnv {
  3321. /**
  3322. * 'serve': during dev (`vite` command)
  3323. * 'build': when building for production (`vite build` command)
  3324. */
  3325. command: "build" | "serve";
  3326. mode: string;
  3327. isSsrBuild?: boolean;
  3328. isPreview?: boolean;
  3329. }
  3330. /**
  3331. * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
  3332. *
  3333. * mpa: only include non-SPA HTML middlewares
  3334. *
  3335. * custom: don't include HTML middlewares
  3336. */
  3337. type AppType = "spa" | "mpa" | "custom";
  3338. type UserConfigFnObject = (env: ConfigEnv) => UserConfig;
  3339. type UserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
  3340. type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
  3341. type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFnObject | UserConfigFnPromise | UserConfigFn;
  3342. /**
  3343. * Type helper to make it easier to use vite.config.ts
  3344. * accepts a direct {@link UserConfig} object, or a function that returns it.
  3345. * The function receives a {@link ConfigEnv} object.
  3346. */
  3347. export declare function defineConfig(config: UserConfig): UserConfig;
  3348. export declare function defineConfig(config: Promise<UserConfig>): Promise<UserConfig>;
  3349. export declare function defineConfig(config: UserConfigFnObject): UserConfigFnObject;
  3350. export declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
  3351. export declare function defineConfig(config: UserConfigFn): UserConfigFn;
  3352. export declare function defineConfig(config: UserConfigExport): UserConfigExport;
  3353. interface CreateDevEnvironmentContext {
  3354. ws: WebSocketServer;
  3355. }
  3356. interface DevEnvironmentOptions {
  3357. /**
  3358. * Files to be pre-transformed. Supports glob patterns.
  3359. */
  3360. warmup?: string[];
  3361. /**
  3362. * Pre-transform known direct imports
  3363. * defaults to true for the client environment, false for the rest
  3364. */
  3365. preTransformRequests?: boolean;
  3366. /**
  3367. * Enables sourcemaps during dev
  3368. * @default { js: true }
  3369. * @experimental
  3370. */
  3371. sourcemap?: boolean | {
  3372. js?: boolean;
  3373. css?: boolean;
  3374. };
  3375. /**
  3376. * Whether or not to ignore-list source files in the dev server sourcemap, used to populate
  3377. * the [`x_google_ignoreList` source map extension](https://developer.chrome.com/blog/devtools-better-angular-debugging/#the-x_google_ignorelist-source-map-extension).
  3378. *
  3379. * By default, it excludes all paths containing `node_modules`. You can pass `false` to
  3380. * disable this behavior, or, for full control, a function that takes the source path and
  3381. * sourcemap path and returns whether to ignore the source path.
  3382. */
  3383. sourcemapIgnoreList?: false | ((sourcePath: string, sourcemapPath: string) => boolean);
  3384. /**
  3385. * create the Dev Environment instance
  3386. */
  3387. createEnvironment?: (name: string, config: ResolvedConfig, context: CreateDevEnvironmentContext) => Promise<DevEnvironment> | DevEnvironment;
  3388. /**
  3389. * For environments that support a full-reload, like the client, we can short-circuit when
  3390. * restarting the server throwing early to stop processing current files. We avoided this for
  3391. * SSR requests. Maybe this is no longer needed.
  3392. * @experimental
  3393. */
  3394. recoverable?: boolean;
  3395. /**
  3396. * For environments associated with a module runner.
  3397. * By default, it is false for the client environment and true for non-client environments.
  3398. * This option can also be used instead of the removed config.experimental.skipSsrTransform.
  3399. */
  3400. moduleRunnerTransform?: boolean;
  3401. }
  3402. type ResolvedDevEnvironmentOptions = Omit<Required<DevEnvironmentOptions>, "sourcemapIgnoreList"> & {
  3403. sourcemapIgnoreList: Exclude<DevEnvironmentOptions["sourcemapIgnoreList"], false | undefined>;
  3404. };
  3405. type AllResolveOptions = ResolveOptions & {
  3406. alias?: AliasOptions;
  3407. };
  3408. interface SharedEnvironmentOptions {
  3409. /**
  3410. * Entry points of the application.
  3411. *
  3412. * Paths are resolved relative to the project root.
  3413. */
  3414. input?: InputOption;
  3415. /**
  3416. * Define global variable replacements.
  3417. * Entries will be defined on `window` during dev and replaced during build.
  3418. */
  3419. define?: Record<string, any>;
  3420. /**
  3421. * Configure resolver
  3422. */
  3423. resolve?: EnvironmentResolveOptions;
  3424. /**
  3425. * Define if this environment is used for Server-Side Rendering
  3426. * @default 'server' if it isn't the client environment
  3427. */
  3428. consumer?: "client" | "server";
  3429. /**
  3430. * If true, `process.env` referenced in code will be preserved as-is and evaluated in runtime.
  3431. * Otherwise, it is statically replaced as an empty object.
  3432. */
  3433. keepProcessEnv?: boolean;
  3434. /**
  3435. * Optimize deps config
  3436. */
  3437. optimizeDeps?: DepOptimizationOptions;
  3438. /**
  3439. * Whether this environment produces a bundled output.
  3440. *
  3441. * During `build`, this defaults to `true` for every environment.
  3442. * During `serve`, this defaults to `true` only for the client environment
  3443. * when `experimental.bundledDev` is enabled, and `false` otherwise.
  3444. * Setting this explicitly on an environment always overrides the default.
  3445. *
  3446. * @experimental
  3447. */
  3448. isBundled?: boolean;
  3449. }
  3450. interface EnvironmentOptions extends SharedEnvironmentOptions {
  3451. /**
  3452. * Dev specific options
  3453. */
  3454. dev?: DevEnvironmentOptions;
  3455. /**
  3456. * Build specific options
  3457. */
  3458. build?: BuildEnvironmentOptions;
  3459. }
  3460. type ResolvedResolveOptions = Required<ResolveOptions>;
  3461. type ResolvedEnvironmentOptions = {
  3462. input?: InputOption;
  3463. define?: Record<string, any>;
  3464. resolve: ResolvedResolveOptions;
  3465. consumer: "client" | "server";
  3466. keepProcessEnv?: boolean;
  3467. optimizeDeps: DepOptimizationOptions;
  3468. dev: ResolvedDevEnvironmentOptions;
  3469. build: ResolvedBuildEnvironmentOptions;
  3470. isBundled: boolean;
  3471. plugins: readonly Plugin[];
  3472. };
  3473. type DefaultEnvironmentOptions = Omit<EnvironmentOptions, "consumer" | "resolve" | "keepProcessEnv"> & {
  3474. resolve?: AllResolveOptions;
  3475. };
  3476. interface UserConfig extends DefaultEnvironmentOptions {
  3477. /**
  3478. * Project root directory. Can be an absolute path, or a path relative from
  3479. * the location of the config file itself.
  3480. * @default process.cwd()
  3481. */
  3482. root?: string;
  3483. /**
  3484. * Path to the TypeScript configuration file. Relative paths are resolved
  3485. * from the project root.
  3486. */
  3487. tsconfig?: string;
  3488. /**
  3489. * Base public path when served in development or production.
  3490. * @default '/'
  3491. */
  3492. base?: string;
  3493. /**
  3494. * Directory to serve as plain static assets. Files in this directory are
  3495. * served and copied to build dist dir as-is without transform. The value
  3496. * can be either an absolute file system path or a path relative to project root.
  3497. *
  3498. * Set to `false` or an empty string to disable copied static assets to build dist dir.
  3499. * @default 'public'
  3500. */
  3501. publicDir?: string | false;
  3502. /**
  3503. * Directory to save cache files. Files in this directory are pre-bundled
  3504. * deps or some other cache files that generated by vite, which can improve
  3505. * the performance. You can use `--force` flag or manually delete the directory
  3506. * to regenerate the cache files. The value can be either an absolute file
  3507. * system path or a path relative to project root.
  3508. * Default to `.vite` when neither a `package.json` nor a `node_modules` directory is detected.
  3509. * @default 'node_modules/.vite'
  3510. */
  3511. cacheDir?: string;
  3512. /**
  3513. * Explicitly set a mode to run in. This will override the default mode for
  3514. * each command, and can be overridden by the command line --mode option.
  3515. */
  3516. mode?: string;
  3517. /**
  3518. * Array of vite plugins to use.
  3519. */
  3520. plugins?: PluginOption[];
  3521. /**
  3522. * HTML related options
  3523. */
  3524. html?: HTMLOptions;
  3525. /**
  3526. * CSS related options (preprocessors and CSS modules)
  3527. */
  3528. css?: CSSOptions;
  3529. /**
  3530. * JSON loading options
  3531. */
  3532. json?: JsonOptions;
  3533. /**
  3534. * Transform options to pass to esbuild.
  3535. * Or set to `false` to disable esbuild.
  3536. *
  3537. * @deprecated Use `oxc` option instead.
  3538. */
  3539. esbuild?: ESBuildOptions | false;
  3540. /**
  3541. * Transform options to pass to Oxc.
  3542. * Or set to `false` to disable Oxc.
  3543. */
  3544. oxc?: OxcOptions | false;
  3545. /**
  3546. * Specify additional picomatch patterns to be treated as static assets.
  3547. */
  3548. assetsInclude?: string | RegExp | (string | RegExp)[];
  3549. /**
  3550. * Builder specific options
  3551. * @experimental
  3552. */
  3553. builder?: BuilderOptions;
  3554. /**
  3555. * Server specific options, e.g. host, port, https...
  3556. */
  3557. server?: ServerOptions$1;
  3558. /**
  3559. * Preview specific options, e.g. host, port, https...
  3560. */
  3561. preview?: PreviewOptions;
  3562. /**
  3563. * Experimental features
  3564. *
  3565. * Features under this field could change in the future and might NOT follow semver.
  3566. * Please be careful and always pin Vite's version when using them.
  3567. * @experimental
  3568. */
  3569. experimental?: ExperimentalOptions;
  3570. /**
  3571. * Options to opt-in to future behavior
  3572. */
  3573. future?: FutureOptions | "warn";
  3574. /**
  3575. * Legacy options
  3576. *
  3577. * Features under this field only follow semver for patches, they could be removed in a
  3578. * future minor version. Please always pin Vite's version to a minor when using them.
  3579. */
  3580. legacy?: LegacyOptions;
  3581. /**
  3582. * Log level.
  3583. * @default 'info'
  3584. */
  3585. logLevel?: LogLevel;
  3586. /**
  3587. * Custom logger.
  3588. */
  3589. customLogger?: Logger;
  3590. /**
  3591. * @default true
  3592. */
  3593. clearScreen?: boolean;
  3594. /**
  3595. * Environment files directory. Can be an absolute path, or a path relative from
  3596. * root.
  3597. * @default root
  3598. */
  3599. envDir?: string | false;
  3600. /**
  3601. * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
  3602. * @default 'VITE_'
  3603. */
  3604. envPrefix?: string | string[];
  3605. /**
  3606. * Worker bundle options
  3607. */
  3608. worker?: {
  3609. /**
  3610. * Output format for worker bundle
  3611. * @default 'iife'
  3612. */
  3613. format?: "es" | "iife";
  3614. /**
  3615. * Vite plugins that apply to worker bundle. The plugins returned by this function
  3616. * should be new instances every time it is called, because they are used for each
  3617. * rolldown worker bundling process.
  3618. */
  3619. plugins?: () => PluginOption[];
  3620. /**
  3621. * Alias to `rolldownOptions`.
  3622. * @deprecated Use `rolldownOptions` instead.
  3623. */
  3624. rollupOptions?: Omit<RolldownOptions, "plugins" | "input" | "onwarn" | "preserveEntrySignatures">;
  3625. /**
  3626. * Rolldown options to build worker bundle
  3627. */
  3628. rolldownOptions?: Omit<RolldownOptions, "plugins" | "input" | "onwarn" | "preserveEntrySignatures">;
  3629. };
  3630. /**
  3631. * Dep optimization options
  3632. */
  3633. optimizeDeps?: DepOptimizationOptions;
  3634. /**
  3635. * SSR specific options
  3636. * We could make SSROptions be a EnvironmentOptions if we can abstract
  3637. * external/noExternal for environments in general.
  3638. */
  3639. ssr?: SSROptions;
  3640. /**
  3641. * Environment overrides
  3642. */
  3643. environments?: Record<string, EnvironmentOptions>;
  3644. /**
  3645. * Whether your application is a Single Page Application (SPA),
  3646. * a Multi-Page Application (MPA), or Custom Application (SSR
  3647. * and frameworks with custom HTML handling)
  3648. * @default 'spa'
  3649. */
  3650. appType?: AppType;
  3651. /**
  3652. * Enable devtools integration. Ensure that `@vitejs/devtools` is installed as a dependency.
  3653. * @experimental
  3654. * @default false
  3655. */
  3656. devtools?: boolean | DevToolsConfig;
  3657. }
  3658. interface HTMLOptions {
  3659. /**
  3660. * A nonce value placeholder that will be used when generating script/style tags.
  3661. *
  3662. * Make sure that this placeholder will be replaced with a unique value for each request by the server.
  3663. */
  3664. cspNonce?: string;
  3665. /**
  3666. * Define additional HTML elements and attributes to be treated as asset sources.
  3667. * This extends the built-in list that includes standard elements like `<img src>`, `<video src>`, etc.
  3668. *
  3669. * @example
  3670. * ```ts
  3671. * html: {
  3672. * additionalAssetSources: {
  3673. * // Custom web component
  3674. * 'html-import': { srcAttributes: ['src'] },
  3675. * // Add data-* attributes to existing element
  3676. * 'img': { srcAttributes: ['data-src-dark', 'data-src-light'] }
  3677. * }
  3678. * }
  3679. * ```
  3680. */
  3681. additionalAssetSources?: Record<string, HtmlAssetSource>;
  3682. }
  3683. interface FutureOptions {
  3684. removePluginHookHandleHotUpdate?: "warn";
  3685. removePluginHookSsrArgument?: "warn";
  3686. removeServerModuleGraph?: "warn";
  3687. removeServerReloadModule?: "warn";
  3688. removeServerPluginContainer?: "warn";
  3689. removeServerHot?: "warn";
  3690. removeServerTransformRequest?: "warn";
  3691. removeServerWarmupRequest?: "warn";
  3692. removeSsrLoadModule?: "warn";
  3693. }
  3694. interface ExperimentalOptions {
  3695. /**
  3696. * Append fake `&lang.(ext)` when queries are specified, to preserve the file extension for following plugins to process.
  3697. *
  3698. * @experimental
  3699. * @default false
  3700. */
  3701. importGlobRestoreExtension?: boolean;
  3702. /**
  3703. * Allow finegrain control over assets and public files paths
  3704. *
  3705. * @experimental
  3706. */
  3707. renderBuiltUrl?: RenderBuiltAssetUrl;
  3708. /**
  3709. * Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
  3710. *
  3711. * @experimental
  3712. * @default false
  3713. */
  3714. hmrPartialAccept?: boolean;
  3715. /**
  3716. * Enable full bundle mode during `serve`.
  3717. *
  3718. * This seeds the default for the client environment's `isBundled` option.
  3719. * Other environments default to `false` during `serve`. Any environment
  3720. * can override its `isBundled` value via `environments[name].isBundled`.
  3721. *
  3722. * This is highly experimental.
  3723. *
  3724. * HMR semantics under full bundle mode differ from the middleware-based dev server
  3725. * in two ways (boundaries are computed in the browser from runtime state, not
  3726. * statically on the server):
  3727. *
  3728. * - Acceptance counts only when it executed: an `import.meta.hot.accept()` that
  3729. * is in a dead branch does not suppress the update and falls back to a full reload.
  3730. * - `hot.invalidate()` is handled fully client-side.
  3731. *
  3732. * @experimental
  3733. * @default false
  3734. */
  3735. bundledDev?: boolean;
  3736. }
  3737. interface LegacyOptions {
  3738. /**
  3739. * In Vite 6.0.8 and below, WebSocket server was able to connect from any web pages. However,
  3740. * that could be exploited by a malicious web page.
  3741. *
  3742. * In Vite 6.0.9+, the WebSocket server now requires a token to connect from a web page.
  3743. * But this may break some plugins and frameworks that connects to the WebSocket server
  3744. * on their own. Enabling this option will make Vite skip the token check.
  3745. *
  3746. * **We do not recommend enabling this option unless you are sure that you are fine with
  3747. * that security weakness.**
  3748. */
  3749. skipWebSocketTokenCheck?: boolean;
  3750. /**
  3751. * Opt-in to the pre-Vite 8 CJS interop behavior, which was inconsistent.
  3752. *
  3753. * In pre-Vite 8 versions, Vite had inconsistent CJS interop behavior. This was due to
  3754. * the different behavior of esbuild and the Rollup commonjs plugin.
  3755. * Vite 8+ uses Rolldown for both the dependency optimization in dev and the production build,
  3756. * which aligns the behavior to esbuild.
  3757. *
  3758. * See the Vite 8 migration guide for more details.
  3759. */
  3760. inconsistentCjsInterop?: boolean;
  3761. }
  3762. interface ResolvedWorkerOptions {
  3763. format: "es" | "iife";
  3764. plugins: (bundleChain: string[]) => Promise<ResolvedConfig>;
  3765. /**
  3766. * @deprecated Use `rolldownOptions` instead.
  3767. */
  3768. rollupOptions: RolldownOptions;
  3769. rolldownOptions: RolldownOptions;
  3770. }
  3771. interface InlineConfig extends UserConfig {
  3772. configFile?: string | false;
  3773. /** @experimental */
  3774. configLoader?: "bundle" | "runner" | "native";
  3775. /** @deprecated */
  3776. envFile?: false;
  3777. forceOptimizeDeps?: boolean;
  3778. }
  3779. interface ResolvedConfig extends Readonly<Omit<UserConfig, "plugins" | "css" | "json" | "assetsInclude" | "optimizeDeps" | "worker" | "build" | "dev" | "environments" | "experimental" | "future" | "server" | "preview" | "devtools"> & {
  3780. configFile: string | undefined;
  3781. configFileDependencies: string[];
  3782. inlineConfig: InlineConfig;
  3783. root: string;
  3784. base: string;
  3785. publicDir: string;
  3786. cacheDir: string;
  3787. command: "build" | "serve";
  3788. mode: string;
  3789. isWorker: boolean;
  3790. isProduction: boolean;
  3791. envDir: string | false;
  3792. env: Record<string, any>;
  3793. resolve: Required<ResolveOptions> & {
  3794. alias: Alias[];
  3795. };
  3796. plugins: readonly Plugin[];
  3797. css: ResolvedCSSOptions;
  3798. json: Required<JsonOptions>;
  3799. /** @deprecated Use `oxc` option instead. */
  3800. esbuild: ESBuildOptions | false;
  3801. oxc: OxcOptions | false;
  3802. server: ResolvedServerOptions;
  3803. dev: ResolvedDevEnvironmentOptions;
  3804. /** @experimental */
  3805. builder: ResolvedBuilderOptions | undefined;
  3806. build: ResolvedBuildOptions;
  3807. devtools: ResolvedDevToolsConfig | false;
  3808. preview: ResolvedPreviewOptions;
  3809. ssr: ResolvedSSROptions;
  3810. assetsInclude: (file: string) => boolean;
  3811. rawAssetsInclude: (string | RegExp)[];
  3812. logger: Logger;
  3813. /**
  3814. * Create an internal resolver to be used in special scenarios, e.g.
  3815. * optimizer & handling css `@imports`.
  3816. *
  3817. * This API is deprecated. It only works for the client and ssr
  3818. * environments. The `aliasOnly` option is also not being used anymore.
  3819. * Plugins should move to `createIdResolver(environment.config)` instead.
  3820. *
  3821. * @deprecated Use `createIdResolver` from `vite` instead.
  3822. */
  3823. createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
  3824. optimizeDeps: DepOptimizationOptions;
  3825. worker: ResolvedWorkerOptions;
  3826. appType: AppType;
  3827. experimental: RequiredExceptFor<ExperimentalOptions, "renderBuiltUrl">;
  3828. future: FutureOptions | undefined;
  3829. environments: Record<string, ResolvedEnvironmentOptions>;
  3830. /**
  3831. * The token to connect to the WebSocket server from browsers.
  3832. *
  3833. * We recommend using `import.meta.hot` rather than connecting
  3834. * to the WebSocket server directly.
  3835. * If you have a usecase that requires connecting to the WebSocket
  3836. * server, please create an issue so that we can discuss.
  3837. *
  3838. * @deprecated
  3839. */
  3840. webSocketToken: string;
  3841. } & PluginHookUtils> {}
  3842. interface PluginHookUtils {
  3843. getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
  3844. getSortedPluginHooks: <K extends keyof Plugin>(hookName: K) => NonNullable<HookHandler<Plugin[K]>>[];
  3845. }
  3846. type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
  3847. export declare function resolveConfig(inlineConfig: InlineConfig, command: "build" | "serve", defaultMode?: string, defaultNodeEnv?: string, isPreview?: boolean, patchConfig?: ((config: ResolvedConfig) => void) | undefined, patchPlugins?: ((resolvedPlugins: Plugin[]) => void) | undefined): Promise<ResolvedConfig>;
  3848. export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
  3849. export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel, customLogger?: Logger, configLoader?: "bundle" | "runner" | "native"): Promise<{
  3850. path: string;
  3851. config: UserConfig;
  3852. dependencies: string[];
  3853. } | null>;
  3854. //#endregion
  3855. //#region src/node/server/middlewares/error.d.ts
  3856. export declare function buildErrorMessage(err: RollupError, args?: string[], includeStack?: boolean): string;
  3857. //#endregion
  3858. //#region src/node/ssr/runtime/serverModuleRunner.d.ts
  3859. /**
  3860. * @experimental
  3861. */
  3862. interface ServerModuleRunnerOptions extends Omit<ModuleRunnerOptions, "root" | "fetchModule" | "hmr" | "transport"> {
  3863. /**
  3864. * Disable HMR or configure HMR logger.
  3865. */
  3866. hmr?: false | {
  3867. logger?: ModuleRunnerHmr["logger"];
  3868. };
  3869. /**
  3870. * Provide a custom module evaluator. This controls how the code is executed.
  3871. */
  3872. evaluator?: ModuleEvaluator;
  3873. }
  3874. export declare const createServerModuleRunnerTransport: (options: {
  3875. channel: NormalizedServerHotChannel;
  3876. }) => ModuleRunnerTransport;
  3877. /**
  3878. * Create an instance of the Vite SSR runtime that support HMR.
  3879. * @experimental
  3880. */
  3881. export declare function createServerModuleRunner(environment: DevEnvironment, options?: ServerModuleRunnerOptions): ModuleRunner;
  3882. //#endregion
  3883. //#region src/node/server/environments/runnableEnvironment.d.ts
  3884. export declare function createRunnableDevEnvironment(name: string, config: ResolvedConfig, context?: RunnableDevEnvironmentContext): RunnableDevEnvironment;
  3885. interface RunnableDevEnvironmentContext extends Omit<DevEnvironmentContext, "hot"> {
  3886. runner?: (environment: RunnableDevEnvironment, options?: ServerModuleRunnerOptions) => ModuleRunner;
  3887. runnerOptions?: ServerModuleRunnerOptions;
  3888. hot?: boolean;
  3889. }
  3890. export declare function isRunnableDevEnvironment(environment: Environment): environment is RunnableDevEnvironment;
  3891. declare class RunnableDevEnvironment extends DevEnvironment {
  3892. private _runner;
  3893. private _runnerFactory;
  3894. private _runnerOptions;
  3895. constructor(name: string, config: ResolvedConfig, context: RunnableDevEnvironmentContext);
  3896. get runner(): ModuleRunner;
  3897. override close(): Promise<void>;
  3898. }
  3899. //#endregion
  3900. //#region src/node/server/environments/fetchableEnvironments.d.ts
  3901. interface FetchableDevEnvironmentContext extends DevEnvironmentContext {
  3902. handleRequest(request: Request): Promise<Response> | Response;
  3903. }
  3904. export declare function createFetchableDevEnvironment(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext): FetchableDevEnvironment;
  3905. export declare function isFetchableDevEnvironment(environment: Environment): environment is FetchableDevEnvironment;
  3906. declare class FetchableDevEnvironment extends DevEnvironment {
  3907. private _handleRequest;
  3908. constructor(name: string, config: ResolvedConfig, context: FetchableDevEnvironmentContext);
  3909. dispatchFetch(request: Request): Promise<Response>;
  3910. }
  3911. //#endregion
  3912. //#region src/node/ssr/runnerImport.d.ts
  3913. interface RunnerImportResult<T> {
  3914. module: T;
  3915. dependencies: string[];
  3916. }
  3917. /**
  3918. * Import any file using the default Vite environment.
  3919. * @experimental
  3920. */
  3921. export declare function runnerImport<T>(moduleId: string, inlineConfig?: InlineConfig): Promise<RunnerImportResult<T>>;
  3922. //#endregion
  3923. //#region src/node/ssr/fetchModule.d.ts
  3924. interface FetchModuleOptions {
  3925. cached?: boolean;
  3926. inlineSourceMap?: boolean;
  3927. startOffset?: number;
  3928. }
  3929. /**
  3930. * Fetch module information for Vite module runner.
  3931. * @experimental
  3932. */
  3933. export declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<moduleRunner_FetchResult>;
  3934. //#endregion
  3935. //#region src/node/ssr/ssrTransform.d.ts
  3936. interface ModuleRunnerTransformOptions {
  3937. json?: {
  3938. stringify?: boolean;
  3939. };
  3940. }
  3941. declare function ssrTransform(code: string, inMap: SourceMap | {
  3942. mappings: "";
  3943. } | null, url: string, originalCode: string, options?: ModuleRunnerTransformOptions): Promise<TransformResult | null>;
  3944. //#endregion
  3945. //#region src/node/constants.d.ts
  3946. declare const VERSION: string;
  3947. declare const DEFAULT_CLIENT_MAIN_FIELDS: readonly string[];
  3948. declare const DEFAULT_SERVER_MAIN_FIELDS: readonly string[];
  3949. declare const DEFAULT_CLIENT_CONDITIONS: readonly string[];
  3950. declare const DEFAULT_SERVER_CONDITIONS: readonly string[];
  3951. declare const DEFAULT_EXTERNAL_CONDITIONS: readonly string[];
  3952. export declare const defaultAllowedOrigins: RegExp;
  3953. //#endregion
  3954. //#region src/node/utils.d.ts
  3955. /**
  3956. * Inlined to keep `@rollup/pluginutils` in devDependencies
  3957. */
  3958. type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
  3959. export declare const createFilter: (include?: FilterPattern, exclude?: FilterPattern, options?: {
  3960. resolve?: string | false | null;
  3961. }) => (id: unknown) => boolean;
  3962. export declare const rollupVersion = "4.23.0";
  3963. export declare function normalizePath(id: string): string;
  3964. export declare const isCSSRequest: (request: string) => boolean;
  3965. export declare function mergeConfig<D extends Record<string, any>, O extends Record<string, any>>(defaults: D extends Function ? never : D, overrides: O extends Function ? never : O, isRoot?: boolean): Record<string, any>;
  3966. export declare function mergeAlias(a?: AliasOptions, b?: AliasOptions): AliasOptions | undefined;
  3967. //#endregion
  3968. //#region src/node/server/send.d.ts
  3969. interface SendOptions {
  3970. etag?: string;
  3971. cacheControl?: string;
  3972. headers?: OutgoingHttpHeaders;
  3973. map?: SourceMap | {
  3974. mappings: "";
  3975. } | null;
  3976. }
  3977. export declare function send(req: http.IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, options: SendOptions): void;
  3978. //#endregion
  3979. //#region src/node/server/searchRoot.d.ts
  3980. /**
  3981. * Search up for the nearest workspace root
  3982. */
  3983. export declare function searchForWorkspaceRoot(current: string, root?: string): string;
  3984. //#endregion
  3985. //#region src/node/server/middlewares/static.d.ts
  3986. /**
  3987. * Check if the url is allowed to be served, via the `server.fs` config.
  3988. * @deprecated Use the `isFileLoadingAllowed` function instead.
  3989. */
  3990. export declare function isFileServingAllowed(config: ResolvedConfig, url: string): boolean;
  3991. export declare function isFileServingAllowed(url: string, server: ViteDevServer): boolean;
  3992. /**
  3993. * Warning: parameters are not validated, only works with normalized absolute paths
  3994. */
  3995. export declare function isFileLoadingAllowed(config: ResolvedConfig, filePath: string): boolean;
  3996. //#endregion
  3997. //#region src/node/env.d.ts
  3998. /**
  3999. * Load `.env` files within the `envDir` and merge them with the matching
  4000. * variables already present in `process.env`.
  4001. */
  4002. export declare function loadEnv(mode: string, envDir: string | false, prefixes?: string | string[]): Record<string, string>;
  4003. export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];
  4004. //#endregion
  4005. //#region src/node/plugins/manifest.d.ts
  4006. type Manifest = Record<string, ManifestChunk>;
  4007. interface ManifestChunk {
  4008. /**
  4009. * The input file name of this chunk / asset if known
  4010. */
  4011. src?: string;
  4012. /**
  4013. * The output file name of this chunk / asset
  4014. */
  4015. file: string;
  4016. /**
  4017. * The list of CSS files imported by this chunk
  4018. */
  4019. css?: string[];
  4020. /**
  4021. * The list of asset files imported by this chunk, excluding CSS files
  4022. */
  4023. assets?: string[];
  4024. /**
  4025. * Whether this chunk or asset is an entry point
  4026. */
  4027. isEntry?: boolean;
  4028. /**
  4029. * The name of this chunk / asset if known
  4030. */
  4031. name?: string;
  4032. /**
  4033. * Whether this chunk is a dynamic entry point
  4034. *
  4035. * This field is only present in JS chunks.
  4036. */
  4037. isDynamicEntry?: boolean;
  4038. /**
  4039. * The list of statically imported chunks by this chunk
  4040. *
  4041. * The values are the keys of the manifest. This field is only present in JS chunks.
  4042. */
  4043. imports?: string[];
  4044. /**
  4045. * The list of dynamically imported chunks by this chunk
  4046. *
  4047. * The values are the keys of the manifest. This field is only present in JS chunks.
  4048. */
  4049. dynamicImports?: string[];
  4050. }
  4051. //#endregion
  4052. //#region src/node/index.d.ts
  4053. /** @deprecated - use `parseSync` instead */
  4054. export declare const parseAst: typeof parseAst$1;
  4055. /** @deprecated - use `parse` instead */
  4056. export declare const parseAstAsync: typeof parseAstAsync$1;
  4057. export declare const esbuildVersion = "0.25.0";
  4058. //#endregion
  4059. export { type Alias, type AliasOptions, type AnymatchFn, type AnymatchPattern, type AppType, type BindCLIShortcutsOptions, type BuildAppHook, type BuildEnvironmentOptions, type BuildOptions, type BuilderOptions, type CLIShortcut, type CSSModulesOptions, type CSSOptions, type ChunkMetadata, type CommonServerOptions, type ConfigEnv, type ConfigPluginContext, type Connect, type ConnectedPayload, type CorsOptions, type CorsOrigin, type CustomEventMap, type CustomPayload, type CustomPluginOptionsVite, type DepOptimizationConfig, type DepOptimizationMetadata, type DepOptimizationOptions, type DevEnvironmentContext, type DevEnvironmentOptions, type ESBuildOptions, type ESTree, type Environment, type EnvironmentModuleGraph, type EnvironmentModuleNode, type EnvironmentOptions, type ErrorPayload, type EsbuildTransformOptions, type ExperimentalOptions, type ExportsData, type FSWatcher, type FetchFunction, type FetchModuleOptions, type FetchResult, type FetchableDevEnvironment, type FetchableDevEnvironmentContext, type FileSystemServeOptions, type FilterPattern, type FullReloadPayload, type GeneralImportGlobOptions, type HMRPayload, type HTMLOptions, type HmrContext, type HmrOptions, type HookHandler, type HotChannel, type HotChannelClient, type HotChannelListener, type HotPayload, type HotUpdateOptions, type HtmlAssetSource, type HtmlTagDescriptor, type index_d_exports as HttpProxy, type HttpServer, type ImportGlobFunction, type ImportGlobOptions, type IndexHtmlTransform, type IndexHtmlTransformContext, type IndexHtmlTransformHook, type IndexHtmlTransformResult, type InferCustomEventPayload, type InlineConfig, type InternalResolveOptions, type InvalidatePayload, type JsonOptions, type KnownAsTypeMap, type KnownQueryTypeMap, type LegacyOptions, type LessPreprocessorOptions, type LibraryFormats, type LibraryOptions, type LightningCSSOptions, type LogErrorOptions, type LogLevel, type LogOptions, type LogType, type Logger, type LoggerOptions, type Manifest, type ManifestChunk, type MapToFunction, type AnymatchMatcher as Matcher, type MinifyOptions, type MinifyResult, type MinimalPluginContextWithoutEnvironment, type ModuleGraph, type ModuleNode, type ModulePreloadOptions, type ModuleRunnerTransformOptions, type NormalizedHotChannel, type NormalizedHotChannelClient, type NormalizedServerHotChannel, type OptimizedDepInfo, type OxcOptions, type ParseResult, type ParserOptions, type Plugin, type PluginContainer, type PluginHookUtils, type PluginOption, type Config as PostcssUserConfig, type PreprocessCSSResult, type PreviewOptions, type PreviewServer, type PreviewServerHook, type ProxyOptions, type PrunePayload, type RenderBuiltAssetUrl, type ResolveFn, type ResolveModulePreloadDependenciesFn, type ResolveOptions, type ResolvedBuildEnvironmentOptions, type ResolvedBuildOptions, type ResolvedCSSOptions, type ResolvedConfig, type ResolvedDevEnvironmentOptions, type ResolvedDevToolsConfig, type ResolvedModulePreloadOptions, type ResolvedPreviewOptions, type ResolvedSSROptions, type ResolvedServerOptions, type ResolvedServerUrls, type ResolvedUrl, type ResolvedWorkerOptions, type ResolverFunction, type ResolverObject, type Rolldown, type Rollup, type RollupCommonJSOptions, type RollupDynamicImportVarsOptions, type RunnableDevEnvironment, type RunnableDevEnvironmentContext, type SSROptions, type SSRTarget, type SassPreprocessorOptions, type SendOptions, type ServerHook, type ServerHotChannel, type ServerModuleRunnerOptions, type ServerOptions$1 as ServerOptions, type ServerWatchOptions, type SkipInformation, type SsrDepOptimizationConfig, type StylusPreprocessorOptions, type Terser, type TerserOptions, type TransformOptions, type TransformResult, type Update, type UpdatePayload, type UserConfig, type UserConfigExport, type UserConfigFn, type UserConfigFnObject, type UserConfigFnPromise, Visitor, type VisitorObject, type ViteBuilder, type ViteDevServer, type WatchOptions, type WebSocket, type WebSocketAlias, type WebSocketClient, type WebSocketCustomListener, type WebSocketServer, type WsOptions, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_EXTERNAL_CONDITIONS as defaultExternalConditions, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, esmExternalRequirePlugin, minify, minifySync, ssrTransform as moduleRunnerTransform, parse, parseSync, rolldownVersion, VERSION as version, withFilter };