Skip to content

Commit

Permalink
feat: restore worker-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
zoran995 committed Feb 10, 2025
1 parent 32cbd31 commit d7c44eb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/ReactViews/Custom/Chart/ChartPanelDownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ async function download(items: TableMixin.Instance[]) {
const synthesized = synthesizeNameAndValueArrays(items);

// Could implement this using TaskProcessor, but requires webpack magic.
const worker = new Worker(
new URL("./downloadHrefWorker.js", import.meta.url)
const worker = await import("worker-loader!./downloadHrefWorker").then(
(labelLayoutWorker) => new labelLayoutWorker.default()
);

// console.log('names and value arrays', synthesized.names, synthesized.values);
if (synthesized.values && synthesized.values.length > 0) {
worker.postMessage(synthesized);
Expand Down
7 changes: 7 additions & 0 deletions lib/ThirdParty/worker-loader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module "worker-loader!*" {
type value = {
new (): Worker;
};
const value: value;
export default value;
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"mustache": "^2.2.1",
"node-fetch": "^2.6.1",
"papaparse": "^5.2.0",
"pmtiles": "^3.0.7",
"pbf": "^3.0.1",
"pmtiles": "^3.0.7",
"point-in-polygon": "^1.0.1",
"proj4": "^2.4.4",
"proj4-fully-loaded": "^0.2.0",
Expand Down Expand Up @@ -171,7 +171,8 @@
"urijs": "^1.18.12",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
"webpack-dev-server": "^5.1.0",
"worker-loader": "^3.0.8"
},
"devDependencies": {
"@babel/eslint-parser": "^7.23.3",
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9434,7 +9434,7 @@ schema-utils@^2.0.1:
ajv "^6.12.4"
ajv-keywords "^3.5.2"

schema-utils@^3.1.1, schema-utils@^3.2.0:
schema-utils@^3.0.0, schema-utils@^3.1.1, schema-utils@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe"
integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==
Expand Down Expand Up @@ -11147,6 +11147,14 @@ word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==

worker-loader@^3.0.8:
version "3.0.8"
resolved "https://registry.yarnpkg.com/worker-loader/-/worker-loader-3.0.8.tgz#5fc5cda4a3d3163d9c274a4e3a811ce8b60dbb37"
integrity sha512-XQyQkIFeRVC7f7uRhFdNMe/iJOdO6zxAaR3EWbDp45v3mDhrTi+++oswKNxShUNjPC/1xUp5DB29YKLhFo129g==
dependencies:
loader-utils "^2.0.0"
schema-utils "^3.0.0"

wrap-ansi@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09"
Expand Down

0 comments on commit d7c44eb

Please sign in to comment.