Skip to content

fix(build): have each chunk import its stylesheet - #132

Merged
susnux merged 1 commit into
mainfrom
fix/import-chunk-css
Oct 8, 2026
Merged

susnux merged 1 commit into
mainfrom
fix/import-chunk-css

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Since #124, the build emits each chunk's styles as a stylesheet, but nothing imports them and exports doesn't expose them. An app bundling the library gets a viewer with none of its styles. In the server, the image editor is 0px tall, the Video.js controls collapse, and the viewer falls back to NcModal's layout.

inlineCSS: true makes each chunk import its own stylesheet, and the server's Vite build then loads it with the chunk. That has one side effect: the import lands at the top of the chunk, ahead of @nextcloud/image-editor/style. The server then loads the editor's .image-editor { position: relative; height: 100% } after our .viewer__image-editor { position: fixed; inset: 0 }, and with equal specificity ours lost. It now uses .image-editor.viewer__image-editor. That collapse is what made me switch to injected CSS in September; the bundler was never the problem.

Before After
Photo
Video

Checked in the server, with this build in a master instance and the frontend rebuilt: the editor goes from 1280×0 to 1280×800, and the video controls and the viewer's layout are back. Any other rule of ours that only beats a dependency by coming later would break the same way. I found none in what I opened, but I haven't gone through every scoped style.

👾 This pull request was assisted by Claude Code, commits carry an Assisted-by trailer.

Since #124 the styles are emitted as stylesheets, but nothing imports
them and the package does not export them, so an app bundling the library
gets a viewer with none of its styles: in the server the image editor is
zero pixels tall and the Video.js controls collapse. inlineCSS makes every
chunk import its own stylesheet, for the app's bundler to load with it.

The plugin puts that import at the top of the chunk, ahead of the image
editor's own stylesheet, so the app loads the editor's `.image-editor`
after the viewer's override of it and the override lost. It now wins on
specificity rather than on order.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
@skjnldsv skjnldsv added this to the 2.0.0 milestone Oct 8, 2026
@skjnldsv skjnldsv added type: bug 🐛 Something isn't working AI assisted 3. to review labels Oct 8, 2026
@skjnldsv skjnldsv self-assigned this Oct 8, 2026
@skjnldsv
skjnldsv requested a review from susnux October 8, 2026 12:18
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.82%. Comparing base (789469f) to head (ba67e68).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #132   +/-   ##
=======================================
  Coverage   92.82%   92.82%           
=======================================
  Files          47       47           
  Lines        4069     4069           
  Branches      813      813           
=======================================
  Hits         3777     3777           
  Misses        273      273           
  Partials       19       19           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@susnux susnux 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.

sorry!

@susnux
susnux merged commit 9db7164 into main Oct 8, 2026
21 checks passed
@susnux
susnux deleted the fix/import-chunk-css branch October 8, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted type: bug 🐛 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants