Skip to content

Commit

Permalink
Merge pull request #355 from concord-consortium/187028887-webpack-pub…
Browse files Browse the repository at this point in the history
…lic-path

Use built-in __webpack_public_path__ instead of custom global variable
  • Loading branch information
pjanik authored Feb 13, 2024
2 parents f746d46 + 3febe3b commit e32af77
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 2 additions & 0 deletions packages/tecrock-simulation/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ declare module "*.css";
declare module "*.png";
declare module "*.jpg";
declare module "*.svg";

declare var __webpack_public_path__: string;
4 changes: 1 addition & 3 deletions packages/tecrock-simulation/src/worker-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { ISerializedField } from "./plates-model/field";
export type EventName = ModelWorkerMsg["type"];
export type ResponseHandler = (response: any) => void;

declare var __WEBPACK_DEPLOY_PATH__: string;

let _requestId = 0;
const getRequestId = () => ++_requestId;

class WorkerController {
// Plate tectonics model, handles all the aspects of simulation which are not related to view and interaction.
modelWorker = new window.Worker(`${__WEBPACK_DEPLOY_PATH__}/modelWorker.js${window.location.search}`);
modelWorker = new window.Worker(`${__webpack_public_path__}modelWorker.js${window.location.search}`);
modelState = "notRequested";
// Messages to model worker are queued before model is loaded.
modelMessagesQueue: IncomingModelWorkerMsg[] = [];
Expand Down
6 changes: 1 addition & 5 deletions packages/tecrock-simulation/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ module.exports = {
template: './src/index.html',
favicon: './public/favicon.ico',
publicPath: DEPLOY_PATH,
})] : []),
// Define DEPLOY_PATH globally so it can be used to load Web Worker script from a correct location
new webpack.DefinePlugin({
'__WEBPACK_DEPLOY_PATH__': JSON.stringify(DEPLOY_PATH || ".")
})
})] : [])
]
}

Expand Down

0 comments on commit e32af77

Please sign in to comment.