Skip to content

Commit 71c27da

Browse files
committed
Minify npm polyfills
1 parent 736cdf6 commit 71c27da

23 files changed

+28
-25
lines changed

server/build_resolver.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server
22

33
import (
4+
"bytes"
45
"crypto/sha1"
56
"encoding/base64"
67
"encoding/hex"
@@ -784,6 +785,8 @@ func (ctx *BuildContext) resolveExternalModule(specifier string, kind api.Resolv
784785
} else {
785786
data, err := embedFS.ReadFile(("server/embed/polyfills/npm_" + specifier + ".js"))
786787
if err == nil {
788+
data = bytes.ReplaceAll(data, []byte{';', '\n'}, []byte{';'})
789+
data = bytes.TrimSuffix(data, []byte{';'})
787790
resolvedPath = fmt.Sprintf("data:text/javascript;base64,%s", base64.StdEncoding.EncodeToString(data))
788791
return
789792
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const AbortSignal = globalThis.AbortSignal;
2-
export const AbortController = globalThis.AbortController;
1+
export const AbortSignal=globalThis.AbortSignal;
2+
export const AbortController=globalThis.AbortController;
33
export default AbortController;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const every = (a, p, t) => a.every(p, t);
1+
export const every=(a,p,t)=>a.every(p,t);
22
export default every;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const flatten = (a, d) => a.flat(typeof d < "u" ? d : Infinity);
1+
export const flatten=(a,d)=>a.flat(typeof d<"u"?d:Infinity);
22
export default flatten;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default (a, p, i) => a.includes(p, i);
1+
export default (a,p,i)=>a.includes(p,i);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default (a, predicate, thisArg) => a.find(predicate, thisArg);
1+
export default (a,p,t)=>a.find(p,t);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default (a, predicate, thisArg) => a.filter(predicate, thisArg);
1+
export default (a,p,t)=>a.filter(p,t);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
1+
export default (obj,prop)=>Object.prototype.hasOwnProperty.call(obj,prop);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default Object.hasOwn ?? ((o, p) => Object.prototype.hasOwnProperty.call(o, p));
1+
export default Object.hasOwn??((o,p)=>Object.prototype.hasOwnProperty.call(o,p));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const foo = { bar: {} };
2-
const O = Object;
3-
export default () => ({ __proto__: foo }).bar === foo.bar && !({ __proto__: null } instanceof O);
1+
const foo={bar:{}};
2+
const O=Object;
3+
export default ()=>({__proto__:foo}).bar===foo.bar&&!({__proto__:null}instanceof O);

0 commit comments

Comments
 (0)