Skip to content

Commit

Permalink
Revert "shell: experiment with esbuild and terser"
Browse files Browse the repository at this point in the history
This reverts commit ddab90c.
  • Loading branch information
takase1121 committed Jun 5, 2024
1 parent ddab90c commit db038df
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 159 deletions.
2 changes: 1 addition & 1 deletion scripts/gh-pages-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $file_packager "${dest_dir}/lite-xl-files.json" \
--no-force --no-node --use-preload-cache --use-preload-plugins \
--quiet --js-output="${dest_dir}/lite-xl-files.js"
# this file is rather big, run closure compiler over the output
node shell/esbuild.js "${dest_dir}/lite-xl-files.min.js" true "${dest_dir}/lite-xl-files.js"
node shell/closure.js "${dest_dir}/lite-xl-files.min.js" "${dest_dir}/lite-xl-files.js"
# these files can be removed for final distribution
rm -rf "$(pwd)/${dest_dir}/lite-xl.js" "$(pwd)/${dest_dir}/lite-xl-files.js" \
"${data_dir}" "$(pwd)/${dest_dir}/doc"
Expand Down
22 changes: 4 additions & 18 deletions shell/esbuild.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
const installAndRun = require("./deps");

installAndRun((outputFile, minify, entrypoint, ...inject) => {
installAndRun((outputFile, minify, ...entrypoints) => {
const esbuild = require("esbuild");
const { minify_sync } = require("terser");
const { writeFileSync } = require("fs");
const output = esbuild.buildSync({
entryPoints: [entrypoint],
esbuild.buildSync({
entryPoints: entrypoints,
bundle: true,
minify: entrypoint.endsWith("js") ? false : minify == "true",
minify: minify === "true",
target: "es2017",
logLevel: "info",
outfile: outputFile,
write: !entrypoint.endsWith("js"),
inject,
});
if (entrypoint.endsWith("js") && minify == "true") {
const minified = minify_sync(output.outputFiles[0].text, {
compress: {
booleans_as_integers: true,
ecma: 2017,
passes: 3,
},
});
writeFileSync(outputFile, minified.code, { encoding: "utf8" });
}
});
23 changes: 18 additions & 5 deletions shell/js/meson.build
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
main_src = [
'main.js',
'idbsync.js',
'fs.js',
]

main_bundle = custom_target('main.bundle.js',
input: main_src,
output: 'main.bundle.js',
depend_files: [package_lock, esbuild_script],
# esbuild only needs the entrypoint to figure out what files to bundle
command: [node_exe, esbuild_script , '@OUTPUT@', 'false', '@INPUT0@'])

custom_target('main.js',
input: ['main.js', lite_exe],
input: [lite_exe, main_bundle],
output: 'main.js',
build_by_default: true,
depend_files: [package_lock, esbuild_script],
depend_files: [package_lock, closure_script, closure_externs],
install: true,
install_dir: lite_bindir,
# esbuild only needs the entrypoint to figure out what files to bundle
command: [node_exe, esbuild_script , '@OUTPUT@', 'true', '@INPUT@'])
# the first must be the entrypoint
command: [node_exe, closure_script , '@OUTPUT@', '@INPUT@'])

custom_target('advanced.js',
input: 'advanced.js',
output: 'advanced.js',
build_by_default: true,
depend_files: [package_lock, esbuild_script],
build_by_default: true,
install: true,
install_dir: lite_bindir,
# esbuild only needs the entrypoint to figure out what files to bundle
Expand Down
134 changes: 1 addition & 133 deletions shell/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions shell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"devDependencies": {
"esbuild": "^0.21.1",
"google-closure-compiler": "^20240317.0.0",
"prettier": "^3.2.5",
"terser": "^5.31.0"
"prettier": "^3.2.5"
},
"dependencies": {
"fflate": "^0.8.2"
Expand Down

0 comments on commit db038df

Please sign in to comment.