fix: make silent failures observable in dev and strip diagnostics fro… - #65
Merged
Conversation
…se positives to zero
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.
Description
Six failure modes where the runtime did the wrong thing — or the right thing for an unstated reason — without saying so, plus the reason none of the existing warnings ever reached a developer.
The gate was broken. Dev diagnostics never compiled out. The dev flag led with a
globalThis.__SIBU_DEV__lookup, and a member expression is not something a bundler can substitute or fold, so every warning string shipped to production to be tested at runtime and never printed. Fixed with a statically foldable constant plus warning helpers that test the build-time define inline, so their bodies fold to nothing even in a publisheddistchunk.The CDN shipped them too, and could not strip them. The CDN build applied no
__SIBU_DEV__define at all, and a<script src="…/cdn.global.js">consumer has no bundler to fold it later — the published bytes are what runs. With no define and noprocessin a browser the gate resolves tofalseanyway, so those bytes were downloaded and parsed to never print. The build now emits two artifacts:dist/cdn.global.js(production, diagnostics compiled out) anddist/cdn.dev.global.js(development, exported assibujs/cdn-dev), so the no-build workflow keeps its warnings.Fixed
RouterLinksilently ignored a reactiveclass— read withtypeof classAttr === "string", so a getter or conditional map fell through to""and the attribute was never written.data-focus-key,id,name). It does not guess: a match must be unique (nameis shared by every radio in a group), and focus is only restored when genuinely lost, never when the rebuild moved it deliberately. IME composition cannot be preserved — it belongs to the destroyed node — and the warning says so.url()declarations in silence, so blocked images rendered as empty boxes with nothing in any console. The guard stays; each drop is announced in dev with property, value, element, reason and the sanctioned alternatives.optimizeDeps.excludeadvice; the global registry already makes it unnecessary.Changed
show,whenandmatchaccept both an element and a factory. Passing the wrong shape used to raise an obscureTypeError, or — forwhen— render nothing silently. A re-attached bare element keeps its own reactive bindings, since the directive did not create it and does not tear it down.item-0,home-content,user-42,v4.1.0,src/index.ts,https://example.comandN/Aat a measured 29.8% false-positive rate, and a list renderingitem-0…item-999produced a thousand warnings. The new rule measures 0% on the same 131-string corpus. The cost, stated plainly: single-token class lists no longer warn —div("space-y-6")passes silently, where it used to be caught. A warning developers learn to ignore protects nobody.sanitizeCSSValue,sanitizeStyleAttributeandsanitizeAttributeStringtake an optional context used only to enrich the dev warning; it never changes a security decision.Size — production is smaller than 4.1.0 despite everything above, measured against a clean build of
main:sibujssibujs/pluginssibujs/uidist/cdn.global.jsdist/cdn.dev.global.jsis 29,720 gzipped and is not shipped to end users.Guardrails —
treeshaking-dev-diagnostics.test.tsbundles source and fails if any diagnostic string survives a production build;dist-artifacts.test.tsasserts the same against the builtdist/files, which is where the CDN leak hid. It skips locally whendist/is absent but fails on CI.Known limitation, deliberately not changed:
--behavior: redis dropped by the property-qualified check, over-blocking a harmless custom property. Pre-existing, and loosening it changes the security posture.Related Issue
Closes #
Type of Change
Checklist