UNPKG

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