From 24483ab3293dd216aab1bd6c9c7b45465904eaad Mon Sep 17 00:00:00 2001 From: Christian Biasuzzi Date: Mon, 28 Oct 2024 15:31:00 +0100 Subject: [PATCH] Fix JS dependencies bundler's settings (widgets work in other notebook frontends) (#31) Signed-off-by: Christian Biasuzzi --- esbuild.mjs | 14 ++++++++++++++ package.json | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 esbuild.mjs diff --git a/esbuild.mjs b/esbuild.mjs new file mode 100644 index 0000000..3b9f681 --- /dev/null +++ b/esbuild.mjs @@ -0,0 +1,14 @@ +import esbuild from "esbuild"; + +esbuild.build({ + entryPoints: ["js/*.ts", "js/*.jsx"], + bundle: true, + minify: true, + target: ["es2020"], + outdir: "src/pypowsybl_jupyter/static/", + format: "esm", + // Ref. https://github.com/powsybl/pypowsybl-jupyter/issues/30, https://github.com/manzt/anywidget/issues/506 and https://github.com/manzt/anywidget/issues/369#issuecomment-1792376003 + define: { + "define.amd": "false", + }, +}); diff --git a/package.json b/package.json index fb8e783..f68ef2e 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ }, "scripts": { "dev": "npm run build -- --sourcemap=inline --watch", - "build": "esbuild js/*.ts js/*.jsx --minify --format=esm --bundle --outdir=src/pypowsybl_jupyter/static", + "build": "node ./esbuild.mjs", "typecheck": "tsc --noEmit", "lint": "eslint . --ext js,ts,jsx --max-warnings 0" },