From 39847c54dbf4494dc48a438c90f4bea82a2aa701 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:05:41 -0600 Subject: [PATCH] chore: add some types --- generator/src/basepath-middleware.js | 8 +++++ generator/src/build.js | 49 ++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/generator/src/basepath-middleware.js b/generator/src/basepath-middleware.js index af7d2a62d..b3c317c16 100644 --- a/generator/src/basepath-middleware.js +++ b/generator/src/basepath-middleware.js @@ -1,5 +1,13 @@ // this middleware is only active when (config.base !== '/') +/** + * @import { NextHandleFunction } from "connect"; + */ + +/** + * @param {string} base + * @returns {NextHandleFunction} + */ export function baseMiddleware(base) { // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...` return function viteBaseMiddleware(req, res, next) { diff --git a/generator/src/build.js b/generator/src/build.js index 11430afab..ec595cd5a 100755 --- a/generator/src/build.js +++ b/generator/src/build.js @@ -21,8 +21,17 @@ import * as globby from "globby"; import { fileURLToPath } from "url"; import { copyFile } from "fs/promises"; +/** + * @type {Promise<{ worker: Worker }>[]} + */ let pool = []; +/** + * @type {(value: unknown) => void} + */ let pagesReady; +/** + * @type {(reason: unknown) => void} + */ let pagesErrored; let pages = new Promise((resolve, reject) => { pagesReady = resolve; @@ -73,7 +82,11 @@ export async function run(options) { // This is a temporary hack to avoid this warning. elm-pages manages compiling the Elm code without Vite's involvement, so it is external to Vite. // There is a pending issue to allow having external scripts in Vite, once this issue is fixed we can remove this hack: // https://github.com/vitejs/vite/issues/3533 - if (messages && messages[0] && !messages[0].startsWith(`