10.0.0-alpha.0: preact/debug doesn't automatically get removed in production
See original GitHub issueIn Preact 8, the whole preact/debug
was wrapped in a process.env.NODE_ENV
conditional, so it got stripped out of production bundles by default: https://github.com/developit/preact/blob/8/debug/index.js#L3
But in Preact X, when using the .mjs
bundle, it will always include the import{checkPropTypes as n}from"prop-types";
line, which in turn will always import the prop-types
package. This can be seen in the preact/debug/dist/debug.mjs
file. For example here on unpkg: https://unpkg.com/preact@10.0.0-alpha.0/debug/dist/debug.mjs
So now I wrapped preact/debug
in my app myself:
if (process.env.NODE_ENV === 'development') {
require('preact/debug')
}
which is okay, I guess, but the previous behaviour was definitely nicer, and by upgrading to Preact X users could potentially start shipping the debug package to production.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
preact/debug doesn't automatically get removed in production ...
In Preact 8, the whole preact/debug was wrapped in a process.env.NODE_ENV conditional, so it got stripped out of production bundles by ...
Read more >Debugging Preact Apps
Preact ships with a lot of tools to make debugging easier. They're packaged in a single import and can be included by importing...
Read more >Preact NPM - npm.io
Install the React Developer Tools extension · Import the "preact/debug" module in your app · Set process.env.NODE_ENV to 'development' · Reload and go...
Read more >Preact - Releases
The past weeks saw a good chunk of bug fixes and a bit of house keeping. Upgrades should be as straightforward as swapping...
Read more >enzyme-adapter-preact-pure | Yarn - Package Manager
This is an adapter to support using the Enzyme UI component testing library with Preact. For documentation, please see the testing guide on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We may want to consider only shipping CommonJS and UMD versions of debug for this reason, and using inline requires:
This is documented here and is a side-effect of how ESM works, we can’t really conditionally import in our bundle (async imports on your side however are an option but not in libraries).