fix: shim missing helper so live-preview click-to-edit works in production#134
Open
PaulBratslavsky wants to merge 1 commit into
Open
fix: shim missing helper so live-preview click-to-edit works in production#134PaulBratslavsky wants to merge 1 commit into
PaulBratslavsky wants to merge 1 commit into
Conversation
…ction Workaround for a Strapi core bug — root cause should be fixed upstream in Strapi. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@PaulBratslavsky is attempting to deploy a commit to the Strapi-Website Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
Author
Update: root cause fixed upstream in StrapiThe underlying bug is fixed at the source in strapi/strapi#26732 — it makes the injected live-preview highlight script self-contained, so it no longer references an unbundled minified helper ( Verified against the experimental build
Recommendation
Leaving open for maintainers to decide whether to merge as an interim workaround or close in favor of bumping Strapi once the fix is in a stable release. |
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.
Summary
Live-preview click-to-edit silently breaks in production (works fine under
strapi develop). The rendered preview loads, but hovering/clicking text or media never highlights or selects a field.Root cause
Strapi's production admin build injects a live-preview highlight script into the preview iframe. That script calls a minified bundler helper — a lazy-import wrapper around
import('@vercel/stega')— but never includes the helper in the emitted script string:yeis undefined at runtime →ReferenceError: ye is not defined. The script's init promise rejects with no.catch, so the entire highlight/click system never initializes (no overlay, nodata-strapi-sourcetagging, no field selection). It works in dev because the dev build inlines the helper.The minified name is not stable — it changes between Strapi builds (observed
ye→be), so it can't be hardcoded.This PR is a temporary client-side shim to unblock click-to-edit. The actual bug is in Strapi's admin build (it emits a script referencing a helper it doesn't bundle). A separate issue/PR should be filed against
strapi/strapiso the injected preview script is self-contained. Once Strapi ships that fix, this shim should be removed.What this PR does
In
Preview, before injecting Strapi's script, parse everyawait NAME(async …)helper out of the script text and define each as a passthrough that runs the factory. Helpers the script defines locally simply shadow these globals, so it's safe and name-agnostic (handlesye,be, and any future rename).Validation
Verified end-to-end against the production Strapi admin build (helper
be) via Playwright, driving the real admin preview iframe:data-strapi-sourceels.strapi-highlightelsstrapiFieldSingleClickHintReproduces on Strapi 5.47.1. Affects production deployments only.
🤖 Generated with Claude Code