Skip to content

Commit

Permalink
Reworked ide watch and ide start commands (#5634)
Browse files Browse the repository at this point in the history
This PR changes build script's `ide watch` and `ide start` commands, so they don't use `electron-builder` to package. Instead, they invoke `electron` directly, significantly reducing time overhead.

`ide watch` will now start Electron process, while continuously rebuilding gui and the client in the background. Changes can be puilled by reloading within the electron, or closing the electron and letting it start once again. To stop, the script should be interrupted with `Ctrl+C`.
  • Loading branch information
mwu-tow authored Mar 2, 2023
1 parent cfee987 commit ee981d2
Show file tree
Hide file tree
Showing 46 changed files with 915 additions and 448 deletions.
14 changes: 13 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ members = [
"app/gui/language/parser",
"app/gui/enso-profiler-enso-data",
"build/cli",
"build/macros",
"build/macros/proc-macro",
"build/ci-gen",
"build/cli",
"build/intellij-run-config-gen",
Expand Down Expand Up @@ -122,3 +122,12 @@ bytes = { version = "1.1.0" }
matches = { version = "0.1" }
console_error_panic_hook = { version = "0.1.6" }
reqwest = { version = "0.11.5" }
proc-macro2 = { version = "1.0.50" }
syn = { version = "1.0", features = [
"full",
"extra-traits",
"printing",
"parsing",
"visit-mut",
] }
quote = { version = "1.0.23" }
4 changes: 2 additions & 2 deletions app/gui/language/ast/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ proc-macro = true
default = []

[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
proc-macro2 = { workspace = true }
quote = { workspace = true }
Inflector = "0.11.4"
enso-macro-utils = { path = "../../../../../lib/rust/macro-utils" }

Expand Down
26 changes: 26 additions & 0 deletions app/ide-desktop/esbuild-watch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** Helper module for running esbuild in watch mode. */

import * as esbuild from 'esbuild'

/** Transform a given esbuild bundle option configuration into a watch configuration.
* @param config - Configuration for the esbuild command.
* @param onRebuild - Callback to be called after each rebuild.
* @param inject - See [esbuild docs](https://esbuild.github.io/api/#inject).
*
**/
export function toWatchOptions(
config: esbuild.BuildOptions,
onRebuild?: () => void,
inject?: esbuild.BuildOptions['inject']
): esbuild.BuildOptions {
return {
...config,
inject: [...(config.inject ?? []), ...(inject ?? [])],
watch: {
onRebuild(error, result) {
if (error) console.error('watch build failed:', error)
else onRebuild?.()
},
},
}
}
33 changes: 2 additions & 31 deletions app/ide-desktop/lib/client/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,13 @@

import path, { dirname } from 'node:path'
import esbuild from 'esbuild'
import { require_env, require_env_resolved_path } from '../../utils.js'
import { bundlerOptionsFromEnv } from './esbuild-config.js'
import { fileURLToPath } from 'node:url'

// ===================================================
// === Constants provided through the environment. ===
// ===================================================

/** Output directory for bundled client files. */
const outdir = path.join(require_env_resolved_path('ENSO_BUILD_IDE'), 'client')

/** Path to the project manager executable relative to the PM bundle root. */
const projectManagerInBundlePath = require_env('ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH')

/** Version of the Engine (backend) that is bundled along with this client build. */
const bundledEngineVersion = require_env('ENSO_BUILD_IDE_BUNDLED_ENGINE_VERSION')

export const thisPath = path.resolve(dirname(fileURLToPath(import.meta.url)))

// ================
// === Bundling ===
// ================

const bundlerOptions: esbuild.BuildOptions = {
bundle: true,
outdir,
entryPoints: ['src/index.ts', 'src/preload.ts'],
outbase: 'src',
format: 'cjs',
outExtension: { '.js': '.cjs' },
platform: 'node',
define: {
BUNDLED_ENGINE_VERSION: JSON.stringify(bundledEngineVersion),
PROJECT_MANAGER_IN_BUNDLE_PATH: JSON.stringify(projectManagerInBundlePath),
},
sourcemap: true,
external: ['electron'],
}

const bundlerOptions: esbuild.BuildOptions = bundlerOptionsFromEnv()
await esbuild.build(bundlerOptions)
9 changes: 9 additions & 0 deletions app/ide-desktop/lib/client/dist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** This script creates a packaged IDE distribution using electron-builder.
*
* Behaviour details are controlled by the environment variables or CLI arguments.
* @see Arguments
**/

import { args, buildPackage } from './electron-builder-config.js'

await buildPackage(args)
Loading

0 comments on commit ee981d2

Please sign in to comment.