mirror of
https://github.com/enso-org/enso.git
synced 2024-12-21 05:41:42 +03:00
ebf4cd5c1f
- Remove unnecessary modules - Remove `ts-plugin-namespace-auto-import` as it was a workaround to use the non-conventional `import *` convention - Remove `esbuild-plugin-copy-directories` as it is unuse - Inline modules that are only ever used once - Inline `project-manager-shim` into `gui2` - it is only used during `gui2`'s dev mode - Inline `content-config` into `client` - Flatten `app/ide-desktop/lib/` to `app/ide-desktop/` - Flatten `app/ide-desktop/lib/dashboard/` to `app/dashboard/` # Important Notes - As mentioned above, all remaining modules have been moved up from `app/ide-desktop/lib/` to `app/ide-desktop/`. It's not ideal but I'd rather hold off on moving them anywhere else before we have a consensus on what should go where. - (That is to say, this may not be the final directory structure - but I figure it's fine to get *something* done so that hopefully the rest of the restructuring is simpler.)
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
/** @file Esbuild config file. */
|
|
import * as path from 'node:path'
|
|
|
|
import type * as esbuild from 'esbuild'
|
|
import esbuildPluginYaml from 'esbuild-plugin-yaml'
|
|
|
|
import * as appConfig from 'enso-common/src/appConfig'
|
|
import * as paths from './paths'
|
|
|
|
// ====================
|
|
// === Global setup ===
|
|
// ====================
|
|
|
|
await appConfig.readEnvironmentFromFile()
|
|
|
|
// ================
|
|
// === Bundling ===
|
|
// ================
|
|
|
|
/** Get the bundler options using the environment.
|
|
*
|
|
* The following environment variables are required:
|
|
* - `ENSO_BUILD_IDE` - output directory for bundled client files;
|
|
* - `ENSO_BUILD_PROJECT_MANAGER_IN_BUNDLE_PATH` - path to the project manager executable relative
|
|
* to the PM bundle root;
|
|
* @see bundlerOptions
|
|
*/
|
|
export function bundlerOptionsFromEnv(devMode = false): esbuild.BuildOptions {
|
|
return bundlerOptions(
|
|
path.join(paths.getIdeDirectory(), 'client'),
|
|
paths.getProjectManagerInBundlePath(),
|
|
devMode
|
|
)
|
|
}
|
|
|
|
/** Get options without relying on the environment. */
|
|
export function bundlerOptions(
|
|
outdir: string,
|
|
projectManagerInBundlePath: string,
|
|
devMode = false
|
|
): esbuild.BuildOptions {
|
|
return {
|
|
bundle: true,
|
|
outdir,
|
|
entryPoints: ['src/index.ts', 'src/preload.ts'],
|
|
outbase: 'src',
|
|
format: 'cjs',
|
|
platform: 'node',
|
|
plugins: [esbuildPluginYaml.yamlPlugin({})],
|
|
// The names come from a third-party API and cannot be changed.
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
outExtension: { '.js': '.cjs' },
|
|
define: {
|
|
'process.env.PROJECT_MANAGER_IN_BUNDLE_PATH': JSON.stringify(
|
|
projectManagerInBundlePath
|
|
),
|
|
'process.env.ELECTRON_DEV_MODE': JSON.stringify(String(devMode)),
|
|
'process.env.GUI_CONFIG_PATH': JSON.stringify(path.resolve('../gui2/vite.config.ts')),
|
|
},
|
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
sourcemap: true,
|
|
external: ['electron', 'vite', 'lightningcss'],
|
|
}
|
|
}
|