enso/app/ide-desktop/lib/dashboard/bundle.ts
somebody1234 a7dba72b84
Rename tsx files without JSX to ts files (#8085)
This makes it clearer which files contain React components, and which do not.

# Important Notes
The main things that should be tested to confirm that this did not break anything is the two files containing Tailwind classes:
- Shortcuts ("delete" in context menu should still be red. `text-delete` is used elsewhere though, so this should not be broken either way)
- Indentation of directory contents (multiple levels)
Many of the others should more or less be self-testing:
- `index.tsx` -> `index.ts` would break the entire app if not handled properly
- `hooks.tsx` contains `useNavigate` which would break routing if absent, and `useToastAndLog` which would break most  toast notifications.
- `http.tsx` contains the HTTP client which would break all backend requests
- `useRefresh.tsx` would... break login and logout if it was broken I guess
2023-11-03 00:39:08 +00:00

53 lines
1.4 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)))
export const ANALYZE = process.argv.includes('--analyze')
// ===============
// === 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.ts')
)
opts.metafile = ANALYZE
opts.loader['.html'] = 'copy'
const result = await esbuild.build(opts)
if (result.metafile) {
console.log(await esbuild.analyzeMetafile(result.metafile))
}
return
} catch (error) {
console.error(error)
// The error is being re-thrown.
// eslint-disable-next-line no-restricted-syntax
throw error
}
}
void bundle()