fix(build): preserve CSS/Vue side-effects in consumer tree-shaking#774
Merged
Conversation
`"sideEffects": false` told bundlers every file in the package is pure,
licensing them to drop side-effect-only imports during production tree-
shaking. The editor ships its styles that way — `import './style.css'`
inside `molecules/editor/index.ts` (the `frappe-ui/editor` entry) — so
apps importing only named bindings (`import { RichTextKit } from
'frappe-ui/editor'`) lost the editor's table/taskList/cell-selection CSS
in their production builds. Dev was unaffected because it never tree-
shakes, making this a build-only regression.
Scope sideEffects to `.css` and `.vue` so those imports are always
preserved while pure JS modules stay tree-shakeable (bundle size is
unchanged for unused JS exports). Covers all 12 bindingless CSS imports
in src (style.css, popoverMotion.css, CodeBlockComponent.css).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Looks good — correct, minimal build fix.
One note: this is identical to barista · claude-opus-4-8 · 6.2k in / 2.9k out · 583k cached · 51s · $0.542 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
package.jsondeclares"sideEffects": false, which promises bundlers that no file in the package has import-time side effects — licensing them to delete side-effect-only imports during production tree-shaking.But the editor ships its styles as exactly such an import:
So when a consumer app imports only named bindings:
the production build tree-shakes
import './style.css'away. The editor loses its table borders, taskList, and cell-selection styles (e.g..ProseMirror td { border: 1px solid var(--outline-gray-2) }— with the rule gone, no border renders at all).This is build-only: dev servers never tree-shake, so the styles load fine in
yarn devand only vanish afteryarn build. That makes it an easy-to-miss regression. Confirmed reproducing in Gameplan after adopting the beta.Fix
Scope
sideEffectsto the file types that actually have side effects:.css— always preserved, so bindingless stylesheet imports survive tree-shaking. Covers all 12 such imports insrc(style.css×6,popoverMotion.css×5,CodeBlockComponent.css×1)..vue— defensively preserved (SFC<style>injection + import-time global registration).Consumer-side note
Apps currently on the beta can unblock themselves by importing the editor stylesheet explicitly (
@import 'frappe-ui/editor-style.css'), but that's a per-app workaround for what is a package-level mis-declaration. This fixes it at the source for every consumer.🤖 Generated with Claude Code
Docs preview: https://ui.frappe.io/pr-preview/pr-774/
Coverage: 56.48% (±0.00% vs
main)