Preact: not-minified version of preact

Created on 7 Jan 2020  路  8Comments  路  Source: preactjs/preact

preact apparently used to be have not minified version of the library in dist folder https://unpkg.com/browse/[email protected]/dist/ (preact.js 21.2 kB vs preact.min.js 8.43 kB) but apparently now doesn't https://unpkg.com/browse/[email protected]/dist/ (preact.js 9.18 kB vs preact.min.js 9.18 kB), guess it wasn't intentional to have two same minified file in the distribution?

question

Most helpful comment

I would really like a non-minified version of Preact 10 that I can easily step through using my browser debugger. That is not something I use often, but it is something I miss from Preact 8.

All 8 comments

Hiya! This was done intentionally - shipping both minified and unminified builds of Preact meant any tools that integrated with Preact needed to support both builds.

We added the preact.min.js alias in order to fix lots of demos being broken when 10 came out because they directly loaded unpkg.com/preact/dist/preact.min.js.

Can you put not minified version also somewhere? I like to use Preact in some environment that has it own minifier (MediaWiki) thus requiring not minified version, in place of React that I was experiencing with and have built some mini tool with it. Guess it should be easy to do that myself just it would be also nice if I could put some public/verifiable link as the source of the library so others also can update the library easily.

@ebraminio We don't want to encourage folks to use Preact without our property mangling, since that effectively creates a fork of Preact with a different API, and plugins don't account for that being the case. It's also likely to cause different performance characteristics, which is something I would personally be wary of.

I'm guessing the goal here would be to have readable source code, which I think we can consider. For Preact, that would be a preact.js that has properties mangled but not whitespace or local variables. that's probably something we could consider doing, though I don't think we'd necessarily want to ship it as /dist/preact.js (others may disagree, just my opinion).

If you want to see what that version might look like, it can be mostly emulated with the following changes to preact's mangle.json:

{
  // <snip>
  "minify": {
+   "mangle": {
+     "keep_fnames": true,
+     "toplevel": false,
+     "reserved": [
+       "dom",
+       "oldVNode",
+       "newVNode",
+       "vnode",
+       "oldDom",
+       "excessDomChildren",
+       "oldParentVNode",
+       "oldChildrenLength",
+       "oldChildren"
+     ],
+     "properties": {
+       "regex": "^@_"
+     }
+   },
+   "compress": {
+     "hoist_vars": true,
+     "reduce_funcs": false,
+     "keep_fnames": true
+   }
  },
  // <snip>
}

In terms of a real implementation, we'd want to add an option to Microbundle to support this type of output.

Ok, so let's close so you can decide later, thanks :)

I would really like a non-minified version of Preact 10 that I can easily step through using my browser debugger. That is not something I use often, but it is something I miss from Preact 8.

@developit ping. Today I've faced this issue when trying to debug an obscure error coming somewhere from the hooks code. Providing unminified code or/and source maps, which can be utilized by tools like source-map-loader would help debugging a lot.

Screenshot from 2020-12-10 21-24-30

FYI: We ship source maps in our npm package.

Weird, other packages' sources are shown okay. Must be issues with my config then. Still, allowing users to use their own tools for a build process feels more natural imo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipwalton picture philipwalton  路  3Comments

kossnocorp picture kossnocorp  路  3Comments

kay-is picture kay-is  路  3Comments

SabirAmeen picture SabirAmeen  路  3Comments

skaraman picture skaraman  路  3Comments