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: Remove declare global from internal types #4583

Merged
merged 4 commits into from
Nov 30, 2024

Conversation

rschristian
Copy link
Member

#4173 introduced declare global to skip having to import them in src/. However, this blocks usage in other repos (like devtools, which needed to patch this) and we're really abusing the language server to support it. From a TS file you would not be able to import interfaces declared within declare global {}, it blocks all use. While it "works" for our JS usage (every subpath imports from src/internal) at the moment, we have a bunch of TS issues that I'm trying to track down and I don't think this is helping matters one bit.

It's also just really ambiguous. If we're going to have multiple VNode, Component, etc. definitions sitting around, let's at least point to which one we're referencing, no?

Copy link

github-actions bot commented Nov 29, 2024

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: faster ✔ 0% - 1% (0.40ms - 11.42ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.06ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -3% - +1% (-2.19ms - +0.91ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -1% - +5% (-0.19ms - +0.86ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +1% (-1.17ms - +1.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +5% (-0.11ms - +0.10ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +2% (-0.31ms - +0.63ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -3% - +2% (-1.16ms - +0.76ms)
    preact-local vs preact-main

usedJSHeapSize

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

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local928.19ms - 932.54ms-faster ✔
0% - 1%
0.40ms - 11.42ms
preact-main931.21ms - 941.34msslower ❌
0% - 1%
0.40ms - 11.42ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local24.85ms - 24.85ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main24.84ms - 24.84msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.54ms - 16.59ms-unsure 🔍
-0% - +0%
-0.06ms - +0.00ms
preact-main16.57ms - 16.62msunsure 🔍
-0% - +0%
-0.00ms - +0.06ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.65ms - 1.67ms-unsure 🔍
-1% - +1%
-0.02ms - +0.01ms
preact-main1.65ms - 1.68msunsure 🔍
-1% - +1%
-0.01ms - +0.02ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local73.95ms - 76.13ms-unsure 🔍
-3% - +1%
-2.19ms - +0.91ms
preact-main74.57ms - 76.78msunsure 🔍
-1% - +3%
-0.91ms - +2.19ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local11.25ms - 11.85ms-unsure 🔍
-2% - +5%
-0.25ms - +0.55ms
preact-main11.13ms - 11.68msunsure 🔍
-5% - +2%
-0.55ms - +0.25ms
-
many-updates
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #4126
  • Commit: 9cfa970

duration

VersionAvg timevs preact-localvs preact-main
preact-local15.70ms - 16.57ms-unsure 🔍
-1% - +5%
-0.19ms - +0.86ms
preact-main15.51ms - 16.09msunsure 🔍
-5% - +1%
-0.86ms - +0.19ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.50ms - 4.51ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main4.49ms - 4.50msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
replace1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local69.79ms - 71.44ms-unsure 🔍
-2% - +1%
-1.17ms - +1.00ms
preact-main70.00ms - 71.40msunsure 🔍
-1% - +2%
-1.00ms - +1.17ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.57ms - 3.59ms-unsure 🔍
-0% - +1%
-0.02ms - +0.02ms
preact-main3.56ms - 3.59msunsure 🔍
-1% - +0%
-0.02ms - +0.02ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local31.21ms - 32.00ms-unsure 🔍
-1% - +3%
-0.45ms - +0.92ms
preact-main30.82ms - 31.93msunsure 🔍
-3% - +1%
-0.92ms - +0.45ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local36.84ms - 38.45ms-unsure 🔍
-5% - +1%
-2.03ms - +0.27ms
preact-main37.71ms - 39.34msunsure 🔍
-1% - +5%
-0.27ms - +2.03ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local31.04ms - 31.98ms-unsure 🔍
-1% - +4%
-0.20ms - +1.25ms
preact-main30.43ms - 31.53msunsure 🔍
-4% - +1%
-1.25ms - +0.20ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local23.48ms - 23.98ms-unsure 🔍
-3% - +1%
-0.63ms - +0.19ms
preact-main23.63ms - 24.27msunsure 🔍
-1% - +3%
-0.19ms - +0.63ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local22.23ms - 22.51ms-unsure 🔍
-2% - +0%
-0.34ms - +0.09ms
preact-main22.33ms - 22.66msunsure 🔍
-0% - +2%
-0.09ms - +0.34ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local20.74ms - 21.46ms-unsure 🔍
-2% - +2%
-0.49ms - +0.50ms
preact-main20.76ms - 21.43msunsure 🔍
-2% - +2%
-0.50ms - +0.49ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 220
  • Built by: CI #4126
  • Commit: 9cfa970

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.12ms - 2.28ms-unsure 🔍
-5% - +5%
-0.11ms - +0.10ms
preact-main2.14ms - 2.28msunsure 🔍
-5% - +5%
-0.10ms - +0.11ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.11ms - 1.11ms-unsure 🔍
-0% - +1%
-0.00ms - +0.01ms
preact-main1.10ms - 1.11msunsure 🔍
-1% - +0%
-0.01ms - +0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local33.84ms - 34.70ms-unsure 🔍
-1% - +2%
-0.31ms - +0.63ms
preact-main33.92ms - 34.29msunsure 🔍
-2% - +1%
-0.63ms - +0.31ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.22ms - 1.23ms-unsure 🔍
-1% - +1%
-0.01ms - +0.01ms
preact-main1.22ms - 1.23msunsure 🔍
-1% - +1%
-0.01ms - +0.01ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local36.37ms - 37.38ms-unsure 🔍
-3% - +2%
-1.16ms - +0.76ms
preact-main36.26ms - 37.89msunsure 🔍
-2% - +3%
-0.76ms - +1.16ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.48ms - 3.51ms-unsure 🔍
-0% - +1%
-0.00ms - +0.03ms
preact-main3.47ms - 3.49msunsure 🔍
-1% - +0%
-0.03ms - +0.00ms
-

tachometer-reporter-action v2 for CI

Copy link

github-actions bot commented Nov 29, 2024

Size Change: 0 B

Total Size: 62.5 kB

ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.13 kB
compat/dist/compat.module.js 4.06 kB
compat/dist/compat.umd.js 4.2 kB
debug/dist/debug.js 3.82 kB
debug/dist/debug.module.js 3.83 kB
debug/dist/debug.umd.js 3.9 kB
devtools/dist/devtools.js 260 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 346 B
dist/preact.js 4.73 kB
dist/preact.min.js 4.75 kB
dist/preact.min.module.js 4.75 kB
dist/preact.min.umd.js 4.77 kB
dist/preact.module.js 4.75 kB
dist/preact.umd.js 4.79 kB
hooks/dist/hooks.js 1.52 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.6 kB
jsx-runtime/dist/jsxRuntime.js 973 B
jsx-runtime/dist/jsxRuntime.module.js 947 B
jsx-runtime/dist/jsxRuntime.umd.js 1.05 kB
test-utils/dist/testUtils.js 451 B
test-utils/dist/testUtils.module.js 456 B
test-utils/dist/testUtils.umd.js 536 B

compressed-size-action

@coveralls
Copy link

coveralls commented Nov 29, 2024

Coverage Status

coverage: 99.617%. remained the same
when pulling 9cfa970 on chore/internal-types
into b9ff1b7 on main.

Comment on lines +1 to +6
import {
Options as PreactOptions,
Component as PreactComponent,
VNode as PreactVNode,
Context as PreactContext,
} from '../../src/internal';
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what we use in debug & compat, makes everything a bit more consistent

@marvinhagemeister
Copy link
Member

Nice, the declare global stuff seemed always more of a hack to me.

@rschristian rschristian merged commit 42e7b45 into main Nov 30, 2024
13 checks passed
@rschristian rschristian deleted the chore/internal-types branch November 30, 2024 00:11
@JoviDeCroock JoviDeCroock mentioned this pull request Dec 1, 2024
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