Skip to content

Commit 277559a

Browse files
Merge pull request #280 from purecloudlabs/example-dev-server-improvements
Support building web-workers in the example app
2 parents 0fd5c05 + e563288 commit 277559a

File tree

9 files changed

+199
-144
lines changed

9 files changed

+199
-144
lines changed

apps/ifc-example-client/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,10 @@ commands from the iframe-coordinator project root (the parent directory of this
1616
`npm run start-client-example`
1717

1818
You can then see the apps embedded in a host at http://localhost:3000/#/app1 and http://localhost:3000/#/app2
19+
20+
### Notes
21+
22+
There's no hot-reloading in development mode, so you'll need to refresh the page
23+
after making changes. The dev mode uses a rollup watcher rather than a server like
24+
Vite because building stand-alone web-worker modules is particularly challenging
25+
with Vite.

apps/ifc-example-client/main.js renamed to apps/ifc-example-client/client-app.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// Load polyfills required for IE11
2-
import "@babel/polyfill";
3-
import "custom-event-polyfill";
4-
import "url-polyfill";
51
import { registerCustomElements, Client } from "iframe-coordinator";
62

73
registerCustomElements();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This module is a POC placeholder for a future IFC-integrated web-worker example
2+
3+
// This doesn't work because Client references HTMLElement, which doesn't exist
4+
// in the worker context, but will work for a new worker client.
5+
// import { Client } from "iframe-coordinator/dist/client.js";
6+
7+
console.log("Worker Started!");
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"/clients/": "http://localhost:8080/"
2+
"static": {
3+
"/clients": "."
4+
}
35
}

apps/ifc-example-client/package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@
1313
"type": "module",
1414
"scripts": {
1515
"start": "concurrently \"npm:dev\" \"npm:start-host-shim\"",
16-
"dev": "vite --port 8080",
17-
"build": "vite build",
16+
"dev": "rollup -c --watch",
17+
"build": "rollup -c",
1818
"start-host-shim": "ifc-cli"
1919
},
2020
"devDependencies": {
21+
"@rollup/plugin-node-resolve": "^16.0.0",
2122
"concurrently": "^8.2.2",
2223
"iframe-coordinator-cli": "file:../../packages/iframe-coordinator-cli",
23-
"vite": "^5.4.2"
24+
"rollup": "^4.30.1"
2425
},
2526
"dependencies": {
26-
"@babel/polyfill": "^7.12.1",
27-
"custom-event-polyfill": "^1.0.7",
28-
"iframe-coordinator": "file:../../packages/iframe-coordinator",
29-
"url-polyfill": "^1.1.12"
27+
"iframe-coordinator": "file:../../packages/iframe-coordinator"
3028
}
3129
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { nodeResolve } from "@rollup/plugin-node-resolve";
2+
3+
import { dirname, resolve } from "path";
4+
import { fileURLToPath } from "url";
5+
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
8+
export default {
9+
input: [
10+
resolve(__dirname, "client-app.js"),
11+
resolve(__dirname, "client-worker.js"),
12+
],
13+
output: {
14+
preserveModules: false,
15+
dir: "dist",
16+
},
17+
plugins: [nodeResolve()],
18+
};

apps/ifc-example-client/vite.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)