mirror of
https://github.com/enso-org/enso.git
synced 2024-12-27 19:33:05 +03:00
bd3b778721
This PR replaces webpack with esbuild, as our bundler. The change leads to out-of-the-box ~5x improvement in bundling times, reducing the latency in watch-based workflows. Along with this a new development server (with live reload capacity) has been introduced to support watch command. [ci no changelog needed] ### Important Notes * workflow for checking docs has been removed because it was using outdated prettier version and caused troubles; while the same check is performed in a better way by the GUI/Lint job. * introduced little more typescript in the scripts in place of js, usually with minimal changes.
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
/** Script that bundles JS client code. */
|
|
|
|
import path from 'node:path'
|
|
import esbuild from 'esbuild'
|
|
import { require_env, require_env_resolved_path } from '../../utils.js'
|
|
|
|
// ===================================================
|
|
// === 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')
|
|
|
|
// ================
|
|
// === Bundling ===
|
|
// ================
|
|
|
|
const bundlerOptions: esbuild.BuildOptions = {
|
|
bundle: true,
|
|
outdir,
|
|
entryPoints: ['src/index.js', 'src/preload.cjs'],
|
|
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'],
|
|
}
|
|
|
|
await esbuild.build(bundlerOptions)
|