Switch esbuild to ESM with --splitting and load app.js as type=module.
Heavy hooks now ship in their own chunk and only download when their
LiveView mounts.
- assets/js/lib/leaflet.ts: extract ensureLeaflet (vendored Leaflet
loader) into a shared module with a typed window.L declaration.
- assets/js/hooks/coverage_hooks.ts: extract CoverageMap,
MultiCoverageMap, and CoverageLocationPicker (~510 lines) with
proper interface types for hook context and tightened typing on
payloads / event handlers (CoveragePayload is now a real type).
- app.ts: replace those three inline hook bodies with lazyHook
stubs that call import('./hooks/coverage_hooks') on first mount,
forwarding lifecycle hooks once the chunk resolves. Also adds a
scoped `declare const L: any` so the remaining Leaflet hooks
type-check.
- root.html.heex: switch the script tag to type=module so the
emitted ESM bundle can use dynamic import().
- esbuild config: add --splitting --format=esm.
Build output now produces:
app.js 1.2 MB
coverage_hooks-<hash>.js 16 KB (lazy)
chunk-<hash>.js 2.4 KB (shared, lazy)
|
||
|---|---|---|
| .. | ||
| channels | ||
| components | ||
| controllers | ||
| graphql | ||
| helpers | ||
| live | ||
| plugs | ||
| changelog_parser.ex | ||
| endpoint.ex | ||
| gettext.ex | ||
| gettext_helpers.ex | ||
| graphql_socket.ex | ||
| permissions.ex | ||
| plug_exceptions.ex | ||
| remote_ip.ex | ||
| router.ex | ||
| scoped_resource.ex | ||
| telemetry.ex | ||
| telemetry_filter.ex | ||
| user_auth.ex | ||