Skip to content

fix(components): declare component modules as side-effectful#48

Merged
nicomiguelino merged 3 commits into
mainfrom
fix/missing-side-effects
Jul 8, 2026
Merged

fix(components): declare component modules as side-effectful#48
nicomiguelino merged 3 commits into
mainfrom
fix/missing-side-effects

Conversation

@nicomiguelino

@nicomiguelino nicomiguelino commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Bumping Vite to v8 (Rolldown) tree-shook out every customElements.define() call for app-header, auto-scaler, edge-app-devtools, brand-logo, and the calendar-view components, since package.json's sideEffects field didn't cover the component files. Adding **/components/** keeps them from being stripped.
  • dev-tools.ts aliased import.meta through a local variable, which hid it from Vite's static import.meta.env replacement. Using import.meta.env.DEV directly lets it be stripped at build time instead of leaking a raw import.meta into consumer bundles.

Test plan

  • npm run build / npm run test
  • Verified against a real consuming app (Screenly/clock-app) via a packed tarball install: lint, format, build, test, and screenshots all pass, and the previously-missing header/logo render correctly again across all screenshot resolutions

- add **/components/** to the sideEffects package.json field so bundlers
  don't tree-shake customElements.define() calls out of the bundle
- use import.meta.env.DEV directly instead of aliasing import.meta so
  build tools can statically strip it

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses bundler tree-shaking regressions introduced by the Vite v8 (Rolldown) upgrade by ensuring Web Component registration modules are treated as side-effectful and by adjusting dev-tools environment detection to enable build-time stripping in Vite-based consumers.

Changes:

  • Expanded package.json#sideEffects to include component modules (**/components/**) so customElements.define() registrations aren’t tree-shaken away.
  • Updated dev-tools development-mode detection logic to reference import.meta.env.DEV directly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/components/dev-tools/dev-tools.ts Adjusts dev-mode detection logic used by the dev-tools custom element.
package.json Extends sideEffects patterns to retain component modules during bundler optimizations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/dev-tools/dev-tools.ts Outdated
- this package ships plain tsc output with no Vite transform, so a
  direct import.meta.env.DEV reference throws in non-Vite consumers
  where env is undefined
@nicomiguelino nicomiguelino marked this pull request as ready for review July 7, 2026 22:31
@nicomiguelino nicomiguelino merged commit 5a11d89 into main Jul 8, 2026
4 checks passed
@nicomiguelino nicomiguelino deleted the fix/missing-side-effects branch July 8, 2026 07:55
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