From 0729a3efa8cd14b776685fbad556d22b9a0b929b Mon Sep 17 00:00:00 2001
From: Avad3 <65318266+Avad3@users.noreply.github.com>
Date: Fri, 28 Jun 2024 18:56:37 -0400
Subject: [PATCH] add treeshaking + bugfix
---
.gitignore | 3 ++-
esbuild.js | 10 ++++++++--
src/bundle/rewriters/html.ts | 5 ++---
static/ui.js | 3 ++-
tsconfig.json | 16 ++++++++--------
5 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/.gitignore b/.gitignore
index 5c3bd53..3923901 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ static/scramjet*
static/bare-mux.js
static/bare-client.js
static/curl-client.js
-static/epoxy-client.js
\ No newline at end of file
+static/epoxy-client.js
+meta.json
diff --git a/esbuild.js b/esbuild.js
index 8ebf1fc..859724c 100644
--- a/esbuild.js
+++ b/esbuild.js
@@ -1,7 +1,8 @@
import { build } from "esbuild";
import time from "esbuild-plugin-time";
+// import { writeFileSync } from "fs"
-build({
+const scramjetBuild = await build({
entryPoints: {
client: "./src/client/index.ts",
bundle: "./src/bundle/index.ts",
@@ -16,4 +17,9 @@ build({
time()
],
logLevel: "info",
-});
\ No newline at end of file
+ // metafile: true,
+ treeShaking: true,
+ minify: true
+});
+
+// writeFileSync("./meta.json", JSON.stringify(scramjetBuild.metafile));
diff --git a/src/bundle/rewriters/html.ts b/src/bundle/rewriters/html.ts
index 08d7bce..e0deb3b 100644
--- a/src/bundle/rewriters/html.ts
+++ b/src/bundle/rewriters/html.ts
@@ -31,8 +31,7 @@ function traverseParsedHtml(node, origin?: URL) {
if (hasAttrib(node, "data")) node.attribs.data = encodeUrl(node.attribs.data, origin);
if (hasAttrib(node, "action")) node.attribs.action = encodeUrl(node.attribs.action, origin);
if (hasAttrib(node, "formaction")) node.attribs.formaction = encodeUrl(node.attribs.formaction, origin);
- if (hasAttrib(node, "form")) node.attribs.action = encodeUrl(node.attribs.action, origin);
-
+
/* other */
if (hasAttrib(node, "srcdoc")) node.attribs.srcdoc = rewriteHtml(node.attribs.srcdoc, origin);
if (hasAttrib(node, "srcset")) node.attribs.srcset = rewriteSrcset(node.attribs.srcset, origin);
@@ -84,4 +83,4 @@ export function rewriteSrcset(srcset: string, origin?: URL) {
});
return rewrittenUrls.join("");
-}
\ No newline at end of file
+}
diff --git a/static/ui.js b/static/ui.js
index a737af4..6d0c3e6 100644
--- a/static/ui.js
+++ b/static/ui.js
@@ -85,6 +85,7 @@ function App() {
+
(store.url = e.target.value)} on:keyup=${(e) => e.keyCode == 13 && console.log(this.urlencoded = __scramjet$config.prefix + __scramjet$config.codec.encode(e.target.value))} />
@@ -95,4 +96,4 @@ function App() {
window.addEventListener("load", () => {
document.body.appendChild(h(App))
-})
\ No newline at end of file
+})
diff --git a/tsconfig.json b/tsconfig.json
index 6839507..7ac7e40 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,10 +1,10 @@
{
- "compilerOptions": {
- // "allowJs": true,
- "allowImportingTsExtensions": true,
- "rootDir": "./src",
- "target": "ES2020",
- "moduleResolution": "Bundler",
- "noEmit": true,
- }
+ "compilerOptions": {
+ // "allowJs": true,
+ "allowImportingTsExtensions": true,
+ "rootDir": "./src",
+ "target": "ES2020",
+ "moduleResolution": "Bundler",
+ "noEmit": true
+ }
}
\ No newline at end of file