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

refactor: Breaking changes to outputs & pkg.json #4652

Merged
merged 4 commits into from
Feb 14, 2025

Conversation

rschristian
Copy link
Member

@rschristian rschristian commented Feb 11, 2025

Lands a few breaking changes at once, happy to revert any part or all of this if we feel anything's a problem.

  1. Drop .module.js for .mjs

Obviously this is where the ecosystem is going and it already has pretty good support: Webpack started to adopt back in late 2018 and Node has supported it since v12.16 onward. This moves our effective back compat date up to about 5-6 years ago.

Perhaps too soon, but thought I'd at least suggest it.

  1. Switch package.json#exports.browser to package.json#exports.module

This comes up fairly often, usually due to test runners trying to load modules meant for the browser in Node and then crashing as our browser build does not adhere to Node's ESM semantics. See #4406, preactjs/jest-preset-preact#13 (comment), #3634. While I'd tend to call that ecosystem error, it's not going away any time soon and we don't even use this output; it's just a standard ESM build, nothing browser-specific.

Instead of dropping this entirely though we can switch to module which some bundlers use to guarantee the package isn't instantiated twice (Webpack's docs on the subject). We had this change in the v11 branch and I think it's good to carry over. Might also reduce some of the __H reports we have to deal with.

  1. Drop the .min builds

These largely appear to be broken as-is (preact.min.module.js is not ESM, there's no CJS build as the IIFE output overwrites it immediately, preact.min.umd.js doesn't appear to be valid UMD either); the only thing maybe of value is the IIFE output preact.min.js. It's 30b lighter than preact.umd.js, but I don't know who's actually using it (if anyone at all).

Users are almost certainly better off with the plain UMD build and we'd be better off dropping it to reduce some confusion as it's unclear when this is meant to be used.

Copy link

