enso/app/ide-desktop/lib/client/start.ts
somebody1234 5a100ea79b
Convert dashboard to use esbuild (#6034)
* Switch dashboard to esbuild

* Minor fixes; move Tailwind generation into esbuild-config

* Fix watching `content/` and `client/`

* Bump esbuild binary versions; minor dependency list fixes

* Fixes; rename "npm run dev" to "npm run watch-dashboard"

* Avoid writing esbuild outputs to disk for `dashboard/`

* Convert watch-dashboard to be fully in-memory; rebuild css files on change

* Remove obsolete FIXME

* Remove unused constants

* Run prettier

* add missing styles

* Fixes

* Fix the fixes

* Run prettier

* Fixes; use nesting plugin to wrap tailwind preflight

* Remove testing flag from client/watch

* Minor fixes

* Run prettier

* Make css rebuild when tailwind config changes

* Fix bundling for dashboard

* Fix dashboard/bundle.ts erroring when build directory does not exist

* Fix esbuild binary package names

* Remove redundant "npx" prefix from build scripts

* Remove unused dependency

* workaround for mac freeze

* add missing sections

* Address review issue

* Fix live-reload of `npm run watch-dashboard`

* Fix service worker for client-side routing

* Fix GL crash

* Revert "Fix GL crash"

This reverts commit 612136bc1a.

* Implement suggested fix

* prettier

---------

Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
2023-03-31 16:19:07 +02:00

47 lines
1.6 KiB
TypeScript

/** @file This script starts the IDE using the Electron executable. */
import * as childProcess from 'node:child_process'
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import * as esbuild from 'esbuild'
import * as esbuildConfig from './esbuild-config'
import * as paths from './paths'
const GUI_PATH = path.resolve(paths.getGuiDirectory())
const IDE_PATH = paths.getIdeDirectory()
const PROJECT_MANAGER_BUNDLE = paths.getProjectManagerBundlePath()
const SCRIPT_ARGS = process.argv.slice(2)
console.log('Script arguments:', ...SCRIPT_ARGS.map(arg => JSON.stringify(arg)))
console.log('Cleaning IDE dist directory.')
await fs.rm(IDE_PATH, { recursive: true, force: true })
await fs.mkdir(IDE_PATH, { recursive: true })
console.log('Bundling client.')
const BUNDLER_OPTIONS = esbuildConfig.bundlerOptionsFromEnv()
BUNDLER_OPTIONS.outdir = path.resolve(IDE_PATH)
await esbuild.build(BUNDLER_OPTIONS)
console.log('Linking GUI files.')
await fs.symlink(path.join(GUI_PATH, 'assets'), path.join(IDE_PATH, 'assets'), 'dir')
console.log('LinkingProject Manager files.')
await fs.symlink(PROJECT_MANAGER_BUNDLE, path.join(IDE_PATH, paths.PROJECT_MANAGER_BUNDLE), 'dir')
console.log('Spawning Electron process.')
const ELECTRON_ARGS = [path.join(IDE_PATH, 'index.cjs'), '--', ...SCRIPT_ARGS]
const ELECTRON_PROCESS = childProcess.spawn('electron', ELECTRON_ARGS, {
stdio: 'inherit',
shell: true,
})
// Wait till process finished.
const CODE = await new Promise<string>((resolve, reject) => {
ELECTRON_PROCESS.on('close', resolve)
ELECTRON_PROCESS.on('error', reject)
})
console.log(`Electron process finished. Exit code: ${CODE}.`)