feature: client: sw: migrate to ESM

This commit is contained in:
coderiaser 2026-01-27 20:35:38 +02:00
parent 54c89e52f8
commit 27a52d33d0
7 changed files with 19 additions and 15 deletions

View file

@ -285,10 +285,12 @@ function setUrl(req, res, next) {
function setSW(req, res, next) {
const {url} = req;
const isSW = /^\/sw\.js(\.map)?$/.test(url);
const isSW = /^\/sw\.[mc]?js(\.map)?$/.test(url);
if (isSW)
if (isSW) {
const url = req.url.replace(/[cm]js/, 'js');
req.url = replaceDist(`/dist${url}`);
}
next();
}

View file

@ -173,7 +173,7 @@ test('cloudcmd: getIndexPath: development', (t) => {
});
test('cloudcmd: sw', async (t) => {
const {status} = await request.get('/sw.js');
const {status} = await request.get('/sw.mjs');
t.equal(status, 200, 'should return sw');
t.end();