Skip to content

[stable32] fix(template): add import map for JS module entry points - #60659

Merged
AndyScherzinger merged 1 commit into
stable32from
backport/56941/stable32
Jun 11, 2026
Merged

[stable32] fix(template): add import map for JS module entry points#60659
AndyScherzinger merged 1 commit into
stable32from
backport/56941/stable32

Conversation

@backportbot

Copy link
Copy Markdown

Backport of PR #56941

@backportbot
backportbotBot requested a review from a team as a code ownerMay 22, 2026 14:06
@backportbot
backportbotBot requested review from Altahrim, ArtificialOwl, ShGKme, artonge, come-nc, leftybournes and susnux and removed request for a teamMay 22, 2026 14:06
@backportbotbackportbotBot added this to the Nextcloud 32.0.10 milestone May 22, 2026
Currently apps are broken if they have exports in the JS entry point,
because they then will import from the entry point but because they do
not know about the Nextcloud cache buster they will import without cache
buster.
This results in two problem:
1. The module might be outdated (old cached)
2. The module is duplicated, so the module will be loaded twice and will
have two different - out of sync - states. This also means it will
re-run sideeffects of the entry point.
To fix this we generate an import map which basically maps the plain
entry point script to the script with cache buster added.
(Some background: Bundler will try to minimize chunks (reduce page
loading time) so they can inline modules into entry points and thus
extend the entry point exports and then this issue would be caused).
For example:
```js
// entry.mjs
console.error('called')
async function onClick() {
await import('./chunk.mjs')
}
export const name = 'foo'
// chunk.mjs
import { name } from './entry.mjs'
console.error(name)
```
When calling `onClick` without this fix the output will be:
> called
> called
> foo
With this fix:
> called
> foo
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
@pringelmann
pringelmannforce-pushed the backport/56941/stable32 branch from f06ddd8 to eaa634cCompareMay 26, 2026 15:34
@nextcloud-botnextcloud-bot mentioned this pull request May 27, 2026
This was referenced Jun 1, 2026
@AndyScherzinger
AndyScherzinger merged commit 5693358 into stable32Jun 11, 2026
297 of 325 checks passed
@AndyScherzinger
AndyScherzinger deleted the backport/56941/stable32 branch June 11, 2026 21:25
@nextcloud-botnextcloud-bot mentioned this pull request Jun 17, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@icewind1991@susnux@AndyScherzinger@Altahrim@pringelmann