enso/app/ide-desktop/lib/dashboard/bundle.ts
somebody1234 3e5a3dc468
Fix all eslint errors (#6267)
Fixes all eslint errors - now `npx eslint .` in `app/ide-desktop` should show no errors and no warnings.
Also fixes an incorrect lint rule (the rule to catch early returns (?) did not work properly for `try-catch`)

# Important Notes
This changes quite a few files (unfortunately) so QA should be done to check all affected files
2023-04-24 12:56:26 +00:00

46 lines
1.1 KiB
TypeScript

/** @file Entry point for the bundler. */
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import * as url from 'node:url'
import * as esbuild from 'esbuild'
import * as bundler from './esbuild-config'
// =================
// === Constants ===
// =================
export const THIS_PATH = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
// ===============
// === Bundler ===
// ===============
async function bundle() {
try {
try {
await fs.rm('./build', { recursive: true })
} catch {
// Ignored.
}
const opts = bundler.bundlerOptions({
outputPath: './build',
devMode: false,
})
opts.entryPoints.push(
path.resolve(THIS_PATH, 'src', 'index.html'),
path.resolve(THIS_PATH, 'src', 'index.tsx')
)
await esbuild.build(opts)
return
} catch (error) {
console.error(error)
// The error is being re-thrown.
// eslint-disable-next-line no-restricted-syntax
throw error
}
}
void bundle()