Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conditional debug #3894

Open
Haroenv opened this issue Feb 14, 2023 · 2 comments
Open

conditional debug #3894

Haroenv opened this issue Feb 14, 2023 · 2 comments

Comments

@Haroenv
Copy link

Haroenv commented Feb 14, 2023

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 #1746 which suggests to "just use require", which probably works on pages, but not really on libraries

@rschristian
Copy link
Member

If you're happy to have multiple output files, why not configure your build tool (assuming you're using one) to inject import 'preact/debug'; into some/one of your output files?

@Haroenv
Copy link
Author

Haroenv commented Feb 15, 2023

Yes, that could indeed be one of the solutions. Most of our implementations indeed have multiple output files, especially in UMD, however the ESM version usually only has one file with conditionals à la process.env.NODE_ENV, for which I'm not really sure what the solution would be.

Thanks for your idea already!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants