nextcloud/lib/private/Template
Ferdinand Thiessen f0e020f97d fix(template): add import map for JS module entry points
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>
2026-01-12 13:34:11 +01:00
..
Base.php chore: Run rector on lib/private/Template folder and cleanup more typing 2025-09-29 12:23:37 +02:00
CSSResourceLocator.php chore(Template): allow styles from dist folder 2025-10-22 14:57:47 +02:00
functions.php fix(template): add import map for JS module entry points 2026-01-12 13:34:11 +01:00
JSCombiner.php fix: Cleanup and fix tests, and fix related issues in code 2025-09-30 11:53:59 +02:00
JSConfigHelper.php chore: Fix the last psalm issues in lib/private/Template 2025-09-29 12:32:26 +02:00
JSResourceLocator.php chore: Cleanup typing and deprecated method calls in resource locators 2025-09-29 12:10:56 +02:00
ResourceLocator.php fix: Cleanup and fix tests, and fix related issues in code 2025-09-30 11:53:59 +02:00
ResourceNotFoundException.php chore: Run rector on lib/private/Template folder and cleanup more typing 2025-09-29 12:23:37 +02:00
Template.php fix(lib): include headers from OC\Template\Template as well in produced HTML 2025-12-16 23:01:38 +01:00
TemplateFileLocator.php fix: Use a dedicated Exception class for when a template is not found 2025-03-06 15:49:25 +01:00
TemplateManager.php chore: Run rector on lib/private/Template folder and cleanup more typing 2025-09-29 12:23:37 +02:00