From c7bc77b08ff0564927c73dbfa86daf1df59f3518 Mon Sep 17 00:00:00 2001 From: Eric NGUYEN Date: Wed, 17 Aug 2022 17:47:16 +0200 Subject: [PATCH] Fix build version of the project because of web workers --- docs/Project_Structure.md | 4 ++-- {src => public}/workers/worker.js | 0 src/Components/Editor/Save.ts | 3 +-- tsconfig.json | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) rename {src => public}/workers/worker.js (100%) diff --git a/docs/Project_Structure.md b/docs/Project_Structure.md index 3daa579..355682b 100644 --- a/docs/Project_Structure.md +++ b/docs/Project_Structure.md @@ -6,7 +6,8 @@ The project is structured this way . ├── docs/ Documentation folder ├── public/ Public folder in which the index.html -│ import its resources +│ │ import its resources +│ └── workers/ Webworkers folder ├── src/ Source folder for the react app │ ├── assets/ Assets folder in which the react app │ │ import its resources @@ -17,7 +18,6 @@ The project is structured this way │ ├── test/ Setup folder for the tests │ ├── tests/ Other tests + resources │ ├── utils/ Utilities folder -│ ├── workers/ Webworkers folder │ ├── index.scss Tailwind CSS extends │ ├── main.tsx Entrypoint for App injection │ └── vite-env.d.ts Types for .env files diff --git a/src/workers/worker.js b/public/workers/worker.js similarity index 100% rename from src/workers/worker.js rename to public/workers/worker.js diff --git a/src/Components/Editor/Save.ts b/src/Components/Editor/Save.ts index 159959a..0dc783b 100644 --- a/src/Components/Editor/Save.ts +++ b/src/Components/Editor/Save.ts @@ -3,7 +3,6 @@ import { IConfiguration } from '../../Interfaces/IConfiguration'; import { getCircularReplacer } from '../../utils/saveload'; import { ID } from '../SVG/SVG'; import { IEditorState } from '../../Interfaces/IEditorState'; -import Worker from '../../workers/worker?worker'; export function SaveEditorAsJSON( history: IHistoryState[], @@ -21,7 +20,7 @@ export function SaveEditorAsJSON( // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (window.Worker) { // use webworker for the stringify to avoid freezing - const myWorker = new Worker(); + const myWorker = new Worker('workers/worker.js'); myWorker.postMessage({ editorState, spaces }); myWorker.onmessage = (event) => { const data = event.data; diff --git a/tsconfig.json b/tsconfig.json index 2fe4d5a..034ee0e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "noEmit": true, "jsx": "react-jsx" }, - "include": ["src", "src/workers"], + "include": ["src"], "exclude": ["test-server"], "references": [{ "path": "./tsconfig.node.json" }] }