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

fix: Devtool flag inconsistencies #113

Merged
merged 3 commits into from Mar 17, 2024
Merged

fix: Devtool flag inconsistencies #113

merged 3 commits into from Mar 17, 2024

Conversation

rschristian
Copy link
Member

Non-breaking form of #112

devToolsEnabled becomes a derived value, formed of the user passed option, whether it's a prod build or not, and the user-passed devtoolsInProd option.

Still not sure about the devtools source, see below

src/devtools.ts Outdated
Comment on lines 61 to 66
if (entry === id && (!config.isProduction || injectInProd)) {
const source = injectInProd ? "preact/devtools" : "preact/debug";
if (entry === id && devToolsEnabled) {
const source = devtoolsInProd ? "preact/devtools" : "preact/debug";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why the source changes based upon whether devtoolsInProd is enabled or not. Is this correct? This seems wrong to me, but it's perfectly possible I'm missing something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During production you likely don't want the weight of preact/debug with all the warnings, just the devtools connection bridge. That's why the switch was originally introduced. The preact/devtools bridge is <200b .

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, I had it in my mind for some reason that devtools pulled in debug, not the other way around. Didn't even double check when confused.

My bad, cheers!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, I think this is a bit of a problem as it'd mean enabling it would cause problems with dev, no?

Will correct tomorrow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be correct now, will always provide 'preact/debug' in dev if devToolsEnabled is set to true/default, while in prod, you'll get 'preact/devtools' only if you've enabled devtoolsInProd.

@rschristian rschristian merged commit 08d0d8f into main Mar 17, 2024
1 check passed
@rschristian rschristian deleted the fix/devtools-opts branch March 17, 2024 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants