Commit graph

8 commits

Author SHA1 Message Date
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
Côme Chilliet
b2100484c0 fix: Remove some call and references to deprecated OC_Util class
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-04-07 17:05:54 +02:00
Côme Chilliet
e467ea1c6a
chore(legacy): Remove deprecated OC_Util::addScript and functions depending on it
Deprecated since 24, currently unused.
Sadly not all related functions were officially marked as deprecated,
 but all of them were unused.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-04-01 15:24:24 +02:00
Côme Chilliet
1ce593311b
fix: Go back to soft typing for template function p
Strong typing breaks legacy code in this case.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-24 12:53:27 +01:00
Côme Chilliet
101b1f0eaf chore: cleanup human_file_size usage
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-20 10:54:50 +01:00
Côme Chilliet
e9046a0f24 fix: Remove obsolete component template function
HTML imports are not a thing anymore, they are not supported by any
 browser.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-20 10:54:50 +01:00
Côme Chilliet
13fe0f5612 fix: Clean up typing and remove deprecated calls in template functions
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-20 10:54:50 +01:00
Côme Chilliet
aac391d466 chore: Move template functions out of legacy folder
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
2025-03-20 10:54:50 +01:00
Renamed from lib/private/legacy/template/functions.php (Browse further)