From 1d32fd3c8dbb8935b5bc2361b69ebb31aafe0708 Mon Sep 17 00:00:00 2001 From: Matthew Cheely Date: Thu, 9 Jan 2025 19:46:07 +1300 Subject: [PATCH 1/2] feat(ifc-cli): enable static file hosting in ifc-cli server This allows ifc-cli to serve static files in addition to acting as a proxy to a dev server, for simpler client-embedding setups. We have also updated the example app to use this hosting in conjunction with build changes that make it easier to build both an app js file and web workers for future IFC features --- apps/ifc-example-client/README.md | 7 + .../{main.js => client-app.js} | 0 apps/ifc-example-client/client-worker.js | 7 + apps/ifc-example-client/ifc-proxy.config.json | 4 +- apps/ifc-example-client/package.json | 7 +- apps/ifc-example-client/rollup.config.js | 18 ++ apps/ifc-example-client/vite.config.js | 14 -- package-lock.json | 199 +++++++++++------- packages/iframe-coordinator-cli/ifc-cli.js | 46 +++- 9 files changed, 197 insertions(+), 105 deletions(-) rename apps/ifc-example-client/{main.js => client-app.js} (100%) create mode 100644 apps/ifc-example-client/client-worker.js create mode 100644 apps/ifc-example-client/rollup.config.js delete mode 100644 apps/ifc-example-client/vite.config.js diff --git a/apps/ifc-example-client/README.md b/apps/ifc-example-client/README.md index e586855..134dc1e 100644 --- a/apps/ifc-example-client/README.md +++ b/apps/ifc-example-client/README.md @@ -16,3 +16,10 @@ commands from the iframe-coordinator project root (the parent directory of this `npm run start-client-example` You can then see the apps embedded in a host at http://localhost:3000/#/app1 and http://localhost:3000/#/app2 + +### Notes + +There's no hot-reloading in development mode, so you'll need to refresh the page +after making changes. The dev mode uses a rollup watcher rather than a server like +Vite because building stand-alone web-worker modules is particularly challenging +with Vite. diff --git a/apps/ifc-example-client/main.js b/apps/ifc-example-client/client-app.js similarity index 100% rename from apps/ifc-example-client/main.js rename to apps/ifc-example-client/client-app.js diff --git a/apps/ifc-example-client/client-worker.js b/apps/ifc-example-client/client-worker.js new file mode 100644 index 0000000..65866e1 --- /dev/null +++ b/apps/ifc-example-client/client-worker.js @@ -0,0 +1,7 @@ +// This module is a POC placeholder for a future IFC-integrated web-worker example + +// This doesn't work because Client references HTMLElement, which doesn't exist +// in the worker context, but will work for a new worker client. +// import { Client } from "iframe-coordinator/dist/client.js"; + +console.log("Worker Started!"); diff --git a/apps/ifc-example-client/ifc-proxy.config.json b/apps/ifc-example-client/ifc-proxy.config.json index b767865..f1cd7a9 100644 --- a/apps/ifc-example-client/ifc-proxy.config.json +++ b/apps/ifc-example-client/ifc-proxy.config.json @@ -1,3 +1,5 @@ { - "/clients/": "http://localhost:8080/" + "static": { + "/clients": "." + } } diff --git a/apps/ifc-example-client/package.json b/apps/ifc-example-client/package.json index f740c96..e68b517 100644 --- a/apps/ifc-example-client/package.json +++ b/apps/ifc-example-client/package.json @@ -13,14 +13,15 @@ "type": "module", "scripts": { "start": "concurrently \"npm:dev\" \"npm:start-host-shim\"", - "dev": "vite --port 8080", - "build": "vite build", + "dev": "rollup -c --watch", + "build": "rollup -c", "start-host-shim": "ifc-cli" }, "devDependencies": { + "@rollup/plugin-node-resolve": "^16.0.0", "concurrently": "^8.2.2", "iframe-coordinator-cli": "file:../../packages/iframe-coordinator-cli", - "vite": "^5.4.2" + "rollup": "^4.30.1" }, "dependencies": { "@babel/polyfill": "^7.12.1", diff --git a/apps/ifc-example-client/rollup.config.js b/apps/ifc-example-client/rollup.config.js new file mode 100644 index 0000000..db47e01 --- /dev/null +++ b/apps/ifc-example-client/rollup.config.js @@ -0,0 +1,18 @@ +import { nodeResolve } from "@rollup/plugin-node-resolve"; + +import { dirname, resolve } from "path"; +import { fileURLToPath } from "url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +export default { + input: [ + resolve(__dirname, "client-app.js"), + resolve(__dirname, "client-worker.js"), + ], + output: { + preserveModules: false, + dir: "dist", + }, + plugins: [nodeResolve()], +}; diff --git a/apps/ifc-example-client/vite.config.js b/apps/ifc-example-client/vite.config.js deleted file mode 100644 index 625b684..0000000 --- a/apps/ifc-example-client/vite.config.js +++ /dev/null @@ -1,14 +0,0 @@ -// vite.config.js -import { resolve } from "path"; -import { defineConfig } from "vite"; - -export default defineConfig({ - build: { - lib: { - entry: resolve(__dirname, "main.js"), - name: "clientApp", - // the proper extensions will be added - fileName: "client-app", - }, - }, -}); diff --git a/package-lock.json b/package-lock.json index 0d5ca78..72f5dbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,9 +35,34 @@ "url-polyfill": "^1.1.12" }, "devDependencies": { + "@rollup/plugin-node-resolve": "^16.0.0", "concurrently": "^8.2.2", "iframe-coordinator-cli": "file:../../packages/iframe-coordinator-cli", - "vite": "^5.4.2" + "rollup": "^4.30.1" + } + }, + "apps/ifc-example-client/node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.0.tgz", + "integrity": "sha512-0FPvAeVUT/zdWoO0jnb/V5BlBsUSNfkIOtFHzMO4H9MOklrmQFY6FduVHKucNb/aTFxvnGhj4MNj/T1oNdDfNg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, "node_modules/@ampproject/remapping": { @@ -1333,9 +1358,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.25.0.tgz", - "integrity": "sha512-CC/ZqFZwlAIbU1wUPisHyV/XRc5RydFrNLtgl3dGYskdwPZdt4HERtKm50a/+DtTlKeCq9IXFEWR+P6blwjqBA==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.30.1.tgz", + "integrity": "sha512-pSWY+EVt3rJ9fQ3IqlrEUtXh3cGqGtPDH1FQlNZehO2yYxCHEX1SPsz1M//NXwYfbTlcKr9WObLnJX9FsS9K1Q==", "cpu": [ "arm" ], @@ -1346,9 +1371,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.25.0.tgz", - "integrity": "sha512-/Y76tmLGUJqVBXXCfVS8Q8FJqYGhgH4wl4qTA24E9v/IJM0XvJCGQVSW1QZ4J+VURO9h8YCa28sTFacZXwK7Rg==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.30.1.tgz", + "integrity": "sha512-/NA2qXxE3D/BRjOJM8wQblmArQq1YoBVJjrjoTSBS09jgUisq7bqxNHJ8kjCHeV21W/9WDGwJEWSN0KQ2mtD/w==", "cpu": [ "arm64" ], @@ -1359,9 +1384,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.25.0.tgz", - "integrity": "sha512-YVT6L3UrKTlC0FpCZd0MGA7NVdp7YNaEqkENbWQ7AOVOqd/7VzyHpgIpc1mIaxRAo1ZsJRH45fq8j4N63I/vvg==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.30.1.tgz", + "integrity": "sha512-r7FQIXD7gB0WJ5mokTUgUWPl0eYIH0wnxqeSAhuIwvnnpjdVB8cRRClyKLQr7lgzjctkbp5KmswWszlwYln03Q==", "cpu": [ "arm64" ], @@ -1372,9 +1397,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.25.0.tgz", - "integrity": "sha512-ZRL+gexs3+ZmmWmGKEU43Bdn67kWnMeWXLFhcVv5Un8FQcx38yulHBA7XR2+KQdYIOtD0yZDWBCudmfj6lQJoA==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.30.1.tgz", + "integrity": "sha512-x78BavIwSH6sqfP2xeI1hd1GpHL8J4W2BXcVM/5KYKoAD3nNsfitQhvWSw+TFtQTLZ9OmlF+FEInEHyubut2OA==", "cpu": [ "x64" ], @@ -1385,9 +1410,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.25.0.tgz", - "integrity": "sha512-xpEIXhiP27EAylEpreCozozsxWQ2TJbOLSivGfXhU4G1TBVEYtUPi2pOZBnvGXHyOdLAUUhPnJzH3ah5cqF01g==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.30.1.tgz", + "integrity": "sha512-HYTlUAjbO1z8ywxsDFWADfTRfTIIy/oUlfIDmlHYmjUP2QRDTzBuWXc9O4CXM+bo9qfiCclmHk1x4ogBjOUpUQ==", "cpu": [ "arm64" ], @@ -1398,9 +1423,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.25.0.tgz", - "integrity": "sha512-sC5FsmZGlJv5dOcURrsnIK7ngc3Kirnx3as2XU9uER+zjfyqIjdcMVgzy4cOawhsssqzoAX19qmxgJ8a14Qrqw==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.30.1.tgz", + "integrity": "sha512-1MEdGqogQLccphhX5myCJqeGNYTNcmTyaic9S7CG3JhwuIByJ7J05vGbZxsizQthP1xpVx7kd3o31eOogfEirw==", "cpu": [ "x64" ], @@ -1411,9 +1436,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.25.0.tgz", - "integrity": "sha512-uD/dbLSs1BEPzg564TpRAQ/YvTnCds2XxyOndAO8nJhaQcqQGFgv/DAVko/ZHap3boCvxnzYMa3mTkV/B/3SWA==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.30.1.tgz", + "integrity": "sha512-PaMRNBSqCx7K3Wc9QZkFx5+CX27WFpAMxJNiYGAXfmMIKC7jstlr32UhTgK6T07OtqR+wYlWm9IxzennjnvdJg==", "cpu": [ "arm" ], @@ -1424,9 +1449,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.25.0.tgz", - "integrity": "sha512-ZVt/XkrDlQWegDWrwyC3l0OfAF7yeJUF4fq5RMS07YM72BlSfn2fQQ6lPyBNjt+YbczMguPiJoCfaQC2dnflpQ==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.30.1.tgz", + "integrity": "sha512-B8Rcyj9AV7ZlEFqvB5BubG5iO6ANDsRKlhIxySXcF1axXYUyqwBok+XZPgIYGBgs7LDXfWfifxhw0Ik57T0Yug==", "cpu": [ "arm" ], @@ -1437,9 +1462,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.25.0.tgz", - "integrity": "sha512-qboZ+T0gHAW2kkSDPHxu7quaFaaBlynODXpBVnPxUgvWYaE84xgCKAPEYE+fSMd3Zv5PyFZR+L0tCdYCMAtG0A==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.30.1.tgz", + "integrity": "sha512-hqVyueGxAj3cBKrAI4aFHLV+h0Lv5VgWZs9CUGqr1z0fZtlADVV1YPOij6AhcK5An33EXaxnDLmJdQikcn5NEw==", "cpu": [ "arm64" ], @@ -1450,9 +1475,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.25.0.tgz", - "integrity": "sha512-ndWTSEmAaKr88dBuogGH2NZaxe7u2rDoArsejNslugHZ+r44NfWiwjzizVS1nUOHo+n1Z6qV3X60rqE/HlISgw==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.30.1.tgz", + "integrity": "sha512-i4Ab2vnvS1AE1PyOIGp2kXni69gU2DAUVt6FSXeIqUCPIR3ZlheMW3oP2JkukDfu3PsexYRbOiJrY+yVNSk9oA==", "cpu": [ "arm64" ], @@ -1462,10 +1487,23 @@ "linux" ] }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.30.1.tgz", + "integrity": "sha512-fARcF5g296snX0oLGkVxPmysetwUk2zmHcca+e9ObOovBR++9ZPOhqFUM61UUZ2EYpXVPN1redgqVoBB34nTpQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.25.0.tgz", - "integrity": "sha512-BVSQvVa2v5hKwJSy6X7W1fjDex6yZnNKy3Kx1JGimccHft6HV0THTwNtC2zawtNXKUu+S5CjXslilYdKBAadzA==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.30.1.tgz", + "integrity": "sha512-GLrZraoO3wVT4uFXh67ElpwQY0DIygxdv0BNW9Hkm3X34wu+BkqrDrkcsIapAY+N2ATEbvak0XQ9gxZtCIA5Rw==", "cpu": [ "ppc64" ], @@ -1476,9 +1514,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.25.0.tgz", - "integrity": "sha512-G4hTREQrIdeV0PE2JruzI+vXdRnaK1pg64hemHq2v5fhv8C7WjVaeXc9P5i4Q5UC06d/L+zA0mszYIKl+wY8oA==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.30.1.tgz", + "integrity": "sha512-0WKLaAUUHKBtll0wvOmh6yh3S0wSU9+yas923JIChfxOaaBarmb/lBKPF0w/+jTVozFnOXJeRGZ8NvOxvk/jcw==", "cpu": [ "riscv64" ], @@ -1489,9 +1527,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.25.0.tgz", - "integrity": "sha512-9T/w0kQ+upxdkFL9zPVB6zy9vWW1deA3g8IauJxojN4bnz5FwSsUAD034KpXIVX5j5p/rn6XqumBMxfRkcHapQ==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.30.1.tgz", + "integrity": "sha512-GWFs97Ruxo5Bt+cvVTQkOJ6TIx0xJDD/bMAOXWJg8TCSTEK8RnFeOeiFTxKniTc4vMIaWvCplMAFBt9miGxgkA==", "cpu": [ "s390x" ], @@ -1515,9 +1553,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.25.0.tgz", - "integrity": "sha512-zx71aY2oQxGxAT1JShfhNG79PnjYhMC6voAjzpu/xmMjDnKNf6Nl/xv7YaB/9SIa9jDYf8RBPWEnjcdlhlv1rQ==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.30.1.tgz", + "integrity": "sha512-V9U8Ey2UqmQsBT+xTOeMzPzwDzyXmnAoO4edZhL7INkwQcaW1Ckv3WJX3qrrp/VHaDkEWIBWhRwP47r8cdrOow==", "cpu": [ "x64" ], @@ -1528,9 +1566,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.25.0.tgz", - "integrity": "sha512-JT8tcjNocMs4CylWY/CxVLnv8e1lE7ff1fi6kbGocWwxDq9pj30IJ28Peb+Y8yiPNSF28oad42ApJB8oUkwGww==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.30.1.tgz", + "integrity": "sha512-WabtHWiPaFF47W3PkHnjbmWawnX/aE57K47ZDT1BXTS5GgrBUEpvOzq0FI0V/UYzQJgdb8XlhVNH8/fwV8xDjw==", "cpu": [ "arm64" ], @@ -1541,9 +1579,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.25.0.tgz", - "integrity": "sha512-dRLjLsO3dNOfSN6tjyVlG+Msm4IiZnGkuZ7G5NmpzwF9oOc582FZG05+UdfTbz5Jd4buK/wMb6UeHFhG18+OEg==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.30.1.tgz", + "integrity": "sha512-pxHAU+Zv39hLUTdQQHUVHf4P+0C47y/ZloorHpzs2SXMRqeAWmGghzAhfOlzFHHwjvgokdFAhC4V+6kC1lRRfw==", "cpu": [ "ia32" ], @@ -1554,9 +1592,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.25.0.tgz", - "integrity": "sha512-/RqrIFtLB926frMhZD0a5oDa4eFIbyNEwLLloMTEjmqfwZWXywwVVOVmwTsuyhC9HKkVEZcOOi+KV4U9wmOdlg==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.30.1.tgz", + "integrity": "sha512-D6qjsXGcvhTjv0kI4fU8tUuBDF/Ueee4SVX79VfNDXZa64TfCW1Slkb6Z7O1p7vflqZjcmOVdZlqf8gvJxc6og==", "cpu": [ "x64" ], @@ -9745,9 +9783,9 @@ } }, "node_modules/rollup": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.25.0.tgz", - "integrity": "sha512-uVbClXmR6wvx5R1M3Od4utyLUxrmOcEm3pAtMphn73Apq19PDtHpgZoEvqH2YnnaNUuvKmg2DgRd2Sqv+odyqg==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.30.1.tgz", + "integrity": "sha512-mlJ4glW020fPuLi7DkM/lN97mYEZGWeqBnrljzN0gs7GLctqX3lNWxKQ7Gl712UAX+6fog/L3jh4gb7R6aVi3w==", "dev": true, "dependencies": { "@types/estree": "1.0.6" @@ -9760,31 +9798,32 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.25.0", - "@rollup/rollup-android-arm64": "4.25.0", - "@rollup/rollup-darwin-arm64": "4.25.0", - "@rollup/rollup-darwin-x64": "4.25.0", - "@rollup/rollup-freebsd-arm64": "4.25.0", - "@rollup/rollup-freebsd-x64": "4.25.0", - "@rollup/rollup-linux-arm-gnueabihf": "4.25.0", - "@rollup/rollup-linux-arm-musleabihf": "4.25.0", - "@rollup/rollup-linux-arm64-gnu": "4.25.0", - "@rollup/rollup-linux-arm64-musl": "4.25.0", - "@rollup/rollup-linux-powerpc64le-gnu": "4.25.0", - "@rollup/rollup-linux-riscv64-gnu": "4.25.0", - "@rollup/rollup-linux-s390x-gnu": "4.25.0", - "@rollup/rollup-linux-x64-gnu": "4.25.0", - "@rollup/rollup-linux-x64-musl": "4.25.0", - "@rollup/rollup-win32-arm64-msvc": "4.25.0", - "@rollup/rollup-win32-ia32-msvc": "4.25.0", - "@rollup/rollup-win32-x64-msvc": "4.25.0", + "@rollup/rollup-android-arm-eabi": "4.30.1", + "@rollup/rollup-android-arm64": "4.30.1", + "@rollup/rollup-darwin-arm64": "4.30.1", + "@rollup/rollup-darwin-x64": "4.30.1", + "@rollup/rollup-freebsd-arm64": "4.30.1", + "@rollup/rollup-freebsd-x64": "4.30.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.30.1", + "@rollup/rollup-linux-arm-musleabihf": "4.30.1", + "@rollup/rollup-linux-arm64-gnu": "4.30.1", + "@rollup/rollup-linux-arm64-musl": "4.30.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.30.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.30.1", + "@rollup/rollup-linux-riscv64-gnu": "4.30.1", + "@rollup/rollup-linux-s390x-gnu": "4.30.1", + "@rollup/rollup-linux-x64-gnu": "4.30.1", + "@rollup/rollup-linux-x64-musl": "4.30.1", + "@rollup/rollup-win32-arm64-msvc": "4.30.1", + "@rollup/rollup-win32-ia32-msvc": "4.30.1", + "@rollup/rollup-win32-x64-msvc": "4.30.1", "fsevents": "~2.3.2" } }, "node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.25.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.25.0.tgz", - "integrity": "sha512-ThcnU0EcMDn+J4B9LD++OgBYxZusuA7iemIIiz5yzEcFg04VZFzdFjuwPdlURmYPZw+fgVrFzj4CA64jSTG4Ig==", + "version": "4.30.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.30.1.tgz", + "integrity": "sha512-UtgGb7QGgXDIO+tqqJ5oZRGHsDLO8SlpE4MhqpY9Llpzi5rJMvrK6ZGhsRCST2abZdBqIBeXW6WPD5fGK5SDwg==", "cpu": [ "x64" ], @@ -11715,6 +11754,14 @@ "typescript": "^4.9.5", "vite": "^5.4.2" } + }, + "packages/iframe-coordinator-cli/node_modules/iframe-coordinator": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/iframe-coordinator/-/iframe-coordinator-6.0.0.tgz", + "integrity": "sha512-M4WGIpIyh/2+jTPLGaDp/JoV9gwJYV6y1raM9y/C46WQXP+aOvbvo3+CEEoUIW9wQCbVBn1Qrc661CM5wBchJQ==", + "dependencies": { + "decoders": "1.15.0" + } } } } diff --git a/packages/iframe-coordinator-cli/ifc-cli.js b/packages/iframe-coordinator-cli/ifc-cli.js index f9615ca..31217c2 100755 --- a/packages/iframe-coordinator-cli/ifc-cli.js +++ b/packages/iframe-coordinator-cli/ifc-cli.js @@ -19,14 +19,14 @@ main(); function main() { const opts = parseProgramOptions(); const indexContent = generateIndex(appPath, opts.clientConfigFile); - const configuredProxies = loadProxyConfig(opts.proxyConfigFile); + const serverConfig = loadConfig(opts.proxyConfigFile); app = express(); // Serve our custom index file with injected frame-router config app.use(/^\/$/, serveIndex(indexContent)); // Set up user configured proxies - configuredProxies.forEach((proxy) => { + serverConfig.proxies.forEach((proxy) => { app.use( proxy.path, createProxyMiddleware({ @@ -38,6 +38,11 @@ function main() { ); }); + // Set up user configured static directories + serverConfig.static.forEach((mapping) => { + app.use(mapping.serverPath, express.static(mapping.fsDir)); + }); + // Deprecated path-based dynamic proxy - to be removed in next major release app.use( "/proxy", @@ -53,7 +58,7 @@ function main() { }), ); - // Server the static Vue App assets + // Serve the static Vue App assets app.use(express.static(appPath)); if (opts.ssl) { @@ -218,18 +223,37 @@ function getSslOpts(certPath, keyPath) { } } -function loadProxyConfig(path) { +function loadConfig(path) { if (!path) { return []; } - const proxyConfig = JSON.parse(fs.readFileSync(path).toString()); - return Object.entries(proxyConfig).map(([path, target]) => { - return { - path, - target, - }; - }); + const rawConfig = JSON.parse(fs.readFileSync(path).toString()); + // The old config format was just an object of proxy mappings. To also + // support new static file features, we have a new format with optional `proxy` + // and `static` fields. + const useNewFormat = rawConfig.proxies || rawConfig.static; + let rawProxyConfig = useNewFormat ? rawConfig.proxies || {} : rawConfig; + const proxyConfig = Object.entries(rawProxyConfig).map( + ([serverPath, target]) => { + return { + path: serverPath, + target, + }; + }, + ); + + const rawStaticConfig = useNewFormat ? rawConfig.static : {}; + const staticConfig = Object.entries(rawStaticConfig).map( + ([serverPath, fsDir]) => { + return { + fsDir, + serverPath, + }; + }, + ); + + return { proxies: proxyConfig, static: staticConfig }; } function extractTargetHost(req) { From 52c6bc70cfe59dcee6d48f9278b855de84ceaa2f Mon Sep 17 00:00:00 2001 From: Matthew Cheely Date: Fri, 10 Jan 2025 08:39:41 +1300 Subject: [PATCH 2/2] chore(example-app): remove old IE11 polyfills from the example client application --- apps/ifc-example-client/client-app.js | 4 ---- apps/ifc-example-client/package.json | 5 +---- package-lock.json | 32 +-------------------------- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/apps/ifc-example-client/client-app.js b/apps/ifc-example-client/client-app.js index 6e636a5..ee0918c 100644 --- a/apps/ifc-example-client/client-app.js +++ b/apps/ifc-example-client/client-app.js @@ -1,7 +1,3 @@ -// Load polyfills required for IE11 -import "@babel/polyfill"; -import "custom-event-polyfill"; -import "url-polyfill"; import { registerCustomElements, Client } from "iframe-coordinator"; registerCustomElements(); diff --git a/apps/ifc-example-client/package.json b/apps/ifc-example-client/package.json index e68b517..9dbd44c 100644 --- a/apps/ifc-example-client/package.json +++ b/apps/ifc-example-client/package.json @@ -24,9 +24,6 @@ "rollup": "^4.30.1" }, "dependencies": { - "@babel/polyfill": "^7.12.1", - "custom-event-polyfill": "^1.0.7", - "iframe-coordinator": "file:../../packages/iframe-coordinator", - "url-polyfill": "^1.1.12" + "iframe-coordinator": "file:../../packages/iframe-coordinator" } } diff --git a/package-lock.json b/package-lock.json index 72f5dbe..e4d9f5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,10 +29,7 @@ "apps/ifc-example-client": { "version": "6.1.0", "dependencies": { - "@babel/polyfill": "^7.12.1", - "custom-event-polyfill": "^1.0.7", - "iframe-coordinator": "file:../../packages/iframe-coordinator", - "url-polyfill": "^1.1.12" + "iframe-coordinator": "file:../../packages/iframe-coordinator" }, "devDependencies": { "@rollup/plugin-node-resolve": "^16.0.0", @@ -284,16 +281,6 @@ "node": ">=6.0.0" } }, - "node_modules/@babel/polyfill": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/polyfill/-/polyfill-7.12.1.tgz", - "integrity": "sha512-X0pi0V6gxLi6lFZpGmeNa4zxtwEmCs42isWLNjZZDE0Y8yVfgu0T2OAHlzBbdYlqbW/YXVvoBHpATEM+goCj8g==", - "deprecated": "🚨 This package has been deprecated in favor of separate inclusion of a polyfill and regenerator-runtime (when needed). See the @babel/polyfill docs (https://babeljs.io/docs/en/babel-polyfill) for more information.", - "dependencies": { - "core-js": "^2.6.5", - "regenerator-runtime": "^0.13.4" - } - }, "node_modules/@babel/runtime": { "version": "7.26.0", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.26.0.tgz", @@ -4113,13 +4100,6 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, - "node_modules/core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "hasInstallScript": true - }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -9597,11 +9577,6 @@ "node": ">=8" } }, - "node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==" - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -11138,11 +11113,6 @@ "requires-port": "^1.0.0" } }, - "node_modules/url-polyfill": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.12.tgz", - "integrity": "sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A==" - }, "node_modules/urlpattern-polyfill": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-10.0.0.tgz",