Skip to content

fix(html): prevent tsdown from stripping custom element registrations#703

Merged
mihar-22 merged 2 commits intomainfrom
fix/688-define-side-effects
Mar 4, 2026
Merged

fix(html): prevent tsdown from stripping custom element registrations#703
mihar-22 merged 2 commits intomainfrom
fix/688-define-side-effects

Conversation

@mihar-22
Copy link
Copy Markdown
Member

@mihar-22 mihar-22 commented Mar 4, 2026

Closes #688

Summary

tsdown's unbundle mode stripped bare side-effect imports between entry points in define/, causing customElements.define() calls for sub-elements to be silently removed from the build output. This also fixed the @lit/context upgrade order bug where <media-container> (consumer) was defined before <video-player> (provider).

Changes

  • Add safeDefine() utility that guards against double-registration — all define files now use it
  • Extract MediaContainerElement class to media/container-element.ts so player define files can control registration order
  • Replace bare side-effect imports in composite define files with direct class imports and inline safeDefine() calls
  • Register provider/parent elements before consumer/child elements in each composite file
  • Exclude .test. files from tsdown define entry point glob

Testing

pnpm -F @videojs/html test

New tests in define/tests/:

  • safe-define.test.ts — unit tests for the guard utility
  • registration.test.ts — verifies all composites register elements in correct order and the full registry is complete

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 4, 2026

Deploy Preview for vjs10-site ready!

Name Link
🔨 Latest commit 107d91d
🔍 Latest deploy log https://app.netlify.com/projects/vjs10-site/deploys/69a7e7bde1a63e000892936a
😎 Deploy Preview https://deploy-preview-703--vjs10-site.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 project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

📦 Bundle Size Report

Package Size Diff %
@videojs/core 10.41 kB 0 B ░░░░░░░░ 0%
@videojs/element 1.60 kB 0 B ░░░░░░░░ 0%
@videojs/html 18.55 kB +42 B ████████ +0.2% 🔺
@videojs/icons 3.79 kB 0 B ░░░░░░░░ 0%
@videojs/react 15.08 kB 0 B ░░░░░░░░ 0%
@videojs/store 1.96 kB 0 B ░░░░░░░░ 0%
@videojs/utils 2.81 kB 0 B ░░░░░░░░ 0%

Total: 54.20 kB · +42 B · +0.1%


Entry Breakdown

Subpath sizes are the additional bytes on top of the root entry point, measured by bundling root + subpath together and subtracting the root-only size.

@videojs/core
Entry Base PR Diff %
. 4.39 kB 4.39 kB 0 B 0%
./dom 6.03 kB 6.03 kB 0 B 0%
total 10.41 kB 10.41 kB 0 B 0%
@videojs/element
Entry Base PR Diff %
. 817 B 817 B 0 B 0%
./context 823 B 823 B 0 B 0%
total 1.60 kB 1.60 kB 0 B 0%
@videojs/html
Entry Base PR Diff %
. 15.41 kB 15.44 kB +30 B +0.2% 🔺
./video 1.05 kB 1.04 kB -12 B -1.1% 🔽
./audio 1.03 kB 1.03 kB +5 B +0.5% 🔺
./background 1.02 kB 1.04 kB +19 B +1.8% 🔺
total 18.51 kB 18.55 kB +42 B +0.2%
@videojs/icons
Entry Base PR Diff %
./react 2.27 kB 2.27 kB 0 B 0%
./html 1.52 kB 1.52 kB 0 B 0%
total 3.79 kB 3.79 kB 0 B 0%
@videojs/store
Entry Base PR Diff %
. 1.31 kB 1.31 kB 0 B 0%
./html 472 B 472 B 0 B 0%
./react 199 B 199 B 0 B 0%
total 1.96 kB 1.96 kB 0 B 0%
@videojs/utils
Entry Base PR Diff %
./array 104 B 104 B 0 B 0%
./dom 928 B 928 B 0 B 0%
./events 227 B 227 B 0 B 0%
./function 261 B 261 B 0 B 0%
./object 119 B 119 B 0 B 0%
./predicate 265 B 265 B 0 B 0%
./string 148 B 148 B 0 B 0%
./style 185 B 185 B 0 B 0%
./time 478 B 478 B 0 B 0%
./number 158 B 158 B 0 B 0%
total 2.81 kB 2.81 kB 0 B 0%

ℹ️ How to interpret

Sizes are minified + brotli, measured with esbuild.
Package totals are computed as root size + marginal subpath costs.
Subpath marginal cost = (root + subpath bundled together) − root alone.

Icon Meaning
No change
🔺 Increased ≤ 10%
🔴 Increased > 10%
🔽 Decreased
🆕 New (no baseline)

Run pnpm size locally to check current sizes.

@mihar-22 mihar-22 merged commit 9a5dfab into main Mar 4, 2026
18 of 19 checks passed
@mihar-22 mihar-22 deleted the fix/688-define-side-effects branch March 4, 2026 08:06
@github-actions github-actions Bot mentioned this pull request Mar 4, 2026
@github-actions github-actions Bot mentioned this pull request Mar 10, 2026
@luwes luwes mentioned this pull request Apr 11, 2026
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.

fix: tsdown unbundle strips side-effect imports + context upgrade order bug

1 participant