preact-cli icon indicating copy to clipboard operation
preact-cli copied to clipboard

Use `preact` and `preact-router` from source instead of dist

Open prateekbh opened this issue 7 years ago • 9 comments
trafficstars

Do you want to request a feature or report a bug? Bug

What is the current behaviour? We use preact and preact-router from their dist folder on npm

What is the expected behaviour? Since we transpile node_modules ourselves we should be using preact and preact_router from their source. This will have no affect on the regular bundles but will have some saving on the module bundle generated.

If this is a feature request, what is motivation or use case for changing the behaviour? Web perf

Please mention other relevant information.

  • Node version: any
  • npm version: any
  • Operating system: any
  • CLI version: next
  • Browser: any

prateekbh avatar Sep 07 '18 17:09 prateekbh

Thumbs down

lukeed avatar Sep 07 '18 17:09 lukeed

no? because?

prateekbh avatar Sep 07 '18 18:09 prateekbh

Preact & Router are super optimized distributions. No user-settings are going to match it. /cc @developit

lukeed avatar Sep 07 '18 18:09 lukeed

Now thats a thing I never knew, super interested in learning what is it?

prateekbh avatar Sep 07 '18 18:09 prateekbh

Follow here. IIRC it's circa ~1kb savings. This is actually (can) happen often, and is part of the reason why bundling from node_modules is not the norm... for now.

lukeed avatar Sep 07 '18 18:09 lukeed

feel free to close :), if there's no better solution

prateekbh avatar Sep 07 '18 18:09 prateekbh

@developit We spoke about moving the optimizations to build size into preact-cli and applying these across all source instead of just one off packages.

Perhaps now is the time, or 3.1.0.

kristoferbaxter avatar Sep 07 '18 18:09 kristoferbaxter

I'd support that 👍 It was a thumbs-down for present situation.

My original intention for CLI was to extract some of the config into standalone chunks. I finally got around to the Babel stuff (#639), but an uglify package was on my radar too. Perhaps the mapping lives there?

lukeed avatar Sep 07 '18 19:09 lukeed

Another thing we can consider here is applying the Preact's minification processes to a bundled JS Modules version - with constant inlining, hoisting and a customized terser config I'm sure it'd be reasonably close to what preact ships over the wire today.

developit avatar Oct 15 '18 20:10 developit