UNPKG

@embeddable.com/sdk-core

Version:

Core Embeddable SDK module responsible for web-components bundling and publishing.

35 lines (34 loc) 2.18 kB
import { CompilerWatcher } from "@stencil/core/compiler"; import { PluginName, ResolvedEmbeddableConfig } from "./defineConfig"; /** * Stencil watcher doesnt react on file metadata changes, * so we have to change the file content to trigger a rebuild by appending a space character. * This constant defines how many times the space character can be appended before the file is truncated back to its original size. */ export declare const TRIGGER_BUILD_ITERATION_LIMIT = 5; export declare function resetForTesting(): void; /** * Triggers a rebuild of a Stencil web component by modifying the `component.tsx` file. * * This function works by appending a space character to the file, which causes Stencil's watcher * to detect a change and rebuild the component. After every TRIGGER_BUILD_ITERATION_LIMIT rebuilds, the file is truncated back * to its original size to prevent indefinite growth and reset the internal rebuild counter. * * Append and truncate are used instead of rewriting the file to ensure minimal I/O overhead and preserve file metadata. */ export declare function triggerWebComponentRebuild(ctx: ResolvedEmbeddableConfig): Promise<void>; declare const _default: (ctx: ResolvedEmbeddableConfig, pluginName: PluginName) => Promise<void | CompilerWatcher>; export default _default; /** * Generates only the d.ts type declaration files using Stencil, without performing a full build. * Used in dev mode to pre-generate types before the watcher starts, avoiding a double-build * triggered by the watcher reacting to freshly generated d.ts files. * * Key differences from the default generate function: * - Writes an empty style.css stub (no real CSS injection needed for type generation) * - Injects a no-op render stub instead of the real render import * - Always creates a fresh sys (never reuses ctx.dev?.sys) to avoid watcher interference */ export declare function generateDTS(ctx: ResolvedEmbeddableConfig): Promise<void>; export declare function injectCSS(ctx: ResolvedEmbeddableConfig, pluginName: PluginName): Promise<void>; export declare function injectBundleRender(ctx: ResolvedEmbeddableConfig, pluginName: PluginName): Promise<void>;