Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/self contained desktop package #439

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"start:electron": "tsc -p electron -w",
"build:electron": "tsc -p electron",
"build:pyodide": "curl -L https://github.com/pyodide/pyodide/releases/download/0.21.3/pyodide-build-0.21.3.tar.bz2 | tar xj -C ./build --files-from=./pyodide-files.txt",
"build:bin": "esbuild ./bin/dump_artifacts.ts --bundle --minify --platform=node --external:@stlite/kernel --external:node-fetch --external:pyodide --external:yargs --external:fs-extra --outfile=./bin/dump_artifacts.js && sed -i'' -e '1 s/^#!.*$/#!\\/usr\\/bin\\/env node/' ./bin/*.js",
"build:bin": "./scripts/build_bin.js && sed -i'' -e '1 s/^#!.*$/#!\\/usr\\/bin\\/env node/' ./bin/*.js",
"typecheck": "yarn tsc --noEmit -p electron",
"start": "concurrently \"cross-env BROWSER=none yarn start:web\" \"wait-on http://localhost:3000 && yarn start:electron\" \"wait-on http://localhost:3000 && tsc -p electron && cross-env NODE_ENV=\"development\" electron .\"",
"build:app": "yarn build:web && yarn build:electron && yarn build:pyodide",
Expand Down Expand Up @@ -48,6 +48,11 @@
"last 1 electron version"
]
},
"//": "The packages not bundled with bin/dump_artifacts.js must be specified here as the runtime dependencies. See `scripts/build_bin.js` for the details.",
"dependencies": {
"node-fetch": "2",
"pyodide": "^0.21.3"
},
"devDependencies": {
"@craco/craco": "^6.1.2",
"@stlite/common": "^0.19.1",
Expand All @@ -74,7 +79,7 @@
"typescript": "^4.6.3",
"yargs": "^17.5.1"
},
"//": "build.productName is necessary because electron-builder uses the package name for its purpose but the scoped name including '@' makes a problem: https://github.com/electron-userland/electron-builder/issues/3230",
"///": "build.productName is necessary because electron-builder uses the package name for its purpose but the scoped name including '@' makes a problem: https://github.com/electron-userland/electron-builder/issues/3230",
"build": {
"appId": "your.id",
"mac": {
Expand Down
19 changes: 19 additions & 0 deletions packages/desktop/scripts/build_bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node

// Build script using esbuild like https://esbuild.github.io/getting-started/#build-scripts

require("esbuild")
.build({
entryPoints: ["./bin/dump_artifacts.ts"],
bundle: true,
minify: true,
platform: "node",
external: [
"@stlite/kernel", // Don't touch `require.resolve("@stlite/kernel") at the bundle time.
"pyodide", // The `pyodide` package must be installed at runtime for the included Wasm files, so there is no reason to bundle it here.
"node-fetch", // `node-fetch` will be installed at runtime anyway because it is one dependency of the `pyodide` package, so there is no reason to bundle it here.
],
outfile: "./bin/dump_artifacts.js",
logLevel: "info",
})
.catch(() => process.exit(1));