summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/bin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /devtools/client/debugger/bin
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/bin')
-rw-r--r--devtools/client/debugger/bin/bundle.js86
-rw-r--r--devtools/client/debugger/bin/watch.js31
2 files changed, 117 insertions, 0 deletions
diff --git a/devtools/client/debugger/bin/bundle.js b/devtools/client/debugger/bin/bundle.js
new file mode 100644
index 0000000000..b44f7dcd70
--- /dev/null
+++ b/devtools/client/debugger/bin/bundle.js
@@ -0,0 +1,86 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+const path = require("path");
+const { rollup } = require("rollup");
+const nodeResolve = require("@rollup/plugin-node-resolve");
+const commonjs = require("@rollup/plugin-commonjs");
+const injectProcessEnv = require("rollup-plugin-inject-process-env");
+const nodePolyfills = require("rollup-plugin-node-polyfills");
+
+const projectPath = path.resolve(__dirname, "..");
+const bundlePath = path.join(projectPath, "./dist");
+
+process.env.NODE_ENV = "production";
+
+function getEntry(filename) {
+ return path.join(__dirname, "..", filename);
+}
+
+/**
+ * The `bundle` module will build the following:
+ * - parser-worker.js, pretty-print-worker.js, search-worker:
+ * Workers used only by the debugger.
+ * Sources at devtools/client/debugger/src/workers/*
+ */
+(async function bundle() {
+ const rollupSucceeded = await bundleRollup();
+ process.exit(rollupSucceeded ? 0 : 1);
+})();
+
+/**
+ * Generates all dist/*-worker.js files
+ */
+async function bundleRollup() {
+ console.log(`[bundle|rollup] Start bundling…`);
+
+ let success = true;
+
+ // We need to handle workers 1 by 1 to be able to generate umd bundles.
+ const entries = {
+ "parser-worker": getEntry("src/workers/parser/worker.js"),
+ "pretty-print-worker": getEntry("src/workers/pretty-print/worker.js"),
+ "search-worker": getEntry("src/workers/search/worker.js"),
+ };
+
+ for (const [entryName, input] of Object.entries(entries)) {
+ let bundle;
+ try {
+ // create a bundle
+ bundle = await rollup({
+ input: {
+ [entryName]: input,
+ },
+ plugins: [
+ commonjs({
+ transformMixedEsModules: true,
+ strictRequires: true,
+ }),
+ injectProcessEnv({ NODE_ENV: "production" }),
+ nodeResolve(),
+ // read-wasm.js is part of source-map and is only for Node environment.
+ // we need to ignore it, otherwise __dirname is inlined with the path the bundle
+ // is generated from, which makes the verify-bundle task fail
+ nodePolyfills({ exclude: [/read-wasm\.js/] }),
+ ],
+ });
+ await bundle.write({
+ dir: bundlePath,
+ entryFileNames: "[name].js",
+ format: "umd",
+ });
+ } catch (error) {
+ success = false;
+ // do some error reporting
+ console.error("[bundle|rollup] Something went wrong.", error);
+ }
+ if (bundle) {
+ // closes the bundle
+ await bundle.close();
+ }
+ }
+
+ console.log(`[bundle|rollup] Done bundling`);
+ return success;
+}
diff --git a/devtools/client/debugger/bin/watch.js b/devtools/client/debugger/bin/watch.js
new file mode 100644
index 0000000000..d4d02e18ca
--- /dev/null
+++ b/devtools/client/debugger/bin/watch.js
@@ -0,0 +1,31 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+var chokidar = require("chokidar");
+var shell = require("shelljs");
+var path = require("path");
+
+const geckoPath = path.join(__dirname, "../../../..");
+const srcPath = path.join(__dirname, "../src");
+function watch() {
+ console.log("Watching for src changes");
+ const watcher = chokidar.watch(srcPath);
+ let working = false;
+ watcher.on("change", filePath => {
+ const relPath = path.relative(srcPath, filePath);
+ console.log(`Updating ${relPath}`);
+ if (working) {
+ return;
+ }
+ working = true;
+ const start = new Date();
+
+ shell.exec(`cd ${geckoPath}; ./mach build faster; cd -;`, { silent: true });
+ working = false;
+ const end = Math.round((new Date() - start) / 1000);
+ console.log(` Built in ${end}s`);
+ });
+}
+
+watch();