diff --git a/changelog.md b/changelog.md index c1e386c..13911f3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-12-04 - 6.8.1 - fix(web_serviceworker) +Move service worker initialization to init.ts and remove exports from service worker entrypoint to avoid ESM bundle output + +- Remove exports from ts_web_serviceworker/index.ts so the service worker entrypoint does not export symbols (prevents tsbundle from producing ESM output). +- Add ts_web_serviceworker/init.ts which initializes the ServiceWorker instance and exports getServiceWorkerInstance() for internal imports. +- Update ts_web_serviceworker/classes.dashboard.ts to import getServiceWorkerInstance from init.ts instead of index.ts. + ## 2025-12-04 - 6.8.0 - feat(swdash) Add SW-Dash (Lit-based service worker dashboard), bundle & serve it; improve servertools and static handlers diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index aee7939..b413903 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedserver', - version: '6.8.0', + version: '6.8.1', description: 'A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.' } diff --git a/ts_web_serviceworker/classes.dashboard.ts b/ts_web_serviceworker/classes.dashboard.ts index de6a31e..46a26e4 100644 --- a/ts_web_serviceworker/classes.dashboard.ts +++ b/ts_web_serviceworker/classes.dashboard.ts @@ -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'; /** diff --git a/ts_web_serviceworker/index.ts b/ts_web_serviceworker/index.ts index 14a622a..c98daba 100644 --- a/ts_web_serviceworker/index.ts +++ b/ts_web_serviceworker/index.ts @@ -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'; diff --git a/ts_web_serviceworker/init.ts b/ts_web_serviceworker/init.ts new file mode 100644 index 0000000..dd96ada --- /dev/null +++ b/ts_web_serviceworker/init.ts @@ -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;