1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-24 01:29:36 +01:00

♻️ Update build script to support minification levels

Full minification by default
This commit is contained in:
Jan Andrle 2023-10-19 14:23:10 +02:00
parent 46869736d5
commit 19fd857dac
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
5 changed files with 71 additions and 1765 deletions

View File

@ -2,39 +2,43 @@
const files= [ "index.js", "index-with-signals.js" ]; const files= [ "index.js", "index-with-signals.js" ];
const filesOut= (file, mark= "esm")=> "dist/"+file.replace("index", mark); const filesOut= (file, mark= "esm")=> "dist/"+file.replace("index", mark);
for(const file of files){ $.api("", true)
const out= filesOut(file); .option("--minify", "Level of minification [ full (default), partial ]")
s.run([ .action(function main({ minify= "full" }){
"npx esbuild '::file::'", for(const file of files){
"--platform=neutral", const out= filesOut(file);
"--bundle", s.run([
//"--minify", "npx esbuild '::file::'",
"--minify-syntax --minify-identifiers", "--platform=neutral",
"--legal-comments=inline", "--bundle",
"--packages=external", minify==="full" ? "--minify" : "--minify-syntax --minify-identifiers",
"--outfile='::out::'" "--legal-comments=inline",
].join(" "), { file, out }); "--packages=external",
pipe( "--outfile='::out::'"
f=> f.replace(/^ +/gm, m=> "\t".repeat(m.length/2)), ].join(" "), { file, out });
f=> s.echo(f).to(out) pipe(
)(s.cat(out)); f=> f.replace(/^ +/gm, m=> "\t".repeat(m.length/2)),
toDDE(out, filesOut(file, "dde")); f=> s.echo(f).to(out)
} )(s.cat(out));
$.exit(0); toDDE(out, filesOut(file, "dde"));
}
$.exit(0);
function toDDE(file, out){ function toDDE(file, out){
const name= "dde"; const name= "dde";
echo(`\n ${out} (${file} → globalThis.${name})\n`); echo(`\n ${out} (${file} → globalThis.${name})\n`);
let content= s.cat(file).toString().split(/export ?{/); let content= s.cat(file).toString().split(/export ?{/);
content.splice(1, 0, `\nglobalThis.${name}= {`); content.splice(1, 0, `\nglobalThis.${name}= {`);
content[2]= content[2].replace(/^(\t*)(.*) as ([^,\n]*)(,?)$/mg, "$1$3: $2$4"); content[2]= content[2].replace(/,(?!\n)/g, ",\n").replace(/(?<!\n)}/, "\n}").replace(/^(\t*)(.*) as ([^,\n]*)(,?)$/mg, "$1$3: $2$4");
s.echo([ s.echo([
`//deka-dom-el library is available via global namespace \`${name}\``, `//deka-dom-el library is available via global namespace \`${name}\``,
"(()=> {", "(()=> {",
"\t"+content.join("").split("\n").join("\n "), content.join(""),
"})();" "})();"
].join("\n")).to(out); ].join("\n")).to(out);
echo("⚡ Done\n"); echo("⚡ Done\n");
} }
})
.parse();

File diff suppressed because one or more lines are too long

351
dist/dde.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

339
dist/esm.js vendored

File diff suppressed because one or more lines are too long