stencil-public-compiler.d.ts 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207
  1. import type { JsonDocs } from './stencil-public-docs';
  2. import type { PrerenderUrlResults } from '../internal';
  3. export * from './stencil-public-docs';
  4. /**
  5. * https://stenciljs.com/docs/config/
  6. */
  7. export interface StencilConfig {
  8. /**
  9. * By default, Stencil will attempt to optimize small scripts by inlining them in HTML. Setting
  10. * this flag to `false` will prevent this optimization and keep all scripts separate from HTML.
  11. */
  12. allowInlineScripts?: boolean;
  13. /**
  14. * By setting `autoprefixCss` to `true`, Stencil will use the appropriate config to automatically
  15. * prefix css. For example, developers can write modern and standard css properties, such as
  16. * "transform", and Stencil will automatically add in the prefixed version, such as "-webkit-transform".
  17. * As of Stencil v2, autoprefixing CSS is no longer the default.
  18. * Defaults to `false`
  19. */
  20. autoprefixCss?: boolean | any;
  21. /**
  22. * By default, Stencil will statically analyze the application and generate a component graph of
  23. * how all the components are interconnected.
  24. *
  25. * From the component graph it is able to best decide how components should be grouped
  26. * depending on their usage with one another within the app.
  27. * By doing so it's able to bundle components together in order to reduce network requests.
  28. * However, bundles can be manually generated using the bundles config.
  29. *
  30. * The bundles config is an array of objects that represent how components are grouped together
  31. * in lazy-loaded bundles.
  32. * This config is rarely needed as Stencil handles this automatically behind the scenes.
  33. */
  34. bundles?: ConfigBundle[];
  35. /**
  36. * Stencil will cache build results in order to speed up rebuilds.
  37. * To disable this feature, set enableCache to false.
  38. */
  39. enableCache?: boolean;
  40. /**
  41. * Stencil is traditionally used to compile many components into an app,
  42. * and each component comes with its own compartmentalized styles.
  43. * However, it's still common to have styles which should be "global" across all components and the website.
  44. * A global CSS file is often useful to set CSS Variables.
  45. *
  46. * Additionally, the globalStyle config can be used to precompile styles with Sass, PostCss, etc.
  47. * Below is an example folder structure containing a webapp's global sass file, named app.css.
  48. */
  49. globalStyle?: string;
  50. /**
  51. * When the hashFileNames config is set to true, and it is a production build,
  52. * the hashedFileNameLength config is used to determine how many characters the file name's hash should be.
  53. */
  54. hashedFileNameLength?: number;
  55. /**
  56. * During production builds, the content of each generated file is hashed to represent the content,
  57. * and the hashed value is used as the filename. If the content isn't updated between builds,
  58. * then it receives the same filename. When the content is updated, then the filename is different.
  59. *
  60. * By doing this, deployed apps can "forever-cache" the build directory and take full advantage of
  61. * content delivery networks (CDNs) and heavily caching files for faster apps.
  62. */
  63. hashFileNames?: boolean;
  64. /**
  65. * The namespace config is a string representing a namespace for the app.
  66. * For apps that are not meant to be a library of reusable components,
  67. * the default of App is just fine. However, if the app is meant to be consumed
  68. * as a third-party library, such as Ionic, a unique namespace is required.
  69. */
  70. namespace?: string;
  71. /**
  72. * Stencil is able to take an app's source and compile it to numerous targets,
  73. * such as an app to be deployed on an http server, or as a third-party library
  74. * to be distributed on npm. By default, Stencil apps have an output target type of www.
  75. *
  76. * The outputTargets config is an array of objects, with types of www and dist.
  77. */
  78. outputTargets?: OutputTarget[];
  79. /**
  80. * The plugins config can be used to add your own rollup plugins.
  81. * By default, Stencil does not come with Sass or PostCss support.
  82. * However, either can be added using the plugin array.
  83. */
  84. plugins?: any[];
  85. /**
  86. * Generate js source map files for all bundles
  87. */
  88. sourceMap?: boolean;
  89. /**
  90. * The srcDir config specifies the directory which should contain the source typescript files
  91. * for each component. The standard for Stencil apps is to use src, which is the default.
  92. */
  93. srcDir?: string;
  94. /**
  95. * Passes custom configuration down to the "@rollup/plugin-commonjs" that Stencil uses under the hood.
  96. * For further information: https://stenciljs.com/docs/module-bundling
  97. */
  98. commonjs?: BundlingConfig;
  99. /**
  100. * Passes custom configuration down to the "@rollup/plugin-node-resolve" that Stencil uses under the hood.
  101. * For further information: https://stenciljs.com/docs/module-bundling
  102. */
  103. nodeResolve?: NodeResolveConfig;
  104. /**
  105. * Passes custom configuration down to rollup itself, not all rollup options can be overridden.
  106. */
  107. rollupConfig?: RollupConfig;
  108. /**
  109. * Sets if the ES5 build should be generated or not. Stencil generates a modern build without ES5,
  110. * whereas this setting to `true` will also create es5 builds for both dev and prod modes. Setting
  111. * `buildEs5` to `prod` will only build ES5 in prod mode. Basically if the app does not need to run
  112. * on legacy browsers (IE11 and Edge 18 and below), it's safe to not build ES5, which will also speed
  113. * up build times. Defaults to `false`.
  114. */
  115. buildEs5?: boolean | 'prod';
  116. /**
  117. * Sets if the JS browser files are minified or not. Stencil uses `terser` under the hood.
  118. * Defaults to `false` in dev mode and `true` in production mode.
  119. */
  120. minifyJs?: boolean;
  121. /**
  122. * Sets if the CSS is minified or not.
  123. * Defaults to `false` in dev mode and `true` in production mode.
  124. */
  125. minifyCss?: boolean;
  126. /**
  127. * Forces Stencil to run in `dev` mode if the value is `true` and `production` mode
  128. * if it's `false`.
  129. *
  130. * Defaults to `false` (ie. production) unless the `--dev` flag is used in the CLI.
  131. */
  132. devMode?: boolean;
  133. /**
  134. * Object to provide a custom logger. By default a `logger` is already provided for the
  135. * platform the compiler is running on, such as NodeJS or a browser.
  136. */
  137. logger?: Logger;
  138. /**
  139. * Config to add extra runtime for DOM features that require more polyfills. Note
  140. * that not all DOM APIs are fully polyfilled when using the slot polyfill. These
  141. * are opt-in since not all users will require the additional runtime.
  142. */
  143. extras?: ConfigExtras;
  144. /**
  145. * The hydrated flag identifies if a component and all of its child components
  146. * have finished hydrating. This helps prevent any flash of unstyled content (FOUC)
  147. * as various components are asynchronously downloaded and rendered. By default it
  148. * will add the `hydrated` CSS class to the element. The `hydratedFlag` config can be used
  149. * to change the name of the CSS class, change it to an attribute, or change which
  150. * type of CSS properties and values are assigned before and after hydrating. This config
  151. * can also be used to not include the hydrated flag at all by setting it to `null`.
  152. */
  153. hydratedFlag?: HydratedFlag;
  154. /**
  155. * Ionic prefers to hide all components prior to hydration with a style tag appended
  156. * to the head of the document containing some `visibility: hidden;` css rules.
  157. *
  158. * Disabling this will remove the style tag that sets `visibility: hidden;` on all
  159. * unhydrated web components. This more closely follows the HTML spec, and allows
  160. * you to set your own fallback content.
  161. *
  162. */
  163. invisiblePrehydration?: boolean;
  164. /**
  165. * Sets the task queue used by stencil's runtime. The task queue schedules DOM read and writes
  166. * across the frames to efficiently render and reduce layout thrashing. By default,
  167. * `async` is used. It's recommended to also try each setting to decide which works
  168. * best for your use-case. In all cases, if your app has many CPU intensive tasks causing the
  169. * main thread to periodically lock-up, it's always recommended to try
  170. * [Web Workers](https://stenciljs.com/docs/web-workers) for those tasks.
  171. *
  172. * - `async`: DOM read and writes are scheduled in the next frame to prevent layout thrashing.
  173. * During intensive CPU tasks it will not reschedule rendering to happen in the next frame.
  174. * `async` is ideal for most apps, and if the app has many intensive tasks causing the main
  175. * thread to lock-up, it's recommended to try [Web Workers](https://stenciljs.com/docs/web-workers)
  176. * rather than the congestion async queue.
  177. *
  178. * - `congestionAsync`: DOM reads and writes are scheduled in the next frame to prevent layout
  179. * thrashing. When the app is heavily tasked and the queue becomes congested it will then
  180. * split the work across multiple frames to prevent blocking the main thread. However, it can
  181. * also introduce unnecessary reflows in some cases, especially during startup. `congestionAsync`
  182. * is ideal for apps running animations while also simultaneously executing intensive tasks
  183. * which may lock-up the main thread.
  184. *
  185. * - `immediate`: Makes writeTask() and readTask() callbacks to be executed synchronously. Tasks
  186. * are not scheduled to run in the next frame, but do note there is at least one microtask.
  187. * The `immediate` setting is ideal for apps that do not provide long running and smooth
  188. * animations. Like the async setting, if the app has intensive tasks causing the main thread
  189. * to lock-up, it's recommended to try [Web Workers](https://stenciljs.com/docs/web-workers).
  190. */
  191. taskQueue?: 'async' | 'immediate' | 'congestionAsync';
  192. /**
  193. * Provide a object of key/values accessible within the app, using the `Env` object.
  194. */
  195. env?: {
  196. [prop: string]: string | undefined;
  197. };
  198. globalScript?: string;
  199. srcIndexHtml?: string;
  200. watch?: boolean;
  201. testing?: TestingConfig;
  202. maxConcurrentWorkers?: number;
  203. preamble?: string;
  204. rollupPlugins?: {
  205. before?: any[];
  206. after?: any[];
  207. };
  208. entryComponentsHint?: string[];
  209. buildDist?: boolean;
  210. buildLogFilePath?: string;
  211. cacheDir?: string;
  212. devInspector?: boolean;
  213. devServer?: StencilDevServerConfig;
  214. enableCacheStats?: boolean;
  215. sys?: CompilerSystem;
  216. tsconfig?: string;
  217. validateTypes?: boolean;
  218. /**
  219. * An array of RegExp patterns that are matched against all source files before adding
  220. * to the watch list in watch mode. If the file path matches any of the patterns, when it
  221. * is updated, it will not trigger a re-run of tests.
  222. */
  223. watchIgnoredRegex?: RegExp | RegExp[];
  224. excludeUnusedDependencies?: boolean;
  225. stencilCoreResolvedId?: string;
  226. }
  227. export interface ConfigExtras {
  228. /**
  229. * By default, the slot polyfill does not update `appendChild()` so that it appends
  230. * new child nodes into the correct child slot like how shadow dom works. This is an opt-in
  231. * polyfill for those who need it when using `element.appendChild(node)` and expecting the
  232. * child to be appended in the same location shadow dom would. This is not required for
  233. * IE11 or Edge 18, but can be enabled if the app is using `appendChild()`. Defaults to `false`.
  234. */
  235. appendChildSlotFix?: boolean;
  236. /**
  237. * By default, the runtime does not polyfill `cloneNode()` when cloning a component
  238. * that uses the slot polyfill. This is an opt-in polyfill for those who need it.
  239. * This is not required for IE11 or Edge 18, but can be enabled if the app is using
  240. * `cloneNode()` and unexpected node are being cloned due to the slot polyfill
  241. * simulating shadow dom. Defaults to `false`.
  242. */
  243. cloneNodeFix?: boolean;
  244. /**
  245. * Include the CSS Custom Property polyfill/shim for legacy browsers. ESM builds will
  246. * not include the css vars shim. Defaults to `false`
  247. */
  248. cssVarsShim?: boolean;
  249. /**
  250. * Dynamic `import()` shim. This is only needed for Edge 18 and below, and Firefox 67
  251. * and below. Defaults to `false`.
  252. */
  253. dynamicImportShim?: boolean;
  254. /**
  255. * Dispatches component lifecycle events. Mainly used for testing. Defaults to `false`.
  256. */
  257. lifecycleDOMEvents?: boolean;
  258. /**
  259. * Safari 10 supports ES modules with `<script type="module">`, however, it did not implement
  260. * `<script nomodule>`. When set to `true`, the runtime will patch support for Safari 10
  261. * due to its lack of `nomodule` support.
  262. * Defaults to `false`.
  263. */
  264. safari10?: boolean;
  265. /**
  266. * It is possible to assign data to the actual `<script>` element's `data-opts` property,
  267. * which then gets passed to Stencil's initial bootstrap. This feature is only required
  268. * for very special cases and rarely needed. Defaults to `false`.
  269. */
  270. scriptDataOpts?: boolean;
  271. /**
  272. * Experimental flag to align the behavior of invoking `textContent` on a scoped component to act more like a
  273. * component that uses the shadow DOM. Defaults to `false`
  274. */
  275. scopedSlotTextContentFix?: boolean;
  276. /**
  277. * If enabled `true`, the runtime will check if the shadow dom shim is required. However,
  278. * if it's determined that shadow dom is already natively supported by the browser then
  279. * it does not request the shim. When set to `false` it will avoid all shadow dom tests.
  280. * Defaults to `false`.
  281. */
  282. shadowDomShim?: boolean;
  283. /**
  284. * When a component is first attached to the DOM, this setting will wait a single tick before
  285. * rendering. This works around an Angular issue, where Angular attaches the elements before
  286. * settings their initial state, leading to double renders and unnecessary event dispatches.
  287. * Defaults to `false`.
  288. */
  289. initializeNextTick?: boolean;
  290. /**
  291. * For browsers that do not support shadow dom (IE11 and Edge 18 and below), slot is polyfilled
  292. * to simulate the same behavior. However, the host element's `childNodes` and `children`
  293. * getters are not patched to only show the child nodes and elements of the default slot.
  294. * Defaults to `false`.
  295. */
  296. slotChildNodesFix?: boolean;
  297. /**
  298. * Enables the tagNameTransform option of `defineCustomElements()`, so the component tagName
  299. * can be customized at runtime. Defaults to `false`.
  300. */
  301. tagNameTransform?: boolean;
  302. }
  303. export interface Config extends StencilConfig {
  304. buildAppCore?: boolean;
  305. buildDocs?: boolean;
  306. configPath?: string;
  307. writeLog?: boolean;
  308. devServer?: DevServerConfig;
  309. flags?: ConfigFlags;
  310. fsNamespace?: string;
  311. logLevel?: LogLevel;
  312. rootDir?: string;
  313. packageJsonFilePath?: string;
  314. suppressLogs?: boolean;
  315. profile?: boolean;
  316. tsCompilerOptions?: any;
  317. _isValidated?: boolean;
  318. _isTesting?: boolean;
  319. }
  320. export interface HydratedFlag {
  321. /**
  322. * Defaults to `hydrated`.
  323. */
  324. name?: string;
  325. /**
  326. * Can be either `class` or `attribute`. Defaults to `class`.
  327. */
  328. selector?: 'class' | 'attribute';
  329. /**
  330. * The CSS property used to show and hide components. Defaults to use the CSS `visibility`
  331. * property. Other commonly used CSS properties would be `display` with the `initialValue`
  332. * setting as `none`, or `opacity` with the `initialValue` as `0`. Defaults to `visibility`
  333. * and the default `initialValue` is `hidden`.
  334. */
  335. property?: string;
  336. /**
  337. * This is the CSS value to give all components before it has been hydrated.
  338. * Defaults to `hidden`.
  339. */
  340. initialValue?: string;
  341. /**
  342. * This is the CSS value to assign once a component has finished hydrating.
  343. * This is the CSS value that'll allow the component to show. Defaults to `inherit`.
  344. */
  345. hydratedValue?: string;
  346. }
  347. export interface StencilDevServerConfig {
  348. /**
  349. * IP address used by the dev server. The default is `0.0.0.0`, which points to all IPv4 addresses
  350. * on the local machine, such as `localhost`.
  351. */
  352. address?: string;
  353. /**
  354. * Base path to be used by the server. Defaults to the root pathname.
  355. */
  356. basePath?: string;
  357. /**
  358. * EXPERIMENTAL!
  359. * During development, node modules can be independently requested and bundled, making for
  360. * faster build times. This is only available using the Stencil Dev Server throughout
  361. * development. Production builds and builds with the `es5` flag will override
  362. * this setting to `false`. Default is `false`.
  363. */
  364. experimentalDevModules?: boolean;
  365. /**
  366. * If the dev server should respond with gzip compressed content. Defaults to `true`.
  367. */
  368. gzip?: boolean;
  369. /**
  370. * When set, the dev server will run via https using the SSL certificate and key you provide
  371. * (use `fs` if you want to read them from files).
  372. */
  373. https?: Credentials;
  374. /**
  375. * The URL the dev server should first open to. Defaults to `/`.
  376. */
  377. initialLoadUrl?: string;
  378. /**
  379. * When `true`, every request to the server will be logged within the terminal.
  380. * Defaults to `false`.
  381. */
  382. logRequests?: boolean;
  383. /**
  384. * By default, when dev server is started the local dev URL is opened in your default browser.
  385. * However, to prevent this URL to be opened change this value to `false`. Defaults to `true`.
  386. */
  387. openBrowser?: boolean;
  388. /**
  389. * Sets the server's port. Defaults to `3333`.
  390. */
  391. port?: number;
  392. /**
  393. * When files are watched and updated, by default the dev server will use `hmr` (Hot Module Replacement)
  394. * to update the page without a full page refresh. To have the page do a full refresh use `pageReload`.
  395. * To disable any reloading, use `null`. Defaults to `hmr`.
  396. */
  397. reloadStrategy?: PageReloadStrategy;
  398. /**
  399. * Local path to a NodeJs file with a dev server request listener as the default export.
  400. * The user's request listener is given the first chance to handle every request the dev server
  401. * receives, and can choose to handle it or instead pass it on to the default dev server
  402. * by calling `next()`.
  403. *
  404. * Below is an example of a NodeJs file the `requestListenerPath` config is using.
  405. * The request and response arguments are the same as Node's `http` module and `RequestListener`
  406. * callback. https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener
  407. *
  408. * ```js
  409. * module.exports = function (req, res, next) {
  410. * if (req.url === '/ping') {
  411. * // custom response overriding the dev server
  412. * res.setHeader('Content-Type', 'text/plain');
  413. * res.writeHead(200);
  414. * res.end('pong');
  415. * } else {
  416. * // pass request on to the default dev server
  417. * next();
  418. * }
  419. * };
  420. * ```
  421. */
  422. requestListenerPath?: string;
  423. /**
  424. * The root directory to serve the files from.
  425. */
  426. root?: string;
  427. /**
  428. * If the dev server should Server-Side Render (SSR) each page, meaning it'll dynamically generate
  429. * server-side rendered html on each page load. The `--ssr` flag will most commonly be used with
  430. * the`--dev --watch --serve` flags during development. Note that this is for development purposes
  431. * only, and the built-in dev server should not be used for production. Defaults to `false`.
  432. */
  433. ssr?: boolean;
  434. /**
  435. * If the dev server fails to start up within the given timeout (in milliseconds), the startup will
  436. * be canceled. Set to zero to disable the timeout. Defaults to `15000`.
  437. */
  438. startupTimeout?: number;
  439. /**
  440. * Whether to use the dev server's websocket client or not. Defaults to `true`.
  441. */
  442. websocket?: boolean;
  443. /**
  444. * If the dev server should fork a worker for the server process or not. A singled-threaded dev server
  445. * is slower, however it is useful for debugging http requests and responses. Defaults to `true`.
  446. */
  447. worker?: boolean;
  448. }
  449. export interface DevServerConfig extends StencilDevServerConfig {
  450. browserUrl?: string;
  451. devServerDir?: string;
  452. excludeHmr?: string[];
  453. historyApiFallback?: HistoryApiFallback;
  454. openBrowser?: boolean;
  455. prerenderConfig?: string;
  456. protocol?: 'http' | 'https';
  457. srcIndexHtml?: string;
  458. }
  459. export interface HistoryApiFallback {
  460. index?: string;
  461. disableDotRule?: boolean;
  462. }
  463. export interface DevServerEditor {
  464. id: string;
  465. name?: string;
  466. supported?: boolean;
  467. priority?: number;
  468. }
  469. export interface ConfigFlags {
  470. task?: TaskCommand;
  471. args?: string[];
  472. knownArgs?: string[];
  473. unknownArgs?: string[];
  474. address?: string;
  475. build?: boolean;
  476. cache?: boolean;
  477. checkVersion?: boolean;
  478. ci?: boolean;
  479. compare?: boolean;
  480. config?: string;
  481. debug?: boolean;
  482. dev?: boolean;
  483. docs?: boolean;
  484. docsApi?: string;
  485. docsJson?: string;
  486. e2e?: boolean;
  487. emulate?: string;
  488. es5?: boolean;
  489. headless?: boolean;
  490. help?: boolean;
  491. log?: boolean;
  492. logLevel?: string;
  493. verbose?: boolean;
  494. maxWorkers?: number;
  495. open?: boolean;
  496. port?: number;
  497. prerender?: boolean;
  498. prod?: boolean;
  499. profile?: boolean;
  500. root?: string;
  501. screenshot?: boolean;
  502. screenshotConnector?: string;
  503. serve?: boolean;
  504. serviceWorker?: boolean;
  505. spec?: boolean;
  506. ssr?: boolean;
  507. stats?: boolean;
  508. updateScreenshot?: boolean;
  509. version?: boolean;
  510. watch?: boolean;
  511. devtools?: boolean;
  512. }
  513. export declare type TaskCommand = 'build' | 'docs' | 'generate' | 'g' | 'help' | 'info' | 'prerender' | 'serve' | 'telemetry' | 'test' | 'version';
  514. export declare type PageReloadStrategy = 'hmr' | 'pageReload' | null;
  515. /**
  516. * The prerender config is used when prerendering a `www` output target.
  517. * Within `stencil.config.ts`, set the path to the prerendering
  518. * config file path using the `prerenderConfig` property, such as:
  519. *
  520. * ```tsx
  521. * import { Config } from '@stencil/core';
  522. * export const config: Config = {
  523. * outputTargets: [
  524. * {
  525. * type: 'www',
  526. * baseUrl: 'https://stenciljs.com/',
  527. * prerenderConfig: './prerender.config.ts',
  528. * }
  529. * ]
  530. * };
  531. * ```
  532. *
  533. * The `prerender.config.ts` should export a `config` object using
  534. * the `PrerenderConfig` interface.
  535. *
  536. * ```tsx
  537. * import { PrerenderConfig } from '@stencil/core';
  538. * export const config: PrerenderConfig = {
  539. * ...
  540. * };
  541. * ```
  542. *
  543. * For more info: https://stenciljs.com/docs/static-site-generation
  544. */
  545. export interface PrerenderConfig {
  546. /**
  547. * Run after each `document` is hydrated, but before it is serialized
  548. * into an HTML string. Hook is passed the `document` and its `URL`.
  549. */
  550. afterHydrate?(document: Document, url: URL, results: PrerenderUrlResults): any | Promise<any>;
  551. /**
  552. * Run before each `document` is hydrated. Hook is passed the `document` it's `URL`.
  553. */
  554. beforeHydrate?(document: Document, url: URL): any | Promise<any>;
  555. /**
  556. * Runs after the template Document object has serialize into an
  557. * HTML formatted string. Returns an HTML string to be used as the
  558. * base template for all prerendered pages.
  559. */
  560. afterSerializeTemplate?(html: string): string | Promise<string>;
  561. /**
  562. * Runs before the template Document object is serialize into an
  563. * HTML formatted string. Returns the Document to be serialized which
  564. * will become the base template html for all prerendered pages.
  565. */
  566. beforeSerializeTemplate?(document: Document): Document | Promise<Document>;
  567. /**
  568. * A hook to be used to generate the canonical `<link>` tag
  569. * which goes in the `<head>` of every prerendered page. Returning `null`
  570. * will not add a canonical url tag to the page.
  571. */
  572. canonicalUrl?(url: URL): string | null;
  573. /**
  574. * While prerendering, crawl same-origin URLs found within `<a href>` elements.
  575. * Defaults to `true`.
  576. */
  577. crawlUrls?: boolean;
  578. /**
  579. * URLs to start the prerendering from. By default the root URL of `/` is used.
  580. */
  581. entryUrls?: string[];
  582. /**
  583. * Return `true` the given `<a>` element should be crawled or not.
  584. */
  585. filterAnchor?(attrs: {
  586. [attrName: string]: string;
  587. }, base?: URL): boolean;
  588. /**
  589. * Return `true` if the given URL should be prerendered or not.
  590. */
  591. filterUrl?(url: URL, base: URL): boolean;
  592. /**
  593. * Returns the file path which the prerendered HTML content
  594. * should be written to.
  595. */
  596. filePath?(url: URL, filePath: string): string;
  597. /**
  598. * Returns the hydrate options to use for each individual prerendered page.
  599. */
  600. hydrateOptions?(url: URL): PrerenderHydrateOptions;
  601. /**
  602. * Returns the template file's content. The template is the base
  603. * HTML used for all prerendered pages.
  604. */
  605. loadTemplate?(filePath: string): string | Promise<string>;
  606. /**
  607. * Used to normalize the page's URL from a given a string and the current
  608. * page's base URL. Largely used when reading an anchor's `href` attribute
  609. * value and normalizing it into a `URL`.
  610. */
  611. normalizeUrl?(href: string, base: URL): URL;
  612. robotsTxt?(opts: RobotsTxtOpts): string | RobotsTxtResults;
  613. sitemapXml?(opts: SitemapXmpOpts): string | SitemapXmpResults;
  614. /**
  615. * Static Site Generated (SSG). Does not include Stencil's clientside
  616. * JavaScript, custom elements or preload modules.
  617. */
  618. staticSite?: boolean;
  619. /**
  620. * If the prerenndered URLs should have a trailing "/"" or not. Defaults to `false`.
  621. */
  622. trailingSlash?: boolean;
  623. }
  624. export interface HydrateDocumentOptions {
  625. /**
  626. * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
  627. * a random ID will be generated
  628. */
  629. buildId?: string;
  630. /**
  631. * Sets the `href` attribute on the `<link rel="canonical">`
  632. * tag within the `<head>`. If the value is not defined it will
  633. * ensure a canonical link tag is no included in the `<head>`.
  634. */
  635. canonicalUrl?: string;
  636. /**
  637. * Include the HTML comments and attributes used by the clientside
  638. * JavaScript to read the structure of the HTML and rebuild each
  639. * component. Defaults to `true`.
  640. */
  641. clientHydrateAnnotations?: boolean;
  642. /**
  643. * Constrain `setTimeout()` to 1ms, but still async. Also
  644. * only allows `setInterval()` to fire once, also constrained to 1ms.
  645. * Defaults to `true`.
  646. */
  647. constrainTimeouts?: boolean;
  648. /**
  649. * Sets `document.cookie`
  650. */
  651. cookie?: string;
  652. /**
  653. * Sets the `dir` attribute on the top level `<html>`.
  654. */
  655. direction?: string;
  656. /**
  657. * Component tag names listed here will not be prerendered, nor will
  658. * hydrated on the clientside. Components listed here will be ignored
  659. * as custom elements and treated no differently than a `<div>`.
  660. */
  661. excludeComponents?: string[];
  662. /**
  663. * Sets the `lang` attribute on the top level `<html>`.
  664. */
  665. language?: string;
  666. /**
  667. * Maximum number of components to hydrate on one page. Defaults to `300`.
  668. */
  669. maxHydrateCount?: number;
  670. /**
  671. * Sets `document.referrer`
  672. */
  673. referrer?: string;
  674. /**
  675. * Removes every `<script>` element found in the `document`. Defaults to `false`.
  676. */
  677. removeScripts?: boolean;
  678. /**
  679. * Removes CSS not used by elements within the `document`. Defaults to `true`.
  680. */
  681. removeUnusedStyles?: boolean;
  682. /**
  683. * The url the runtime uses for the resources, such as the assets directory.
  684. */
  685. resourcesUrl?: string;
  686. /**
  687. * Prints out runtime console logs to the NodeJS process. Defaults to `false`.
  688. */
  689. runtimeLogging?: boolean;
  690. /**
  691. * Component tags listed here will only be prerendered or serverside-rendered
  692. * and will not be clientside hydrated. This is useful for components that
  693. * are not dynamic and do not need to be defined as a custom element within the
  694. * browser. For example, a header or footer component would be a good example that
  695. * may not require any clientside JavaScript.
  696. */
  697. staticComponents?: string[];
  698. /**
  699. * The amount of milliseconds to wait for a page to finish rendering until
  700. * a timeout error is thrown. Defaults to `15000`.
  701. */
  702. timeout?: number;
  703. /**
  704. * Sets `document.title`.
  705. */
  706. title?: string;
  707. /**
  708. * Sets `location.href`
  709. */
  710. url?: string;
  711. /**
  712. * Sets `navigator.userAgent`
  713. */
  714. userAgent?: string;
  715. }
  716. export interface SerializeDocumentOptions extends HydrateDocumentOptions {
  717. /**
  718. * Runs after the `document` has been hydrated.
  719. */
  720. afterHydrate?(document: any): any | Promise<any>;
  721. /**
  722. * Sets an approximate line width the HTML should attempt to stay within.
  723. * Note that this is "approximate", in that HTML may often not be able
  724. * to be split at an exact line width. Additionally, new lines created
  725. * is where HTML naturally already has whitespace, such as before an
  726. * attribute or spaces between words. Defaults to `100`.
  727. */
  728. approximateLineWidth?: number;
  729. /**
  730. * Runs before the `document` has been hydrated.
  731. */
  732. beforeHydrate?(document: any): any | Promise<any>;
  733. /**
  734. * Format the HTML in a nicely indented format.
  735. * Defaults to `false`.
  736. */
  737. prettyHtml?: boolean;
  738. /**
  739. * Remove quotes from attribute values when possible.
  740. * Defaults to `true`.
  741. */
  742. removeAttributeQuotes?: boolean;
  743. /**
  744. * Remove the `=""` from standardized `boolean` attributes,
  745. * such as `hidden` or `checked`. Defaults to `true`.
  746. */
  747. removeBooleanAttributeQuotes?: boolean;
  748. /**
  749. * Remove these standardized attributes when their value is empty:
  750. * `class`, `dir`, `id`, `lang`, and `name`, `title`. Defaults to `true`.
  751. */
  752. removeEmptyAttributes?: boolean;
  753. /**
  754. * Remove HTML comments. Defaults to `true`.
  755. */
  756. removeHtmlComments?: boolean;
  757. }
  758. export interface HydrateFactoryOptions extends SerializeDocumentOptions {
  759. serializeToHtml: boolean;
  760. destroyWindow: boolean;
  761. destroyDocument: boolean;
  762. }
  763. export interface PrerenderHydrateOptions extends SerializeDocumentOptions {
  764. /**
  765. * Adds `<link rel="modulepreload">` for modules that will eventually be requested.
  766. * Defaults to `true`.
  767. */
  768. addModulePreloads?: boolean;
  769. /**
  770. * Hash the content of assets, such as images, fonts and css files,
  771. * and add the hashed value as `v` querystring. For example,
  772. * `/assets/image.png?v=abcd1234`. This allows for assets to be
  773. * heavily cached by setting the server's response header with
  774. * `Cache-Control: max-age=31536000, immutable`.
  775. */
  776. hashAssets?: 'querystring';
  777. /**
  778. * External stylesheets from `<link rel="stylesheet">` are instead inlined
  779. * into `<style>` elements. Defaults to `false`.
  780. */
  781. inlineExternalStyleSheets?: boolean;
  782. /**
  783. * Minify CSS content within `<style>` elements. Defaults to `true`.
  784. */
  785. minifyStyleElements?: boolean;
  786. /**
  787. * Minify JavaScript content within `<script>` elements. Defaults to `true`.
  788. */
  789. minifyScriptElements?: boolean;
  790. /**
  791. * Entire `document` should be static. This is useful for specific pages that
  792. * should be static, rather than the entire site. If the whole site should be static,
  793. * use the `staticSite` property on the prerender config instead. If only certain
  794. * components should be static then use `staticComponents` instead.
  795. */
  796. staticDocument?: boolean;
  797. }
  798. export interface RobotsTxtOpts {
  799. urls: string[];
  800. sitemapUrl: string;
  801. baseUrl: string;
  802. dir: string;
  803. }
  804. export interface RobotsTxtResults {
  805. content: string;
  806. filePath: string;
  807. url: string;
  808. }
  809. export interface SitemapXmpOpts {
  810. urls: string[];
  811. baseUrl: string;
  812. dir: string;
  813. }
  814. export interface SitemapXmpResults {
  815. content: string;
  816. filePath: string;
  817. url: string;
  818. }
  819. /**
  820. * Common system used by the compiler. All file reads, writes, access, etc. will all use
  821. * this system. Additionally, throughout each build, the compiler will use an internal
  822. * in-memory file system as to prevent unnecessary fs reads and writes. At the end of each
  823. * build all actions the in-memory fs performed will be written to disk using this system.
  824. * A NodeJS based system will use APIs such as `fs` and `crypto`, and a web-based system
  825. * will use in-memory Maps and browser APIs. Either way, the compiler itself is unaware
  826. * of the actual platform it's being ran on top of.
  827. */
  828. export interface CompilerSystem {
  829. name: 'node' | 'in-memory';
  830. version: string;
  831. events?: BuildEvents;
  832. details?: SystemDetails;
  833. /**
  834. * Add a callback which will be ran when destroy() is called.
  835. */
  836. addDestory(cb: () => void): void;
  837. /**
  838. * Always returns a boolean, does not throw.
  839. */
  840. access(p: string): Promise<boolean>;
  841. /**
  842. * SYNC! Always returns a boolean, does not throw.
  843. */
  844. accessSync(p: string): boolean;
  845. applyGlobalPatch?(fromDir: string): Promise<void>;
  846. applyPrerenderGlobalPatch?(opts: {
  847. devServerHostUrl: string;
  848. window: any;
  849. }): void;
  850. cacheStorage?: CacheStorage;
  851. checkVersion?: (logger: Logger, currentVersion: string) => Promise<() => void>;
  852. copy?(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
  853. /**
  854. * Always returns a boolean if the files were copied or not. Does not throw.
  855. */
  856. copyFile(src: string, dst: string): Promise<boolean>;
  857. /**
  858. * Used to destroy any listeners, file watchers or child processes.
  859. */
  860. destroy(): Promise<void>;
  861. /**
  862. * Does not throw.
  863. */
  864. createDir(p: string, opts?: CompilerSystemCreateDirectoryOptions): Promise<CompilerSystemCreateDirectoryResults>;
  865. /**
  866. * SYNC! Does not throw.
  867. */
  868. createDirSync(p: string, opts?: CompilerSystemCreateDirectoryOptions): CompilerSystemCreateDirectoryResults;
  869. homeDir(): string;
  870. /**
  871. * Used to determine if the current context of the terminal is TTY.
  872. */
  873. isTTY(): boolean;
  874. /**
  875. * Each platform as a different way to dynamically import modules.
  876. */
  877. dynamicImport?(p: string): Promise<any>;
  878. /**
  879. * Creates the worker controller for the current system.
  880. */
  881. createWorkerController?(maxConcurrentWorkers: number): WorkerMainController;
  882. encodeToBase64(str: string): string;
  883. ensureDependencies?(opts: {
  884. rootDir: string;
  885. logger: Logger;
  886. dependencies: CompilerDependency[];
  887. }): Promise<{
  888. stencilPath: string;
  889. diagnostics: Diagnostic[];
  890. }>;
  891. ensureResources?(opts: {
  892. rootDir: string;
  893. logger: Logger;
  894. dependencies: CompilerDependency[];
  895. }): Promise<void>;
  896. /**
  897. * process.exit()
  898. */
  899. exit(exitCode: number): Promise<void>;
  900. /**
  901. * Optionally provide a fetch() function rather than using the built-in fetch().
  902. * First arg is a url string or Request object (RequestInfo).
  903. * Second arg is the RequestInit. Returns the Response object
  904. */
  905. fetch?(input: string | any, init?: any): Promise<any>;
  906. /**
  907. * Generates a sha1 digest encoded as HEX
  908. */
  909. generateContentHash?(content: string | any, length?: number): Promise<string>;
  910. /**
  911. * Generates a sha1 digest encoded as HEX from a file path
  912. */
  913. generateFileHash?(filePath: string | any, length?: number): Promise<string>;
  914. /**
  915. * Get the current directory.
  916. */
  917. getCurrentDirectory(): string;
  918. /**
  919. * The compiler's executing path.
  920. */
  921. getCompilerExecutingPath(): string;
  922. /**
  923. * The dev server's executing path.
  924. */
  925. getDevServerExecutingPath?(): string;
  926. getEnvironmentVar?(key: string): string;
  927. /**
  928. * Gets the absolute file path when for a dependency module.
  929. */
  930. getLocalModulePath(opts: {
  931. rootDir: string;
  932. moduleId: string;
  933. path: string;
  934. }): string;
  935. /**
  936. * Gets the full url when requesting a dependency module to fetch from a CDN.
  937. */
  938. getRemoteModuleUrl(opts: {
  939. moduleId: string;
  940. path?: string;
  941. version?: string;
  942. }): string;
  943. /**
  944. * Aync glob task. Only available in NodeJS compiler system.
  945. */
  946. glob?(pattern: string, options: {
  947. cwd?: string;
  948. nodir?: boolean;
  949. [key: string]: any;
  950. }): Promise<string[]>;
  951. /**
  952. * The number of logical processors available to run threads on the user's computer (cpus).
  953. */
  954. hardwareConcurrency: number;
  955. /**
  956. * Tests if the path is a symbolic link or not. Always resolves a boolean. Does not throw.
  957. */
  958. isSymbolicLink(p: string): Promise<boolean>;
  959. lazyRequire?: LazyRequire;
  960. nextTick(cb: () => void): void;
  961. /**
  962. * Normalize file system path.
  963. */
  964. normalizePath(p: string): string;
  965. onProcessInterrupt?(cb: () => void): void;
  966. parseYarnLockFile?: (content: string) => {
  967. type: 'success' | 'merge' | 'conflict';
  968. object: any;
  969. };
  970. platformPath: PlatformPath;
  971. /**
  972. * All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
  973. */
  974. readDir(p: string): Promise<string[]>;
  975. /**
  976. * SYNC! All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
  977. */
  978. readDirSync(p: string): string[];
  979. /**
  980. * Returns undefined if file is not found. Does not throw.
  981. */
  982. readFile(p: string): Promise<string>;
  983. readFile(p: string, encoding: 'utf8'): Promise<string>;
  984. readFile(p: string, encoding: 'binary'): Promise<any>;
  985. /**
  986. * SYNC! Returns undefined if file is not found. Does not throw.
  987. */
  988. readFileSync(p: string, encoding?: string): string;
  989. /**
  990. * Does not throw.
  991. */
  992. realpath(p: string): Promise<CompilerSystemRealpathResults>;
  993. /**
  994. * SYNC! Does not throw.
  995. */
  996. realpathSync(p: string): CompilerSystemRealpathResults;
  997. /**
  998. * Remove a callback which will be ran when destroy() is called.
  999. */
  1000. removeDestory(cb: () => void): void;
  1001. /**
  1002. * Rename old path to new path. Does not throw.
  1003. */
  1004. rename(oldPath: string, newPath: string): Promise<CompilerSystemRenameResults>;
  1005. resolveModuleId?(opts: ResolveModuleIdOptions): Promise<ResolveModuleIdResults>;
  1006. resolvePath(p: string): string;
  1007. /**
  1008. * Does not throw.
  1009. */
  1010. removeDir(p: string, opts?: CompilerSystemRemoveDirectoryOptions): Promise<CompilerSystemRemoveDirectoryResults>;
  1011. /**
  1012. * SYNC! Does not throw.
  1013. */
  1014. removeDirSync(p: string, opts?: CompilerSystemRemoveDirectoryOptions): CompilerSystemRemoveDirectoryResults;
  1015. /**
  1016. * Does not throw.
  1017. */
  1018. removeFile(p: string): Promise<CompilerSystemRemoveFileResults>;
  1019. /**
  1020. * SYNC! Does not throw.
  1021. */
  1022. removeFileSync(p: string): CompilerSystemRemoveFileResults;
  1023. setupCompiler?: (c: {
  1024. ts: any;
  1025. }) => void;
  1026. /**
  1027. * Always returns an object. Does not throw. Check for "error" property if there's an error.
  1028. */
  1029. stat(p: string): Promise<CompilerFsStats>;
  1030. /**
  1031. * SYNC! Always returns an object. Does not throw. Check for "error" property if there's an error.
  1032. */
  1033. statSync(p: string): CompilerFsStats;
  1034. tmpDirSync(): string;
  1035. watchDirectory?(p: string, callback: CompilerFileWatcherCallback, recursive?: boolean): CompilerFileWatcher;
  1036. watchFile?(p: string, callback: CompilerFileWatcherCallback): CompilerFileWatcher;
  1037. /**
  1038. * How many milliseconds to wait after a change before calling watch callbacks.
  1039. */
  1040. watchTimeout?: number;
  1041. /**
  1042. * Does not throw.
  1043. */
  1044. writeFile(p: string, content: string): Promise<CompilerSystemWriteFileResults>;
  1045. /**
  1046. * SYNC! Does not throw.
  1047. */
  1048. writeFileSync(p: string, content: string): CompilerSystemWriteFileResults;
  1049. }
  1050. export interface TranspileOnlyResults {
  1051. diagnostics: Diagnostic[];
  1052. output: string;
  1053. sourceMap: any;
  1054. }
  1055. export interface ParsedPath {
  1056. root: string;
  1057. dir: string;
  1058. base: string;
  1059. ext: string;
  1060. name: string;
  1061. }
  1062. export interface PlatformPath {
  1063. normalize(p: string): string;
  1064. join(...paths: string[]): string;
  1065. resolve(...pathSegments: string[]): string;
  1066. isAbsolute(p: string): boolean;
  1067. relative(from: string, to: string): string;
  1068. dirname(p: string): string;
  1069. basename(p: string, ext?: string): string;
  1070. extname(p: string): string;
  1071. parse(p: string): ParsedPath;
  1072. sep: string;
  1073. delimiter: string;
  1074. posix: any;
  1075. win32: any;
  1076. }
  1077. export interface CompilerDependency {
  1078. name: string;
  1079. version: string;
  1080. main: string;
  1081. resources?: string[];
  1082. }
  1083. export interface ResolveModuleIdOptions {
  1084. moduleId: string;
  1085. containingFile?: string;
  1086. exts?: string[];
  1087. packageFilter?: (pkg: any) => void;
  1088. }
  1089. export interface ResolveModuleIdResults {
  1090. moduleId: string;
  1091. resolveId: string;
  1092. pkgData: {
  1093. name: string;
  1094. version: string;
  1095. [key: string]: any;
  1096. };
  1097. pkgDirPath: string;
  1098. }
  1099. export interface WorkerMainController {
  1100. send(...args: any[]): Promise<any>;
  1101. handler(name: string): (...args: any[]) => Promise<any>;
  1102. destroy(): void;
  1103. maxWorkers: number;
  1104. }
  1105. export interface CopyResults {
  1106. diagnostics: Diagnostic[];
  1107. filePaths: string[];
  1108. dirPaths: string[];
  1109. }
  1110. export interface SystemDetails {
  1111. cpuModel: string;
  1112. freemem(): number;
  1113. platform: 'darwin' | 'windows' | 'linux' | '';
  1114. release: string;
  1115. totalmem: number;
  1116. }
  1117. export interface BuildOnEvents {
  1118. on(cb: (eventName: CompilerEventName, data: any) => void): BuildOnEventRemove;
  1119. on(eventName: CompilerEventFileAdd, cb: (path: string) => void): BuildOnEventRemove;
  1120. on(eventName: CompilerEventFileDelete, cb: (path: string) => void): BuildOnEventRemove;
  1121. on(eventName: CompilerEventFileUpdate, cb: (path: string) => void): BuildOnEventRemove;
  1122. on(eventName: CompilerEventDirAdd, cb: (path: string) => void): BuildOnEventRemove;
  1123. on(eventName: CompilerEventDirDelete, cb: (path: string) => void): BuildOnEventRemove;
  1124. on(eventName: CompilerEventBuildStart, cb: (buildStart: CompilerBuildStart) => void): BuildOnEventRemove;
  1125. on(eventName: CompilerEventBuildFinish, cb: (buildResults: CompilerBuildResults) => void): BuildOnEventRemove;
  1126. on(eventName: CompilerEventBuildLog, cb: (buildLog: BuildLog) => void): BuildOnEventRemove;
  1127. on(eventName: CompilerEventBuildNoChange, cb: () => void): BuildOnEventRemove;
  1128. }
  1129. export interface BuildEmitEvents {
  1130. emit(eventName: CompilerEventFileAdd, path: string): void;
  1131. emit(eventName: CompilerEventFileDelete, path: string): void;
  1132. emit(eventName: CompilerEventFileUpdate, path: string): void;
  1133. emit(eventName: CompilerEventDirAdd, path: string): void;
  1134. emit(eventName: CompilerEventDirDelete, path: string): void;
  1135. emit(eventName: CompilerEventBuildStart, buildStart: CompilerBuildStart): void;
  1136. emit(eventName: CompilerEventBuildFinish, buildResults: CompilerBuildResults): void;
  1137. emit(eventName: CompilerEventBuildNoChange, buildNoChange: BuildNoChangeResults): void;
  1138. emit(eventName: CompilerEventBuildLog, buildLog: BuildLog): void;
  1139. emit(eventName: CompilerEventFsChange, fsWatchResults: FsWatchResults): void;
  1140. }
  1141. export interface FsWatchResults {
  1142. dirsAdded: string[];
  1143. dirsDeleted: string[];
  1144. filesUpdated: string[];
  1145. filesAdded: string[];
  1146. filesDeleted: string[];
  1147. }
  1148. export interface BuildLog {
  1149. buildId: number;
  1150. messages: string[];
  1151. progress: number;
  1152. }
  1153. export interface BuildNoChangeResults {
  1154. buildId: number;
  1155. noChange: boolean;
  1156. }
  1157. export interface CompilerBuildResults {
  1158. buildId: number;
  1159. componentGraph?: BuildResultsComponentGraph;
  1160. diagnostics: Diagnostic[];
  1161. dirsAdded: string[];
  1162. dirsDeleted: string[];
  1163. duration: number;
  1164. filesAdded: string[];
  1165. filesChanged: string[];
  1166. filesDeleted: string[];
  1167. filesUpdated: string[];
  1168. hasError: boolean;
  1169. hasSuccessfulBuild: boolean;
  1170. hmr?: HotModuleReplacement;
  1171. hydrateAppFilePath?: string;
  1172. isRebuild: boolean;
  1173. namespace: string;
  1174. outputs: BuildOutput[];
  1175. rootDir: string;
  1176. srcDir: string;
  1177. timestamp: string;
  1178. }
  1179. export interface BuildResultsComponentGraph {
  1180. [scopeId: string]: string[];
  1181. }
  1182. export interface BuildOutput {
  1183. type: string;
  1184. files: string[];
  1185. }
  1186. export interface HotModuleReplacement {
  1187. componentsUpdated?: string[];
  1188. excludeHmr?: string[];
  1189. externalStylesUpdated?: string[];
  1190. imagesUpdated?: string[];
  1191. indexHtmlUpdated?: boolean;
  1192. inlineStylesUpdated?: HmrStyleUpdate[];
  1193. reloadStrategy: PageReloadStrategy;
  1194. scriptsAdded?: string[];
  1195. scriptsDeleted?: string[];
  1196. serviceWorkerUpdated?: boolean;
  1197. versionId?: string;
  1198. }
  1199. export interface HmrStyleUpdate {
  1200. styleId: string;
  1201. styleTag: string;
  1202. styleText: string;
  1203. }
  1204. export declare type BuildOnEventRemove = () => boolean;
  1205. export interface BuildEvents extends BuildOnEvents, BuildEmitEvents {
  1206. unsubscribeAll(): void;
  1207. }
  1208. export interface CompilerBuildStart {
  1209. buildId: number;
  1210. timestamp: string;
  1211. }
  1212. export declare type CompilerFileWatcherCallback = (fileName: string, eventKind: CompilerFileWatcherEvent) => void;
  1213. export declare type CompilerFileWatcherEvent = CompilerEventFileAdd | CompilerEventFileDelete | CompilerEventFileUpdate | CompilerEventDirAdd | CompilerEventDirDelete;
  1214. export declare type CompilerEventName = CompilerEventFsChange | CompilerEventFileUpdate | CompilerEventFileAdd | CompilerEventFileDelete | CompilerEventDirAdd | CompilerEventDirDelete | CompilerEventBuildStart | CompilerEventBuildFinish | CompilerEventBuildNoChange | CompilerEventBuildLog;
  1215. export declare type CompilerEventFsChange = 'fsChange';
  1216. export declare type CompilerEventFileUpdate = 'fileUpdate';
  1217. export declare type CompilerEventFileAdd = 'fileAdd';
  1218. export declare type CompilerEventFileDelete = 'fileDelete';
  1219. export declare type CompilerEventDirAdd = 'dirAdd';
  1220. export declare type CompilerEventDirDelete = 'dirDelete';
  1221. export declare type CompilerEventBuildStart = 'buildStart';
  1222. export declare type CompilerEventBuildFinish = 'buildFinish';
  1223. export declare type CompilerEventBuildLog = 'buildLog';
  1224. export declare type CompilerEventBuildNoChange = 'buildNoChange';
  1225. export interface CompilerFileWatcher {
  1226. close(): void | Promise<void>;
  1227. }
  1228. export interface CompilerFsStats {
  1229. /**
  1230. * If it's a directory. `false` if there was an error.
  1231. */
  1232. isDirectory: boolean;
  1233. /**
  1234. * If it's a file. `false` if there was an error.
  1235. */
  1236. isFile: boolean;
  1237. /**
  1238. * If it's a symlink. `false` if there was an error.
  1239. */
  1240. isSymbolicLink: boolean;
  1241. /**
  1242. * The size of the file in bytes. `0` for directories or if there was an error.
  1243. */
  1244. size: number;
  1245. /**
  1246. * The timestamp indicating the last time this file was modified expressed in milliseconds since the POSIX Epoch.
  1247. */
  1248. mtimeMs?: number;
  1249. /**
  1250. * Error if there was one, otherwise `null`. `stat` and `statSync` do not throw errors but always returns this interface.
  1251. */
  1252. error: any;
  1253. }
  1254. export interface CompilerSystemCreateDirectoryOptions {
  1255. /**
  1256. * Indicates whether parent directories should be created.
  1257. * @default false
  1258. */
  1259. recursive?: boolean;
  1260. /**
  1261. * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
  1262. * @default 0o777.
  1263. */
  1264. mode?: number;
  1265. }
  1266. export interface CompilerSystemCreateDirectoryResults {
  1267. basename: string;
  1268. dirname: string;
  1269. path: string;
  1270. newDirs: string[];
  1271. error: any;
  1272. }
  1273. export interface CompilerSystemRemoveDirectoryOptions {
  1274. /**
  1275. * Indicates whether child files and subdirectories should be removed.
  1276. * @default false
  1277. */
  1278. recursive?: boolean;
  1279. }
  1280. export interface CompilerSystemRemoveDirectoryResults {
  1281. basename: string;
  1282. dirname: string;
  1283. path: string;
  1284. removedDirs: string[];
  1285. removedFiles: string[];
  1286. error: any;
  1287. }
  1288. export interface CompilerSystemRenameResults extends CompilerSystemRenamedPath {
  1289. renamed: CompilerSystemRenamedPath[];
  1290. oldDirs: string[];
  1291. oldFiles: string[];
  1292. newDirs: string[];
  1293. newFiles: string[];
  1294. error: any;
  1295. }
  1296. export interface CompilerSystemRenamedPath {
  1297. oldPath: string;
  1298. newPath: string;
  1299. isFile: boolean;
  1300. isDirectory: boolean;
  1301. }
  1302. export interface CompilerSystemRealpathResults {
  1303. path: string;
  1304. error: any;
  1305. }
  1306. export interface CompilerSystemRemoveFileResults {
  1307. basename: string;
  1308. dirname: string;
  1309. path: string;
  1310. error: any;
  1311. }
  1312. export interface CompilerSystemWriteFileResults {
  1313. path: string;
  1314. error: any;
  1315. }
  1316. export interface Credentials {
  1317. key: string;
  1318. cert: string;
  1319. }
  1320. export interface ConfigBundle {
  1321. components: string[];
  1322. }
  1323. export interface CopyTask {
  1324. src: string;
  1325. dest?: string;
  1326. warn?: boolean;
  1327. keepDirStructure?: boolean;
  1328. }
  1329. export interface BundlingConfig {
  1330. namedExports?: {
  1331. [key: string]: string[];
  1332. };
  1333. }
  1334. export interface NodeResolveConfig {
  1335. module?: boolean;
  1336. jsnext?: boolean;
  1337. main?: boolean;
  1338. browser?: boolean;
  1339. extensions?: string[];
  1340. preferBuiltins?: boolean;
  1341. jail?: string;
  1342. only?: Array<string | RegExp>;
  1343. modulesOnly?: boolean;
  1344. /**
  1345. * @see https://github.com/browserify/resolve#resolveid-opts-cb
  1346. */
  1347. customResolveOptions?: {
  1348. basedir?: string;
  1349. package?: string;
  1350. extensions?: string[];
  1351. readFile?: Function;
  1352. isFile?: Function;
  1353. isDirectory?: Function;
  1354. packageFilter?: Function;
  1355. pathFilter?: Function;
  1356. paths?: Function | string[];
  1357. moduleDirectory?: string | string[];
  1358. preserveSymlinks?: boolean;
  1359. };
  1360. }
  1361. export interface RollupConfig {
  1362. inputOptions?: RollupInputOptions;
  1363. outputOptions?: RollupOutputOptions;
  1364. }
  1365. export interface RollupInputOptions {
  1366. context?: string;
  1367. moduleContext?: ((id: string) => string) | {
  1368. [id: string]: string;
  1369. };
  1370. treeshake?: boolean;
  1371. }
  1372. export interface RollupOutputOptions {
  1373. globals?: {
  1374. [name: string]: string;
  1375. } | ((name: string) => string);
  1376. }
  1377. export interface Testing {
  1378. run(opts: TestingRunOptions): Promise<boolean>;
  1379. destroy(): Promise<void>;
  1380. }
  1381. export interface TestingRunOptions {
  1382. e2e?: boolean;
  1383. screenshot?: boolean;
  1384. spec?: boolean;
  1385. updateScreenshot?: boolean;
  1386. }
  1387. export interface JestConfig {
  1388. /**
  1389. * This option tells Jest that all imported modules in your tests should be mocked automatically.
  1390. * All modules used in your tests will have a replacement implementation, keeping the API surface. Default: false
  1391. */
  1392. automock?: boolean;
  1393. /**
  1394. * By default, Jest runs all tests and produces all errors into the console upon completion.
  1395. * The bail config option can be used here to have Jest stop running tests after the first failure. Default: false
  1396. */
  1397. bail?: boolean;
  1398. /**
  1399. * The directory where Jest should store its cached dependency information. Jest attempts to scan your dependency tree once (up-front)
  1400. * and cache it in order to ease some of the filesystem raking that needs to happen while running tests. This config option lets you
  1401. * customize where Jest stores that cache data on disk. Default: "/tmp/<path>"
  1402. */
  1403. cacheDirectory?: string;
  1404. /**
  1405. * Automatically clear mock calls and instances between every test. Equivalent to calling jest.clearAllMocks()
  1406. * between each test. This does not remove any mock implementation that may have been provided. Default: false
  1407. */
  1408. clearMocks?: boolean;
  1409. /**
  1410. * Indicates whether the coverage information should be collected while executing the test. Because this retrofits all
  1411. * executed files with coverage collection statements, it may significantly slow down your tests. Default: false
  1412. */
  1413. collectCoverage?: boolean;
  1414. /**
  1415. * An array of glob patterns indicating a set of files for which coverage information should be collected.
  1416. * If a file matches the specified glob pattern, coverage information will be collected for it even if no tests exist
  1417. * for this file and it's never required in the test suite. Default: undefined
  1418. */
  1419. collectCoverageFrom?: any[];
  1420. /**
  1421. * The directory where Jest should output its coverage files. Default: undefined
  1422. */
  1423. coverageDirectory?: string;
  1424. /**
  1425. * An array of regexp pattern strings that are matched against all file paths before executing the test. If the file path matches
  1426. * any of the patterns, coverage information will be skipped. These pattern strings match against the full path.
  1427. * Use the <rootDir> string token to include the path to your project's root directory to prevent it from accidentally
  1428. * ignoring all of your files in different environments that may have different root directories.
  1429. * Example: ["<rootDir>/build/", "<rootDir>/node_modules/"]. Default: ["/node_modules/"]
  1430. */
  1431. coveragePathIgnorePatterns?: any[];
  1432. /**
  1433. * A list of reporter names that Jest uses when writing coverage reports. Any istanbul reporter can be used.
  1434. * Default: ["json", "lcov", "text"]
  1435. */
  1436. coverageReporters?: any[];
  1437. /**
  1438. * This will be used to configure minimum threshold enforcement for coverage results. Thresholds can be specified as global,
  1439. * as a glob, and as a directory or file path. If thresholds aren't met, jest will fail. Thresholds specified as a positive
  1440. * number are taken to be the minimum percentage required. Thresholds specified as a negative number represent the maximum
  1441. * number of uncovered entities allowed. Default: undefined
  1442. */
  1443. coverageThreshold?: any;
  1444. errorOnDeprecated?: boolean;
  1445. forceCoverageMatch?: any[];
  1446. globals?: any;
  1447. globalSetup?: string;
  1448. globalTeardown?: string;
  1449. /**
  1450. * An array of directory names to be searched recursively up from the requiring module's location. Setting this option will
  1451. * override the default, if you wish to still search node_modules for packages include it along with any other
  1452. * options: ["node_modules", "bower_components"]. Default: ["node_modules"]
  1453. */
  1454. moduleDirectories?: string[];
  1455. /**
  1456. * An array of file extensions your modules use. If you require modules without specifying a file extension,
  1457. * these are the extensions Jest will look for. Default: ['ts', 'tsx', 'js', 'json']
  1458. */
  1459. moduleFileExtensions?: string[];
  1460. moduleNameMapper?: any;
  1461. modulePaths?: any[];
  1462. modulePathIgnorePatterns?: any[];
  1463. notify?: boolean;
  1464. notifyMode?: string;
  1465. preset?: string;
  1466. prettierPath?: string;
  1467. projects?: any;
  1468. reporters?: any;
  1469. resetMocks?: boolean;
  1470. resetModules?: boolean;
  1471. resolver?: string;
  1472. restoreMocks?: string;
  1473. rootDir?: string;
  1474. roots?: any[];
  1475. runner?: string;
  1476. /**
  1477. * The paths to modules that run some code to configure or set up the testing environment before each test.
  1478. * Since every test runs in its own environment, these scripts will be executed in the testing environment
  1479. * immediately before executing the test code itself. Default: []
  1480. */
  1481. setupFiles?: string[];
  1482. setupFilesAfterEnv?: string[];
  1483. snapshotSerializers?: any[];
  1484. testEnvironment?: string;
  1485. testEnvironmentOptions?: any;
  1486. testMatch?: string[];
  1487. testPathIgnorePatterns?: string[];
  1488. testPreset?: string;
  1489. testRegex?: string;
  1490. testResultsProcessor?: string;
  1491. testRunner?: string;
  1492. testURL?: string;
  1493. timers?: string;
  1494. transform?: {
  1495. [key: string]: string;
  1496. };
  1497. transformIgnorePatterns?: any[];
  1498. unmockedModulePathPatterns?: any[];
  1499. verbose?: boolean;
  1500. watchPathIgnorePatterns?: any[];
  1501. }
  1502. export interface TestingConfig extends JestConfig {
  1503. /**
  1504. * The `allowableMismatchedPixels` value is used to determine an acceptable
  1505. * number of pixels that can be mismatched before the image is considered
  1506. * to have changes. Realistically, two screenshots representing the same
  1507. * content may have a small number of pixels that are not identical due to
  1508. * anti-aliasing, which is perfectly normal. If the `allowableMismatchedRatio`
  1509. * is provided it will take precedence, otherwise `allowableMismatchedPixels`
  1510. * will be used.
  1511. */
  1512. allowableMismatchedPixels?: number;
  1513. /**
  1514. * The `allowableMismatchedRatio` ranges from `0` to `1` and is used to
  1515. * determine an acceptable ratio of pixels that can be mismatched before
  1516. * the image is considered to have changes. Realistically, two screenshots
  1517. * representing the same content may have a small number of pixels that
  1518. * are not identical due to anti-aliasing, which is perfectly normal. The
  1519. * `allowableMismatchedRatio` is the number of pixels that were mismatched,
  1520. * divided by the total number of pixels in the screenshot. For example,
  1521. * a ratio value of `0.06` means 6% of the pixels can be mismatched before
  1522. * the image is considered to have changes. If the `allowableMismatchedRatio`
  1523. * is provided it will take precedence, otherwise `allowableMismatchedPixels`
  1524. * will be used.
  1525. */
  1526. allowableMismatchedRatio?: number;
  1527. /**
  1528. * Matching threshold while comparing two screenshots. Value ranges from `0` to `1`.
  1529. * Smaller values make the comparison more sensitive. The `pixelmatchThreshold`
  1530. * value helps to ignore anti-aliasing. Default: `0.1`
  1531. */
  1532. pixelmatchThreshold?: number;
  1533. /**
  1534. * Additional arguments to pass to the browser instance.
  1535. */
  1536. browserArgs?: string[];
  1537. /**
  1538. * Path to a Chromium or Chrome executable to run instead of the bundled Chromium.
  1539. */
  1540. browserExecutablePath?: string;
  1541. /**
  1542. * Url of remote Chrome instance to use instead of local Chrome.
  1543. */
  1544. browserWSEndpoint?: string;
  1545. /**
  1546. * Whether to run browser e2e tests in headless mode. Defaults to true.
  1547. */
  1548. browserHeadless?: boolean;
  1549. /**
  1550. * Slows down e2e browser operations by the specified amount of milliseconds.
  1551. * Useful so that you can see what is going on.
  1552. */
  1553. browserSlowMo?: number;
  1554. /**
  1555. * By default, all E2E pages wait until the "load" event, this global setting can be used
  1556. * to change the default `waitUntil` behavior.
  1557. */
  1558. browserWaitUntil?: 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';
  1559. /**
  1560. * Whether to auto-open a DevTools panel for each tab.
  1561. * If this option is true, the headless option will be set false
  1562. */
  1563. browserDevtools?: boolean;
  1564. /**
  1565. * Array of browser emulations to be using during e2e tests. A full e2e
  1566. * test is ran for each emulation.
  1567. */
  1568. emulate?: EmulateConfig[];
  1569. /**
  1570. * Path to the Screenshot Connector module.
  1571. */
  1572. screenshotConnector?: string;
  1573. /**
  1574. * Amount of time in milliseconds to wait before a screenshot is taken.
  1575. */
  1576. waitBeforeScreenshot?: number;
  1577. }
  1578. export interface EmulateConfig {
  1579. /**
  1580. * Predefined device descriptor name, such as "iPhone X" or "Nexus 10".
  1581. * For a complete list please see: https://github.com/puppeteer/puppeteer/blob/main/src/common/DeviceDescriptors.ts
  1582. */
  1583. device?: string;
  1584. /**
  1585. * User-Agent to be used. Defaults to the user-agent of the installed Puppeteer version.
  1586. */
  1587. userAgent?: string;
  1588. viewport?: EmulateViewport;
  1589. }
  1590. export interface EmulateViewport {
  1591. /**
  1592. * Page width in pixels.
  1593. */
  1594. width: number;
  1595. /**
  1596. * page height in pixels.
  1597. */
  1598. height: number;
  1599. /**
  1600. * Specify device scale factor (can be thought of as dpr). Defaults to 1.
  1601. */
  1602. deviceScaleFactor?: number;
  1603. /**
  1604. * Whether the meta viewport tag is taken into account. Defaults to false.
  1605. */
  1606. isMobile?: boolean;
  1607. /**
  1608. * Specifies if viewport supports touch events. Defaults to false
  1609. */
  1610. hasTouch?: boolean;
  1611. /**
  1612. * Specifies if viewport is in landscape mode. Defaults to false.
  1613. */
  1614. isLandscape?: boolean;
  1615. }
  1616. export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error' | string;
  1617. /**
  1618. * Common logger to be used by the compiler, dev-server and CLI. The CLI will use a
  1619. * NodeJS based console logging and colors, and the web will use browser based
  1620. * logs and colors.
  1621. */
  1622. export interface Logger {
  1623. enableColors: (useColors: boolean) => void;
  1624. setLevel: (level: LogLevel) => void;
  1625. getLevel: () => LogLevel;
  1626. debug: (...msg: any[]) => void;
  1627. info: (...msg: any[]) => void;
  1628. warn: (...msg: any[]) => void;
  1629. error: (...msg: any[]) => void;
  1630. createTimeSpan: (startMsg: string, debug?: boolean, appendTo?: string[]) => LoggerTimeSpan;
  1631. printDiagnostics: (diagnostics: Diagnostic[], cwd?: string) => void;
  1632. red: (msg: string) => string;
  1633. green: (msg: string) => string;
  1634. yellow: (msg: string) => string;
  1635. blue: (msg: string) => string;
  1636. magenta: (msg: string) => string;
  1637. cyan: (msg: string) => string;
  1638. gray: (msg: string) => string;
  1639. bold: (msg: string) => string;
  1640. dim: (msg: string) => string;
  1641. bgRed: (msg: string) => string;
  1642. emoji: (e: string) => string;
  1643. setLogFilePath?: (p: string) => void;
  1644. writeLogs?: (append: boolean) => void;
  1645. createLineUpdater?: () => Promise<LoggerLineUpdater>;
  1646. }
  1647. export interface LoggerLineUpdater {
  1648. update(text: string): Promise<void>;
  1649. stop(): Promise<void>;
  1650. }
  1651. export interface LoggerTimeSpan {
  1652. duration(): number;
  1653. finish(finishedMsg: string, color?: string, bold?: boolean, newLineSuffix?: boolean): number;
  1654. }
  1655. export interface OutputTargetDist extends OutputTargetBase {
  1656. type: 'dist';
  1657. buildDir?: string;
  1658. dir?: string;
  1659. collectionDir?: string | null;
  1660. typesDir?: string;
  1661. esmLoaderPath?: string;
  1662. copy?: CopyTask[];
  1663. polyfills?: boolean;
  1664. empty?: boolean;
  1665. }
  1666. export interface OutputTargetDistCollection extends OutputTargetBase {
  1667. type: 'dist-collection';
  1668. dir: string;
  1669. collectionDir: string;
  1670. }
  1671. export interface OutputTargetDistTypes extends OutputTargetBase {
  1672. type: 'dist-types';
  1673. dir: string;
  1674. typesDir: string;
  1675. }
  1676. export interface OutputTargetDistLazy extends OutputTargetBase {
  1677. type: 'dist-lazy';
  1678. dir?: string;
  1679. esmDir?: string;
  1680. esmEs5Dir?: string;
  1681. systemDir?: string;
  1682. cjsDir?: string;
  1683. polyfills?: boolean;
  1684. isBrowserBuild?: boolean;
  1685. esmIndexFile?: string;
  1686. cjsIndexFile?: string;
  1687. systemLoaderFile?: string;
  1688. empty?: boolean;
  1689. }
  1690. export interface OutputTargetDistGlobalStyles extends OutputTargetBase {
  1691. type: 'dist-global-styles';
  1692. file: string;
  1693. }
  1694. export interface OutputTargetDistLazyLoader extends OutputTargetBase {
  1695. type: 'dist-lazy-loader';
  1696. dir: string;
  1697. esmDir: string;
  1698. esmEs5Dir: string;
  1699. cjsDir: string;
  1700. componentDts: string;
  1701. empty: boolean;
  1702. }
  1703. export interface OutputTargetHydrate extends OutputTargetBase {
  1704. type: 'dist-hydrate-script';
  1705. dir?: string;
  1706. /**
  1707. * Module IDs that should not be bundled into the script.
  1708. * By default, all node builtin's, such as `fs` or `path`
  1709. * will be considered "external" and not bundled.
  1710. */
  1711. external?: string[];
  1712. empty?: boolean;
  1713. }
  1714. export interface OutputTargetCustom extends OutputTargetBase {
  1715. type: 'custom';
  1716. name: string;
  1717. validate?: (config: Config, diagnostics: Diagnostic[]) => void;
  1718. generator: (config: Config, compilerCtx: any, buildCtx: any, docs: any) => Promise<void>;
  1719. copy?: CopyTask[];
  1720. }
  1721. export interface OutputTargetDocsVscode extends OutputTargetBase {
  1722. type: 'docs-vscode';
  1723. file: string;
  1724. sourceCodeBaseUrl?: string;
  1725. }
  1726. export interface OutputTargetDocsReadme extends OutputTargetBase {
  1727. type: 'docs-readme';
  1728. dir?: string;
  1729. dependencies?: boolean;
  1730. footer?: string;
  1731. strict?: boolean;
  1732. }
  1733. export interface OutputTargetDocsJson extends OutputTargetBase {
  1734. type: 'docs-json';
  1735. file: string;
  1736. typesFile?: string | null;
  1737. strict?: boolean;
  1738. }
  1739. export interface OutputTargetDocsCustom extends OutputTargetBase {
  1740. type: 'docs-custom';
  1741. generator: (docs: JsonDocs, config: Config) => void | Promise<void>;
  1742. strict?: boolean;
  1743. }
  1744. export interface OutputTargetStats extends OutputTargetBase {
  1745. type: 'stats';
  1746. file?: string;
  1747. }
  1748. export interface OutputTargetBaseNext {
  1749. type: string;
  1750. dir?: string;
  1751. }
  1752. export interface OutputTargetDistCustomElements extends OutputTargetBaseNext {
  1753. type: 'dist-custom-elements';
  1754. empty?: boolean;
  1755. externalRuntime?: boolean;
  1756. copy?: CopyTask[];
  1757. inlineDynamicImports?: boolean;
  1758. includeGlobalScripts?: boolean;
  1759. minify?: boolean;
  1760. /**
  1761. * Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
  1762. * functionality allows consumers to bypass the explicit call to define a component, its children, its children's
  1763. * children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
  1764. */
  1765. autoDefineCustomElements?: boolean;
  1766. /**
  1767. * Enables the generation of type definition files for the output target.
  1768. */
  1769. generateTypeDeclarations?: boolean;
  1770. }
  1771. export interface OutputTargetDistCustomElementsBundle extends OutputTargetBaseNext {
  1772. type: 'dist-custom-elements-bundle';
  1773. empty?: boolean;
  1774. externalRuntime?: boolean;
  1775. copy?: CopyTask[];
  1776. inlineDynamicImports?: boolean;
  1777. includeGlobalScripts?: boolean;
  1778. minify?: boolean;
  1779. }
  1780. export interface OutputTargetBase {
  1781. type: string;
  1782. }
  1783. export declare type OutputTargetBuild = OutputTargetDistCollection | OutputTargetDistLazy;
  1784. export interface OutputTargetAngular extends OutputTargetBase {
  1785. type: 'angular';
  1786. componentCorePackage: string;
  1787. directivesProxyFile?: string;
  1788. directivesArrayFile?: string;
  1789. directivesUtilsFile?: string;
  1790. excludeComponents?: string[];
  1791. }
  1792. export interface OutputTargetCopy extends OutputTargetBase {
  1793. type: 'copy';
  1794. dir: string;
  1795. copy?: CopyTask[];
  1796. copyAssets?: 'collection' | 'dist';
  1797. }
  1798. export interface OutputTargetWww extends OutputTargetBase {
  1799. /**
  1800. * Webapp output target.
  1801. */
  1802. type: 'www';
  1803. /**
  1804. * The directory to write the app's JavaScript and CSS build
  1805. * files to. The default is to place this directory as a child
  1806. * to the `dir` config. Default: `build`
  1807. */
  1808. buildDir?: string;
  1809. /**
  1810. * The directory to write the entire application to.
  1811. * Note, the `buildDir` is where the app's JavaScript and CSS build
  1812. * files are written. Default: `www`
  1813. */
  1814. dir?: string;
  1815. /**
  1816. * Empty the build directory of all files and directories on first build.
  1817. * Default: `true`
  1818. */
  1819. empty?: boolean;
  1820. /**
  1821. * The default index html file of the app, commonly found at the
  1822. * root of the `src` directory.
  1823. * Default: `index.html`
  1824. */
  1825. indexHtml?: string;
  1826. /**
  1827. * The copy config is an array of objects that defines any files or folders that should
  1828. * be copied over to the build directory.
  1829. *
  1830. * Each object in the array must include a src property which can be either an absolute path,
  1831. * a relative path or a glob pattern. The config can also provide an optional dest property
  1832. * which can be either an absolute path or a path relative to the build directory.
  1833. * Also note that any files within src/assets are automatically copied to www/assets for convenience.
  1834. *
  1835. * In the copy config below, it will copy the entire directory from src/docs-content over to www/docs-content.
  1836. */
  1837. copy?: CopyTask[];
  1838. /**
  1839. * The base url of the app, it's required during prerendering to be the absolute path
  1840. * of your app, such as: `https://my.app.com/app`.
  1841. *
  1842. * Default: `/`
  1843. */
  1844. baseUrl?: string;
  1845. /**
  1846. * By default, stencil will include all the polyfills required by legacy browsers in the ES5 build.
  1847. * If it's `false`, stencil will not emit this polyfills anymore and it's your responsibility to provide them before
  1848. * stencil initializes.
  1849. */
  1850. polyfills?: boolean;
  1851. /**
  1852. * Path to an external node module which has exports of the prerender config object.
  1853. * ```
  1854. * module.exports = {
  1855. * afterHydrate(document, url) {
  1856. * document.title = `URL: ${url.href}`;
  1857. * }
  1858. * }
  1859. * ```
  1860. */
  1861. prerenderConfig?: string;
  1862. /**
  1863. * Service worker config for production builds. During development builds
  1864. * service worker script will be injected to automatically unregister existing
  1865. * service workers. When set to `false` neither a service worker registration
  1866. * or unregistration will be added to the index.html.
  1867. */
  1868. serviceWorker?: ServiceWorkerConfig | null | false;
  1869. appDir?: string;
  1870. }
  1871. export declare type OutputTarget = OutputTargetAngular | OutputTargetCopy | OutputTargetCustom | OutputTargetDist | OutputTargetDistCollection | OutputTargetDistCustomElements | OutputTargetDistCustomElementsBundle | OutputTargetDistLazy | OutputTargetDistGlobalStyles | OutputTargetDistLazyLoader | OutputTargetDocsJson | OutputTargetDocsCustom | OutputTargetDocsReadme | OutputTargetDocsVscode | OutputTargetWww | OutputTargetHydrate | OutputTargetStats | OutputTargetDistTypes;
  1872. export interface ServiceWorkerConfig {
  1873. unregister?: boolean;
  1874. swDest?: string;
  1875. swSrc?: string;
  1876. globPatterns?: string[];
  1877. globDirectory?: string | string[];
  1878. globIgnores?: string | string[];
  1879. templatedUrls?: any;
  1880. maximumFileSizeToCacheInBytes?: number;
  1881. manifestTransforms?: any;
  1882. modifyUrlPrefix?: any;
  1883. dontCacheBustURLsMatching?: RegExp;
  1884. navigateFallback?: string;
  1885. navigateFallbackWhitelist?: RegExp[];
  1886. navigateFallbackBlacklist?: RegExp[];
  1887. cacheId?: string;
  1888. skipWaiting?: boolean;
  1889. clientsClaim?: boolean;
  1890. directoryIndex?: string;
  1891. runtimeCaching?: any[];
  1892. ignoreUrlParametersMatching?: any[];
  1893. handleFetch?: boolean;
  1894. }
  1895. export interface LoadConfigInit {
  1896. /**
  1897. * User config object to merge into default config and
  1898. * config loaded from a file path.
  1899. */
  1900. config?: Config;
  1901. /**
  1902. * Absolute path to a Stencil config file. This path cannot be
  1903. * relative and it does not resolve config files within a directory.
  1904. */
  1905. configPath?: string;
  1906. logger?: Logger;
  1907. sys?: CompilerSystem;
  1908. /**
  1909. * When set to true, if the "tsconfig.json" file is not found
  1910. * it'll automatically generate and save a default tsconfig
  1911. * within the root directory.
  1912. */
  1913. initTsConfig?: boolean;
  1914. }
  1915. export interface LoadConfigResults {
  1916. config: Config;
  1917. diagnostics: Diagnostic[];
  1918. tsconfig: {
  1919. path: string;
  1920. compilerOptions: any;
  1921. files: string[];
  1922. include: string[];
  1923. exclude: string[];
  1924. extends: string;
  1925. };
  1926. }
  1927. export interface Diagnostic {
  1928. level: 'error' | 'warn' | 'info' | 'log' | 'debug';
  1929. type: string;
  1930. header?: string;
  1931. language?: string;
  1932. messageText: string;
  1933. debugText?: string;
  1934. code?: string;
  1935. absFilePath?: string;
  1936. relFilePath?: string;
  1937. lineNumber?: number;
  1938. columnNumber?: number;
  1939. lines?: {
  1940. lineIndex: number;
  1941. lineNumber: number;
  1942. text?: string;
  1943. errorCharStart: number;
  1944. errorLength?: number;
  1945. }[];
  1946. }
  1947. export interface CacheStorage {
  1948. get(key: string): Promise<any>;
  1949. set(key: string, value: any): Promise<void>;
  1950. }
  1951. export interface WorkerOptions {
  1952. maxConcurrentWorkers?: number;
  1953. maxConcurrentTasksPerWorker?: number;
  1954. logger?: Logger;
  1955. }
  1956. export interface RollupInterface {
  1957. rollup: {
  1958. (config: any): Promise<any>;
  1959. };
  1960. plugins: {
  1961. nodeResolve(opts: any): any;
  1962. replace(opts: any): any;
  1963. commonjs(opts: any): any;
  1964. json(): any;
  1965. };
  1966. }
  1967. export interface ResolveModuleOptions {
  1968. manuallyResolve?: boolean;
  1969. packageJson?: boolean;
  1970. }
  1971. export interface PrerenderStartOptions {
  1972. buildId?: string;
  1973. hydrateAppFilePath: string;
  1974. componentGraph: BuildResultsComponentGraph;
  1975. srcIndexHtmlPath: string;
  1976. }
  1977. export interface PrerenderResults {
  1978. buildId: string;
  1979. diagnostics: Diagnostic[];
  1980. urls: number;
  1981. duration: number;
  1982. average: number;
  1983. }
  1984. export interface OptimizeCssInput {
  1985. input: string;
  1986. filePath?: string;
  1987. autoprefixer?: any;
  1988. minify?: boolean;
  1989. sourceMap?: boolean;
  1990. resolveUrl?: (url: string) => Promise<string> | string;
  1991. }
  1992. export interface OptimizeCssOutput {
  1993. output: string;
  1994. diagnostics: Diagnostic[];
  1995. }
  1996. export interface OptimizeJsInput {
  1997. input: string;
  1998. filePath?: string;
  1999. target?: 'es5' | 'latest';
  2000. pretty?: boolean;
  2001. sourceMap?: boolean;
  2002. }
  2003. export interface OptimizeJsOutput {
  2004. output: string;
  2005. sourceMap: any;
  2006. diagnostics: Diagnostic[];
  2007. }
  2008. export interface LazyRequire {
  2009. ensure(fromDir: string, moduleIds: string[]): Promise<Diagnostic[]>;
  2010. require(fromDir: string, moduleId: string): any;
  2011. getModulePath(fromDir: string, moduleId: string): string;
  2012. }
  2013. export interface FsWatcherItem {
  2014. close(): void;
  2015. }
  2016. export interface MakeDirectoryOptions {
  2017. /**
  2018. * Indicates whether parent folders should be created.
  2019. * @default false
  2020. */
  2021. recursive?: boolean;
  2022. /**
  2023. * A file mode. If a string is passed, it is parsed as an octal integer. If not specified
  2024. * @default 0o777.
  2025. */
  2026. mode?: number;
  2027. }
  2028. export interface FsStats {
  2029. isFile(): boolean;
  2030. isDirectory(): boolean;
  2031. isBlockDevice(): boolean;
  2032. isCharacterDevice(): boolean;
  2033. isSymbolicLink(): boolean;
  2034. isFIFO(): boolean;
  2035. isSocket(): boolean;
  2036. dev: number;
  2037. ino: number;
  2038. mode: number;
  2039. nlink: number;
  2040. uid: number;
  2041. gid: number;
  2042. rdev: number;
  2043. size: number;
  2044. blksize: number;
  2045. blocks: number;
  2046. atime: Date;
  2047. mtime: Date;
  2048. ctime: Date;
  2049. birthtime: Date;
  2050. }
  2051. export interface FsWriteOptions {
  2052. inMemoryOnly?: boolean;
  2053. clearFileCache?: boolean;
  2054. immediateWrite?: boolean;
  2055. useCache?: boolean;
  2056. outputTargetType?: string;
  2057. }
  2058. export interface Compiler {
  2059. build(): Promise<CompilerBuildResults>;
  2060. createWatcher(): Promise<CompilerWatcher>;
  2061. destroy(): Promise<void>;
  2062. sys: CompilerSystem;
  2063. }
  2064. export interface CompilerWatcher extends BuildOnEvents {
  2065. start: () => Promise<WatcherCloseResults>;
  2066. close: () => Promise<WatcherCloseResults>;
  2067. request: (data: CompilerRequest) => Promise<CompilerRequestResponse>;
  2068. }
  2069. export interface CompilerRequest {
  2070. path?: string;
  2071. }
  2072. export interface WatcherCloseResults {
  2073. exitCode: number;
  2074. }
  2075. export interface CompilerRequestResponse {
  2076. path: string;
  2077. nodeModuleId: string;
  2078. nodeModuleVersion: string;
  2079. nodeResolvedPath: string;
  2080. cachePath: string;
  2081. cacheHit: boolean;
  2082. content: string;
  2083. status: number;
  2084. }
  2085. export interface TranspileOptions {
  2086. /**
  2087. * A component can be defined as a custom element by using `customelement`, or the
  2088. * component class can be exported by using `module`. Default is `customelement`.
  2089. */
  2090. componentExport?: 'customelement' | 'module' | string | undefined;
  2091. /**
  2092. * Sets how and if component metadata should be assigned on the compiled
  2093. * component output. The `compilerstatic` value will set the metadata to
  2094. * a static `COMPILER_META` getter on the component class. This option
  2095. * is useful for unit testing preprocessors. Default is `null`.
  2096. */
  2097. componentMetadata?: 'runtimestatic' | 'compilerstatic' | string | undefined;
  2098. /**
  2099. * The actual internal import path for any `@stencil/core` imports.
  2100. * Default is `@stencil/core/internal/client`.
  2101. */
  2102. coreImportPath?: string;
  2103. /**
  2104. * The current working directory. Default is `/`.
  2105. */
  2106. currentDirectory?: string;
  2107. /**
  2108. * The filename of the code being compiled. Default is `module.tsx`.
  2109. */
  2110. file?: string;
  2111. /**
  2112. * Module format to use for the compiled code output, which can be either `esm` or `cjs`.
  2113. * Default is `esm`.
  2114. */
  2115. module?: 'cjs' | 'esm' | string;
  2116. /**
  2117. * Sets how and if any properties, methods and events are proxied on the
  2118. * component class. The `defineproperty` value sets the getters and setters
  2119. * using Object.defineProperty. Default is `defineproperty`.
  2120. */
  2121. proxy?: 'defineproperty' | string | undefined;
  2122. /**
  2123. * How component styles should be associated to the component. The `static`
  2124. * setting will assign the styles as a static getter on the component class.
  2125. */
  2126. style?: 'static' | string | undefined;
  2127. /**
  2128. * How style data should be added for imports. For example, the `queryparams` value
  2129. * adds the component's tagname and encapsulation info as querystring parameter
  2130. * to the style's import, such as `style.css?tag=my-tag&encapsulation=shadow`. This
  2131. * style data can be used by bundlers to further optimize each component's css.
  2132. * Set to `null` to not include the querystring parameters. Default is `queryparams`.
  2133. */
  2134. styleImportData?: 'queryparams' | string | undefined;
  2135. /**
  2136. * The JavaScript source target TypeScript should to transpile to. Values can be
  2137. * `latest`, `esnext`, `es2017`, `es2015`, or `es5`. Defaults to `latest`.
  2138. */
  2139. target?: CompileTarget;
  2140. /**
  2141. * Create a source map. Using `inline` will inline the source map into the
  2142. * code, otherwise the source map will be in the returned `map` property.
  2143. * Default is `true`.
  2144. */
  2145. sourceMap?: boolean | 'inline';
  2146. /**
  2147. * Base directory to resolve non-relative module names. Same as the `baseUrl`
  2148. * TypeScript compiler option: https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
  2149. */
  2150. baseUrl?: string;
  2151. /**
  2152. * List of path mapping entries for module names to locations relative to the `baseUrl`.
  2153. * Same as the `paths` TypeScript compiler option:
  2154. * https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping
  2155. */
  2156. paths?: {
  2157. [key: string]: string[];
  2158. };
  2159. /**
  2160. * Passed in Stencil Compiler System, otherwise falls back to the internal in-memory only system.
  2161. */
  2162. sys?: CompilerSystem;
  2163. }
  2164. export declare type CompileTarget = 'latest' | 'esnext' | 'es2020' | 'es2019' | 'es2018' | 'es2017' | 'es2015' | 'es5' | string | undefined;
  2165. export interface TranspileResults {
  2166. code: string;
  2167. data?: any[];
  2168. diagnostics: Diagnostic[];
  2169. imports?: {
  2170. path: string;
  2171. }[];
  2172. inputFileExtension: string;
  2173. inputFilePath: string;
  2174. map: any;
  2175. outputFilePath: string;
  2176. }
  2177. export interface TransformOptions {
  2178. coreImportPath: string;
  2179. componentExport: 'lazy' | 'module' | 'customelement' | null;
  2180. componentMetadata: 'runtimestatic' | 'compilerstatic' | null;
  2181. currentDirectory: string;
  2182. file?: string;
  2183. isolatedModules?: boolean;
  2184. module?: 'cjs' | 'esm';
  2185. proxy: 'defineproperty' | null;
  2186. style: 'static' | null;
  2187. styleImportData: 'queryparams' | null;
  2188. target?: string;
  2189. }
  2190. export interface CompileScriptMinifyOptions {
  2191. target?: CompileTarget;
  2192. pretty?: boolean;
  2193. }
  2194. export interface DevServer extends BuildEmitEvents {
  2195. address: string;
  2196. basePath: string;
  2197. browserUrl: string;
  2198. protocol: string;
  2199. port: number;
  2200. root: string;
  2201. close(): Promise<void>;
  2202. }
  2203. export interface CliInitOptions {
  2204. args: string[];
  2205. logger: Logger;
  2206. sys: CompilerSystem;
  2207. }