uncloseai.com/scripts/bundle-extension.mjs
russell@unturf.com 12e9e79f25 disable TTS via feature flag, move floating button up 121px, add bug tickets
TTS disabled by default for all users (tickets #002 freeze, #003 truncation).
Embedders re-enable with window.UNCLOSEAI_ENABLE_TTS = true.
Floating button bottom 20px to 141px to avoid overlapping page buttons.
Added docs/tickets/ with 5 issues from cthegray.
Bundle extension script and biome config updates.
2026-03-03 15:56:09 -05:00

56 lines
1.6 KiB
JavaScript

// Bundle uncloseai.js into a single IIFE for browser extension use.
// Resolves CDN imports (marked, highlight.js) to local node_modules.
// Output: public/uncloseai-bundle.js (CSP-safe, no ES module syntax)
import { build } from "esbuild";
import { createRequire } from "module";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(__dirname, "..");
const require = createRequire(import.meta.url);
// Plugin: resolve CDN URL imports to local node_modules packages
const cdnResolverPlugin = {
name: "cdn-resolver",
setup(build) {
// marked: https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js
build.onResolve(
{ filter: /^https:\/\/cdn\.jsdelivr\.net\/npm\/marked/ },
() => ({
path: require.resolve("marked"),
}),
);
// highlight.js: https://cdnjs.cloudflare.com/ajax/libs/highlight.js/
build.onResolve(
{ filter: /^https:\/\/cdnjs\.cloudflare\.com\/ajax\/libs\/highlight\.js/ },
() => ({
path: require.resolve("highlight.js"),
}),
);
},
};
try {
const result = await build({
entryPoints: [path.join(ROOT, "public", "uncloseai.js")],
bundle: true,
format: "iife",
minify: true,
sourcemap: false,
outfile: path.join(ROOT, "public", "uncloseai-bundle.js"),
plugins: [cdnResolverPlugin],
target: ["chrome120", "firefox120", "safari17"],
logLevel: "info",
});
if (result.errors.length > 0) {
console.error("Build failed with errors");
process.exit(1);
}
} catch (err) {
console.error("Bundle failed:", err.message);
process.exit(1);
}