preactjs / signals

Manage state with style in every framework
https://preactjs.com/blog/introducing-signals/
MIT License
3.82k stars 95 forks source link

refactor: implement signals-core with untranspiled classes #520

Closed jviide closed 8 months ago

jviide commented 8 months ago

This pull request converts the signals-core package to use ES6 classes instead of ES5-style prototypes. It effectively reverts the changes introduced in #160.

Notes:

The sizes of the build artifacts before and after this change are listed below. In general the number of bytes saved falls around 40-60 bytes, depending on the output format.

Before:
       1487 B: signals-core.js.gz
       1352 B: signals-core.js.br
       1513 B: signals-core.mjs.gz
       1378 B: signals-core.mjs.br
       1498 B: signals-core.module.js.gz
       1369 B: signals-core.module.js.br
       1561 B: signals-core.min.js.gz
       1421 B: signals-core.min.js.br

After:
       1429 B: signals-core.js.gz
       1300 B: signals-core.js.br
       1449 B: signals-core.mjs.gz
       1328 B: signals-core.mjs.br
       1438 B: signals-core.module.js.gz
       1316 B: signals-core.module.js.br
       1513 B: signals-core.min.js.gz
       1379 B: signals-core.min.js.br
changeset-bot[bot] commented 8 months ago

⚠️ No Changeset found

Latest commit: 00be0d42da9a7f06157063d6827c4ab8ef82c414

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

netlify[bot] commented 8 months ago

Deploy Preview for preact-signals-demo ready!

Name Link
Latest commit 00be0d42da9a7f06157063d6827c4ab8ef82c414
Latest deploy log https://app.netlify.com/sites/preact-signals-demo/deploys/65f0d237cc7299000833f5a3
Deploy Preview https://deploy-preview-520--preact-signals-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

rschristian commented 8 months ago

While the size reduction is nice, wouldn't this create a bit of a weird discrepancy? If someone's using Preact and (for some godforsaken reason) needs to support ES5, there's now this weird little bit of ES6 in their otherwise ES5 bundles.

I'm just not sure this makes much sense to land on its own.

marvinhagemeister commented 8 months ago

Ah totally forgot about ES5. Yeah that might make it difficult to merge this PR as long as Preact itself ships like that.

jviide commented 8 months ago

Yep, good points.