diff options
author | tdro <tdro@noreply.example.com> | 2023-03-25 07:56:24 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-03-25 07:56:24 -0400 |
commit | 2a69db5d88ce4acda8e7892a351c6a7c790d3172 (patch) | |
tree | 558b83c536e7a517910bab3764b4608c5d9dd1a7 | |
parent | 14a2e29356872aeb49426ae70a0578bdfc58b29d (diff) | |
download | canory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.tar.gz canory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.tar.bz2 canory-2a69db5d88ce4acda8e7892a351c6a7c790d3172.zip |
static/js: Deno bundle is deprecated - replicate
Color outside the lines.. Maybe change to full async no/decoupled build and
leave deno for creating eventual APIs for hugo to consume?
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | assets/js/index.js | 6 | ||||
-rw-r--r-- | shell.nix | 1 | ||||
-rw-r--r-- | static/js/bundle.ts | 21 |
4 files changed, 24 insertions, 6 deletions
@@ -11,7 +11,7 @@ watch: while true; do find . | entr -d -s 'make all'; done js: - deno bundle --no-check --config tsconfig.json static/js/index.ts assets/js/index.js + deno run --allow-all static/js/bundle.ts hugo: rm -rf public diff --git a/assets/js/index.js b/assets/js/index.js index c771211..cc61f84 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -1,7 +1,3 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file -// This code was bundled using `deno bundle` and it's not recommended to edit it manually - (function() { const cookiesDisabled = !navigator.cookieEnabled; if (cookiesDisabled) { @@ -568,4 +564,4 @@ }, 1000); }); })(); -console.log("Surface Control: Complete"); +console.log("Surface Control: Complete");
\ No newline at end of file @@ -39,6 +39,7 @@ let /usr/bin/env --ignore-environment /bin/sh -c ${ pkgs.writeScript name '' export PS1='\h (${name}) \W \$ ' + export DENO_DIR=vendor export PATH=${pkgs.lib.strings.makeBinPath [ hugo validatornu diff --git a/static/js/bundle.ts b/static/js/bundle.ts new file mode 100644 index 0000000..ac858c4 --- /dev/null +++ b/static/js/bundle.ts @@ -0,0 +1,21 @@ +import { bundle } from "https://deno.land/x/emit@0.17.0/mod.ts"; + +function removeSourceMap(text): string { + return text.replace(/^\/\/# sourceMappingURL.*$/gm, "").trim(); +} + +const entrypoint = await bundle( + "./static/js/index.ts", +); + +const output = removeSourceMap(entrypoint.code); +const file = Deno.cwd() + "/assets/js/index.js"; +const fileSize = ((await Deno.stat(file)).size / 1024).toFixed(2) + "kB"; + +await Deno.writeTextFile(file, output, {}); + +console.log( + `Bundle file:///${file}` + + "\n" + + `Emit file:///${file} (${fileSize})`, +); |