github-actions bot commented Feb 11, 2025

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-2.05ms - +6.13ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -1% - +0% (-0.22ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -1% - +2% (-0.78ms - +1.55ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +4% (-0.02ms - +0.74ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +1% (-0.29ms - +0.88ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -4% - +5% (-0.08ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +1% (-0.30ms - +0.46ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -5% - +4% (-1.56ms - +1.15ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -2% - +2% (-0.03ms - +0.03ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +1% (-0.22ms - +0.15ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +0% (-0.02ms - +0.02ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -3% - +0% (-0.04ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +2% (-0.01ms - +0.05ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local940.14ms - 945.88ms-unsure 🔍
-0% - +1%
-2.05ms - +6.13ms
preact-main938.06ms - 943.88msunsure 🔍
-1% - +0%
-6.13ms - +2.05ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.20ms - 19.21ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main19.20ms - 19.22msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.55ms - 16.62ms-unsure 🔍
-1% - +0%
-0.22ms - +0.00ms
preact-main16.59ms - 16.80msunsure 🔍
-0% - +1%
-0.00ms - +0.22ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.54ms - 1.58ms-unsure 🔍
-2% - +2%
-0.03ms - +0.03ms
preact-main1.53ms - 1.58msunsure 🔍
-2% - +2%
-0.03ms - +0.03ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local79.01ms - 81.04ms-unsure 🔍
-1% - +2%
-0.78ms - +1.55ms
preact-main79.06ms - 80.22msunsure 🔍
-2% - +1%
-1.55ms - +0.78ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local13.59ms - 13.87ms-unsure 🔍
-2% - +1%
-0.22ms - +0.15ms
preact-main13.65ms - 13.89msunsure 🔍
-1% - +2%
-0.15ms - +0.22ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.42ms - 17.08ms-unsure 🔍
-0% - +4%
-0.02ms - +0.74ms
preact-main16.21ms - 16.58msunsure 🔍
-4% - +0%
-0.74ms - +0.02ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.76ms - 3.78ms-unsure 🔍
-1% - +0%
-0.02ms - +0.02ms
preact-main3.76ms - 3.79msunsure 🔍
-0% - +1%
-0.02ms - +0.02ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4382
  • Commit: 133776c

duration

VersionAvg timevs preact-localvs preact-main
preact-local64.72ms - 65.74ms-unsure 🔍
-0% - +1%
-0.29ms - +0.88ms
preact-main64.65ms - 65.22msunsure 🔍
-1% - +0%
-0.88ms - +0.29ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.97ms - 2.99ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main2.97ms - 2.98msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local29.26ms - 29.77ms-unsure 🔍
-1% - +1%
-0.26ms - +0.43ms
preact-main29.19ms - 29.66msunsure 🔍
-1% - +1%
-0.43ms - +0.26ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local32.75ms - 33.62ms-unsure 🔍
-2% - +1%
-0.81ms - +0.41ms
preact-main32.96ms - 33.81msunsure 🔍
-1% - +2%
-0.41ms - +0.81ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local24.95ms - 25.29ms-unsure 🔍
-1% - +1%
-0.21ms - +0.30ms
preact-main24.89ms - 25.26msunsure 🔍
-1% - +1%
-0.30ms - +0.21ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local24.00ms - 25.10ms-unsure 🔍
-3% - +3%
-0.82ms - +0.80ms
preact-main23.97ms - 25.15msunsure 🔍
-3% - +3%
-0.80ms - +0.82ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.71ms - 24.76ms-unsure 🔍
-2% - +4%
-0.43ms - +1.06ms
preact-main23.39ms - 24.44msunsure 🔍
-4% - +2%
-1.06ms - +0.43ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local19.84ms - 20.67ms-unsure 🔍
-1% - +3%
-0.28ms - +0.66ms
preact-main19.84ms - 20.28msunsure 🔍
-3% - +1%
-0.66ms - +0.28ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 110
  • Built by: CI #4382
  • Commit: 133776c

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.06ms - 2.18ms-unsure 🔍
-4% - +5%
-0.08ms - +0.10ms
preact-main2.04ms - 2.18msunsure 🔍
-5% - +4%
-0.10ms - +0.08ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.12ms - 1.12ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.11ms - 1.12msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.63ms - 34.36ms-unsure 🔍
-1% - +1%
-0.30ms - +0.46ms
preact-main33.80ms - 34.04msunsure 🔍
-1% - +1%
-0.46ms - +0.30ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.22ms - 1.25ms-unsure 🔍
-3% - +0%
-0.04ms - +0.00ms
preact-main1.23ms - 1.27msunsure 🔍
-0% - +3%
-0.00ms - +0.04ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local31.05ms - 32.41ms-unsure 🔍
-5% - +4%
-1.56ms - +1.15ms
preact-main30.76ms - 33.11msunsure 🔍
-4% - +5%
-1.15ms - +1.56ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.94ms - 2.98ms-unsure 🔍
-0% - +2%
-0.01ms - +0.05ms
preact-main2.93ms - 2.96msunsure 🔍
-2% - +0%
-0.05ms - +0.01ms
-

tachometer-reporter-action v2 for CI

Copy link

github-actions bot commented Feb 11, 2025

Size Change: -29.6 kB (-38.72%) 🎉

Total Size: 46.8 kB

Filename Size Change
compat/dist/compat.mjs 3.59 kB -4 B (-0.11%)
compat/dist/compat.module.js 0 B -3.59 kB (removed) 🏆
debug/dist/debug.mjs 3.87 kB -4 B (-0.1%)
debug/dist/debug.module.js 0 B -3.87 kB (removed) 🏆
devtools/dist/devtools.mjs 270 B -4 B (-1.46%)
devtools/dist/devtools.module.js 0 B -274 B (removed) 🏆
dist/preact.min.js 0 B -4.71 kB (removed) 🏆
dist/preact.min.module.js 0 B -4.7 kB (removed) 🏆
dist/preact.min.umd.js 0 B -4.74 kB (removed) 🏆
dist/preact.mjs 4.69 kB -4 B (-0.09%)
dist/preact.module.js 0 B -4.7 kB (removed) 🏆
hooks/dist/hooks.mjs 1.58 kB -5 B (-0.32%)
hooks/dist/hooks.module.js 0 B -1.58 kB (removed) 🏆
jsx-runtime/dist/jsxRuntime.mjs 922 B -4 B (-0.43%)
jsx-runtime/dist/jsxRuntime.module.js 0 B -926 B (removed) 🏆
test-utils/dist/testUtils.mjs 473 B -4 B (-0.84%)
test-utils/dist/testUtils.module.js 0 B -477 B (removed) 🏆
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 3.67 kB
compat/dist/compat.umd.js 3.73 kB
debug/dist/debug.js 3.87 kB
debug/dist/debug.umd.js 3.95 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.umd.js 346 B
dist/preact.js 4.67 kB
dist/preact.umd.js 4.77 kB
hooks/dist/hooks.js 1.55 kB
hooks/dist/hooks.umd.js 1.62 kB
jsx-runtime/dist/jsxRuntime.js 957 B
jsx-runtime/dist/jsxRuntime.umd.js 1.03 kB
test-utils/dist/testUtils.js 473 B
test-utils/dist/testUtils.umd.js 555 B

compressed-size-action

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

LGTM, sounds reasonable to me. I'm kinda wondering if it's worth it to move to type: "module" at some point or if that would be too much of a breaking change.

@rschristian
Copy link
Member Author

Not sure why coveralls is breaking, weird.

I don't think we'd gain much from "type": "module" and it does move up the minimum a fair bit, .mjs saw way earlier support than .cjs after all.

@marvinhagemeister
Copy link
Member

fair point!

@rschristian rschristian force-pushed the refactor/pkg-exports branch 2 times, most recently from a33b56f to 133776c Compare February 14, 2025 06:23
@rschristian rschristian merged commit d1c4581 into v11-2 Feb 14, 2025
25 checks passed
@rschristian rschristian deleted the refactor/pkg-exports branch February 14, 2025 09:08
JoviDeCroock pushed a commit that referenced this pull request Feb 18, 2025
* refactor: Switch to `package.json#exports.module`, drop `.min` builds, &  use `.mjs` exclusively

* chore: Remove leftover CJS shell

* test: Fix export for karma

* fix: coverage not generated in minify tests

---------

Co-authored-by: Marvin Hagemeister <[email protected]>
JoviDeCroock pushed a commit that referenced this pull request Feb 19, 2025
* refactor: Switch to `package.json#exports.module`, drop `.min` builds, &  use `.mjs` exclusively

* chore: Remove leftover CJS shell

* test: Fix export for karma

* fix: coverage not generated in minify tests

---------

Co-authored-by: Marvin Hagemeister <[email protected]>
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.

3 participants