Skip to content

fix(build): load the editor logic from a hashed chunk - #392

Merged
AndyScherzinger merged 1 commit into
mainfrom
fix/hash-editor-chunk
Oct 18, 2026
Merged

AndyScherzinger merged 1 commit into
mainfrom
fix/hash-editor-chunk

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Opening a mind map can fail after an update with "Cannot read properties of undefined (reading 'init')" and "We were unable to display the requested file", in Files and on public shares.

Since #375 the mind map element loads the editor logic lazily with import('../mindmap.js'). mindmap.js was still a build entry, so it came out as js/files_mindmap-mindmap.mjs, a name that never changes. The server sends it with Cache-Control: max-age=15778463 (six months), and unlike scripts added through Util::addScript() the dynamic import carries no ?v= version. A browser that cached the file from an earlier build therefore keeps using it next to the new init script, and the import resolves to a module that doesn't match.

Nothing loads mindmap.js as an entry anymore, so it is removed from the entries. It is now emitted as a normal chunk, js/mindmap-<hash>.chunk.mjs, whose name changes whenever its content does, like every other chunk the init script imports.

Testing: found on the Nextcloud 36 dev instance after several rebuilds, where a browser with a warm cache failed to open the public share while fresh browsers opened it. With this change the init script imports ./mindmap-<hash>.chunk.mjs, and js/viewer.js is unchanged. Vitest, lint and the build pass.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

The mind map element imports mindmap.js lazily, and it was still built
as the entry files_mindmap-mindmap.mjs, whose name never changes. The
server lets browsers cache it for six months and the dynamic import
carries no version, so after an update browsers kept running the old
file next to the new init script, and opening a mind map failed with
"Cannot read properties of undefined (reading 'init')". Nothing loads
it as an entry since #375, so build it as a normal chunk, whose name
carries a content hash.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Oct 18, 2026
@AndyScherzinger AndyScherzinger added this to the v0.2.0 milestone Oct 18, 2026
AndyScherzinger added a commit that referenced this pull request Oct 18, 2026
The viewer and public share entries import mindmap.js, which was still
built as the entry files_mindmap-mindmap.mjs, whose name never changes.
The server lets browsers cache it for six months and the import carries
no version, so after an update browsers could keep running the old file
next to the new entries. Nothing loads it as an entry, so build it as a
normal chunk, whose name carries a content hash.

Same fix as #392 on main.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger
AndyScherzinger merged commit a0180e5 into main Oct 18, 2026
8 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/hash-editor-chunk branch October 18, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants