preactjs / preactjs/preact

conditional debug

Open
#3,894 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request
Dominant language
JavaScript
Stars
38.9k
Forks
2.4k
Avg merge
20h 18m
Merged PRs (30d)
35

Description

Describe the feature you'd love to see

I'd like to do something like if (myDevCondition) initDebug();, so I can have different output files where that condition is either true or false. I know I could do require('preact/debug'), but that wouldn't translate to pure esm, as it would mean I'd need to process the if out of the code, which currently isn't yet possible.

Maybe initDebug from preact/debug/src/debug.js could be exposed somehow?

Additional context (optional)

In my libraries I'm using preact as a dependency, so people don't necessarily import it themselves.

closest issue I find is https://github.com/preactjs/preact/issues/1746 which suggests to "just use require", which probably works on pages, but not really on libraries

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading preact/debug/src/debug.js and compare the proposed approach with issue #1746. Define how initDebug could be exposed for pure ESM consumers and library dependencies, then confirm that callers can produce different output files based on a development condition without requiring CommonJS processing.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.