fix(web_serviceworker): Move service worker initialization to init.ts and remove exports from service worker entrypoint to avoid ESM bundle output

This commit is contained in:
2025-12-04 13:29:43 +00:00
parent aadec22023
commit ba12ba561b
5 changed files with 23 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
import { getMetricsCollector } from './classes.metrics.js';
import { getServiceWorkerInstance } from './index.js';
import { getServiceWorkerInstance } from './init.js';
import * as interfaces from './env.js';
/**

View File

@@ -1,10 +1,4 @@
// TypeScript declatations
import * as env from './env.js';
declare var self: env.ServiceWindow;
import { ServiceWorker } from './classes.serviceworker.js';
const sw = new ServiceWorker(self);
// Export getter for service worker instance (used by dashboard for TypedSocket access)
export const getServiceWorkerInstance = (): ServiceWorker => sw;
// Service worker entry point - NO EXPORTS here!
// Exports at entry point cause tsbundle to output ESM format which service workers can't use.
// The actual initialization happens in init.ts which other modules can import from.
import './init.js';

View File

@@ -0,0 +1,10 @@
// Service worker initialization - creates and exports the SW instance
// Other modules in the bundle can import from here
import * as env from './env.js';
declare var self: env.ServiceWindow;
import { ServiceWorker } from './classes.serviceworker.js';
const sw = new ServiceWorker(self);
export const getServiceWorkerInstance = (): ServiceWorker => sw;