Skip to content

Commit

Permalink
feat(ifc-cli): enable static file hosting in ifc-cli server
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MattCheely committed Jan 9, 2025
1 parent 9dfc6a8 commit 1d32fd3
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 105 deletions.
7 changes: 7 additions & 0 deletions apps/ifc-example-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
File renamed without changes.
7 changes: 7 additions & 0 deletions apps/ifc-example-client/client-worker.js
Original file line number Diff line number Diff line change
@@ -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!");
4 changes: 3 additions & 1 deletion apps/ifc-example-client/ifc-proxy.config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"/clients/": "http://localhost:8080/"
"static": {
"/clients": "."
}
}
7 changes: 4 additions & 3 deletions apps/ifc-example-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 18 additions & 0 deletions apps/ifc-example-client/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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()],
};
14 changes: 0 additions & 14 deletions apps/ifc-example-client/vite.config.js

This file was deleted.

Loading

0 comments on commit 1d32fd3

Please sign in to comment.