UNPKG

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