Skip to content

Quiet version of $inspect for tree-shaking #17046

@mertalev

Description

@mertalev

Describe the problem

The ability to have dev-only code that is completely removed in production builds is a valuable tool beyond logging. To take advantage of this without logging, I can write:

$inspect(expensiveDebugAssertion()).with(() => {})

This works, but .with(() => {}) is clunky and the usage is not obvious either to the reader or to developers who could use this technique.

Describe the proposed solution

An $inspect.by variant would be an elegant solution with similar usage as $derived.by:

// accepts function with no parameters
$inspect.by(expensiveDebugAssertion)

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions