mirror of
https://github.com/enso-org/enso.git
synced 2024-12-11 14:35:56 +03:00
457d0986b6
* wip * wip 2 * wip * Copy types from bot * wip * Send and display messages * wip: shadow * Copy styles from design screenshot * Fix "create new thread" button * Fix switching threads * wip * Scrollback * Reactions * Fix issues with chat input sizing * Update changelog * Fix bugs; add scroll to thread list * Use types from backend definitions * Update git commit of chat backend; remove stray file path * hotfix: fix "edit thread" shortcut on macos * Address issues * Extract chat header to separate component * Begin matching appearance with Figma * Show reaction bar on hover * fix small scrollbar appear next to the message input * Disallow sending empty messages * Add chat URL to config - production URL will be added soon * add production chat url * fix linters --------- Co-authored-by: Paweł Buchowski <pawel.buchowski@enso.org>
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
/** @file File watch and compile service. */
|
|
import * as module from 'node:module'
|
|
import * as path from 'node:path'
|
|
import * as url from 'node:url'
|
|
|
|
import * as esbuild from 'esbuild'
|
|
import chalk from 'chalk'
|
|
|
|
import * as bundler from './esbuild-config'
|
|
|
|
// =================
|
|
// === Constants ===
|
|
// =================
|
|
|
|
/** The path of this file. */
|
|
const THIS_PATH = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)))
|
|
/** This must be port `8080` because it is defined as such in AWS. */
|
|
const PORT = 8080
|
|
const HTTP_STATUS_OK = 200
|
|
// `outputPath` does not have to be a real directory because `write` is `false`,
|
|
// meaning that files will not be written to the filesystem.
|
|
// However, the path should still be non-empty in order for `esbuild.serve` to work properly.
|
|
const ARGS: bundler.Arguments = { outputPath: '/', devMode: true }
|
|
const OPTS = bundler.bundlerOptions(ARGS)
|
|
OPTS.define.REDIRECT_OVERRIDE = JSON.stringify(`http://localhost:${PORT}`)
|
|
OPTS.entryPoints.push(
|
|
path.resolve(THIS_PATH, 'src', 'index.html'),
|
|
path.resolve(THIS_PATH, 'src', 'index.tsx'),
|
|
path.resolve(THIS_PATH, 'src', 'serviceWorker.ts')
|
|
)
|
|
OPTS.minify = false
|
|
OPTS.write = false
|
|
OPTS.loader['.html'] = 'copy'
|
|
OPTS.pure.splice(OPTS.pure.indexOf('assert'), 1)
|
|
;(OPTS.inject = OPTS.inject ?? []).push(path.resolve(THIS_PATH, '..', '..', 'debugGlobals.ts'))
|
|
const REQUIRE = module.default.createRequire(import.meta.url)
|
|
OPTS.plugins.push({
|
|
name: 'react-dom-profiling',
|
|
setup: build => {
|
|
build.onResolve({ filter: /^react-dom$/ }, args => {
|
|
if (args.kind === 'import-statement') {
|
|
return { path: REQUIRE.resolve('react-dom/profiling') }
|
|
} else {
|
|
return
|
|
}
|
|
})
|
|
},
|
|
})
|
|
|
|
// ===============
|
|
// === Watcher ===
|
|
// ===============
|
|
|
|
/** Start the esbuild watcher. */
|
|
async function watch() {
|
|
const builder = await esbuild.context(OPTS)
|
|
await builder.watch()
|
|
await builder.serve({
|
|
port: PORT,
|
|
servedir: OPTS.outdir,
|
|
/** This function is called on every request.
|
|
* It is used here to show an error if the file to serve was not found. */
|
|
onRequest(args) {
|
|
if (args.status !== HTTP_STATUS_OK) {
|
|
console.error(
|
|
chalk.red(`HTTP error ${args.status} when serving path '${args.path}'.`)
|
|
)
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
void watch()
|