UNPKG

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