enso/app/ide-desktop/lib/dashboard/bundle.ts
somebody1234 658395e011
Enable require-jsdoc lint and add two lints related to React (#6403)
- Enables the `require-jsdoc` lint
- Fixes all lint errors caused by enabling this lint.

# Important Notes
- There is no option to require JSDoc for other constructs, like top-level constants.
2023-05-19 19:55:29 +00:00

49 lines
1.3 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 ===
// ===============
/** Clean up old build output and runs the esbuild 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')
)
// eslint-disable-next-line @typescript-eslint/naming-convention
opts.loader = { '.html': 'copy' }
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()