Skip to content

Commit

Permalink
Build the Webworker into an iife instead of an ES module for compatib…
Browse files Browse the repository at this point in the history
…ility with older browsers (#69)
  • Loading branch information
jaltekruse authored Dec 22, 2023
1 parent a89f0de commit f58aee4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/doenetml-worker/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export default defineConfig({
sourcemap: true,
lib: {
entry: "src/index.ts",
fileName: "CoreWorker",
formats: ["es"],
fileName: (_format, _entryName) => "CoreWorker.js",
formats: ["iife"],
name: "doenetmlWorker"
},
rollupOptions: {
// @ts-ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/doenetml/src/utils/activityUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ export async function determineNumberOfActivityVariants(

export function createCoreWorker() {
return new Worker(doenetGlobalConfig.doenetWorkerUrl, {
type: "module",
type: "classic",
});
}

Expand Down
2 changes: 2 additions & 0 deletions packages/doenetml/src/utils/activtyWebWorker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export function prerenderActivity({ cid, doenetId, flags }) {
// TODO - do we need to move this web worker to an iife as well?
// see - https://github.com/Doenet/DoenetML/pull/69
let worker = new Worker("/utils/prerenderWorker.js", { type: "module" });

// console.log(`Prerendering activity`, cid, doenetId, flags, worker);
Expand Down
2 changes: 1 addition & 1 deletion packages/doenetml/src/utils/prerenderWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function calculateInitialRendererState({
flags = {},
}) {
let coreWorker = new Worker(doenetGlobalConfig.doenetWorkerUrl, {
type: "module",
type: "classic",
});

coreWorker.postMessage({
Expand Down

0 comments on commit f58aee4

Please sign in to comment.