Merge pull request #893 from kuangshen04/PR-Branch
service-worker增加sourceMap(顺便塞了8mb)
This commit is contained in:
commit
eb3046fcf6
|
@ -28,4 +28,3 @@ noname.ico
|
||||||
package-lock.json
|
package-lock.json
|
||||||
package.json
|
package.json
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
game/typescript.js
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -32,22 +32,22 @@ self.addEventListener('fetch', event => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
res.then(res => {
|
res.then(res => {
|
||||||
if (res.status != 200) {
|
if (res.status != 200) return res;
|
||||||
return res;
|
console.log('正在编译', request.url);
|
||||||
} else {
|
return res.text().then(text => {
|
||||||
console.log('正在编译', request.url);
|
const js = ts.transpile(text, {
|
||||||
return res.text().then(text => {
|
module: ts.ModuleKind.ES2015,
|
||||||
const js = ts.transpile(text, { module: ts.ModuleKind.ES2015 });
|
inlineSourceMap: true
|
||||||
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
|
}, request.url);
|
||||||
status: 200,
|
const rep = new Response(new Blob([js], { type: "text/javascript" }), {
|
||||||
statusText: "OK",
|
status: 200,
|
||||||
headers: new Headers({
|
statusText: "OK",
|
||||||
"Content-Type": "text/javascript"
|
headers: new Headers({
|
||||||
}),
|
"Content-Type": "text/javascript"
|
||||||
});
|
}),
|
||||||
return rep;
|
});
|
||||||
})
|
return rep;
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|
Loading…
Reference in New Issue