Merge pull request #893 from kuangshen04/PR-Branch

service-worker增加sourceMap(顺便塞了8mb)
This commit is contained in:
Spmario233 2024-02-02 22:01:20 +08:00 committed by GitHub
commit eb3046fcf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 188477 additions and 17 deletions

1
.gitignore vendored
View File

@ -28,4 +28,3 @@ noname.ico
package-lock.json
package.json
Thumbs.db
game/typescript.js

188461
game/typescript.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -32,22 +32,22 @@ self.addEventListener('fetch', event => {
// @ts-ignore
event.respondWith(
res.then(res => {
if (res.status != 200) {
return res;
} else {
console.log('正在编译', request.url);
return res.text().then(text => {
const js = ts.transpile(text, { module: ts.ModuleKind.ES2015 });
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
status: 200,
statusText: "OK",
headers: new Headers({
"Content-Type": "text/javascript"
}),
});
return rep;
})
}
if (res.status != 200) return res;
console.log('正在编译', request.url);
return res.text().then(text => {
const js = ts.transpile(text, {
module: ts.ModuleKind.ES2015,
inlineSourceMap: true
}, request.url);
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
status: 200,
statusText: "OK",
headers: new Headers({
"Content-Type": "text/javascript"
}),
});
return rep;
})
})
.catch(e => {
console.log(e);