Migrate CootWorker to TS#375
Migrate CootWorker to TS#375stuartjamesmcnicholas merged 8 commits intostuartjamesmcnicholas:masterfrom FilomenoSanchez:master
Conversation
baby-gru/package.json
Outdated
| "transpile-ts-worker": "npx tsc --module es2015 --lib webworker --skipLibCheck public/baby-gru/CootWorker.ts && sed -i '/export {}/d' public/baby-gru/CootWorker.js", | ||
| "prestart": "npm run transpile-ts-worker", | ||
| "start": "react-scripts start", | ||
| "start-tsc": "npx nodemon --trace-warnings", | ||
| "build": "react-scripts build", | ||
| "build-cloud-dev": "webpack --mode development --devtool inline-source-map", | ||
| "build-cloud": "webpack --mode production", | ||
| "build": "npm run transpile-ts-worker && react-scripts build", | ||
| "build-npm-registry": "npm run transpile-ts-worker && webpack --mode development --devtool inline-source-map --env destination='npmRegistry'", | ||
| "build-cloud-dev": "npm run transpile-ts-worker && webpack --mode development --devtool inline-source-map --env destination='ccp4Cloud'", | ||
| "build-cloud": "npm run transpile-ts-worker && webpack --mode production --env destination='ccp4Cloud'", | ||
| "test": "react-scripts test", | ||
| "eject": "react-scripts eject", | ||
| "dev": "concurrently -k \"BROWSER=none npm start\" \"npm:electron\"", | ||
| "electron": "wait-on tcp:3000 && electron-forge start", | ||
| "package": "react-scripts build && electron-forge package", | ||
| "make-mac": "react-scripts build && electron-forge make --platform darwin", | ||
| "make-linux": "react-scripts build && electron-forge make --platform linux", | ||
| "make-win32": "react-scripts build && electron-forge make --platform win32" | ||
| "package": "npm run build && electron-forge package", | ||
| "make-mac": "npm run build && electron-forge make --platform darwin", | ||
| "make-linux": "npm run build && electron-forge make --platform linux", | ||
| "make-win32": "npm run build && electron-forge make --platform win32" |
There was a problem hiding this comment.
Here @stuartjamesmcnicholas I create a script transpile-ts-worker that transpiles the worker TS file. The script is called in npm run build, which in turn is invoked in make-mac, make-win32...etc.
stuartjamesmcnicholas
left a comment
There was a problem hiding this comment.
Problem when I run 'npm start', presumably a difference between linux and mac sed:
Stuarts-MacBook-Pro:baby-gru stuart$ npm start
moorhen@0.1.0 prestart
npm run transpile-ts-worker
moorhen@0.1.0 transpile-ts-worker
npx tsc --module es2015 --lib webworker --skipLibCheck public/baby-gru/CootWorker.ts && sed -i '/export {}/d' public/baby-gru/CootWorker.js
sed: 1: "public/baby-gru/CootWor ...": extra characters at the end of p command
|
Need to add '.bu' sub-option to -i, I think sed -i.bu '/export {}/d' public/baby-gru/CootWorker.js |
|
Thanks indeed the |
This update migrates the coot worker to TS. A few considerations.
npm run transpile-ts-worker. Another quick alternative (only for development) is to modify the JS file, but then it's important to add those changes back to the TS file.package.json. I have testednpm run-script make-linuxon my machine and it produced a working electron app.sedcommand needs to be invoked after transpiling the worker code otherwise the result is not a valid JS worker file. Problem is described here and here.