diff --git a/src/cli/facade/dev.ts b/src/cli/facade/dev.ts index f2fda0f5..2b595874 100644 --- a/src/cli/facade/dev.ts +++ b/src/cli/facade/dev.ts @@ -204,6 +204,7 @@ const dev = ({ local, logger }: { logger: Logger; local: Local }) => hotReloading, liveReloadPort: liveReload.port, local: true, + enableComponentConsoleOutput: true, postRequestPayloadSize, components: opts.components, path: path.resolve(componentsDir), diff --git a/src/registry/domain/options-sanitiser.ts b/src/registry/domain/options-sanitiser.ts index 5c4a0d00..fa54eb0a 100644 --- a/src/registry/domain/options-sanitiser.ts +++ b/src/registry/domain/options-sanitiser.ts @@ -174,6 +174,10 @@ export default function optionsSanitiser(input: RegistryOptions): Config { options.tarExtractMode = 766; } + if (typeof options.enableComponentConsoleOutput === 'undefined') { + options.enableComponentConsoleOutput = false; + } + if ( typeof options.fallbackRegistryUrl !== 'undefined' && !options.fallbackRegistryUrl.endsWith('/') diff --git a/src/registry/routes/helpers/get-component.ts b/src/registry/routes/helpers/get-component.ts index cd7afe81..d68c6a23 100644 --- a/src/registry/routes/helpers/get-component.ts +++ b/src/registry/routes/helpers/get-component.ts @@ -676,7 +676,9 @@ export default function getComponent(conf: Config, repository: Repository) { exports: {} as Record any> }, exports: {} as Record any>, - console: conf.local ? console : noopConsole, + console: conf.enableComponentConsoleOutput + ? console + : noopConsole, setTimeout, Buffer, AbortController: globalThis?.AbortController, diff --git a/src/types.ts b/src/types.ts index 234f4d2e..279f2638 100644 --- a/src/types.ts +++ b/src/types.ts @@ -289,6 +289,14 @@ export interface Config { * system (`true`) or from the remote storage (`false`). */ local: boolean; + /** + * Enables component console output (console.log, console.error, etc.) + * during component execution. Useful for debugging in development and + * lower environments. + * + * @default false + */ + enableComponentConsoleOutput: boolean; /** * File and directory mode (octal) applied when extracting tarballs during * publishing.