From 8256ac25d74181c07043acd772338eebdf2cbf18 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 1/8] chore: update npm description --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1041f1fba..f05b1b3ff 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "3.0.17", "homepage": "https://elm-pages.com", "moduleResolution": "node", - "description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.", + "description": "Hybrid Elm framework with full-stack and static routes.", "main": "index.js", "scripts": { "start": "cd examples/end-to-end && npm i && npx elm-pages dev", From 506d9c53b19d6b7c931cf0bbda5b4aa29611fc51 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 2/8] fix: tsconfig --- generator/tsconfig.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/generator/tsconfig.json b/generator/tsconfig.json index daa00ffe0..4adaaa343 100644 --- a/generator/tsconfig.json +++ b/generator/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { "types": ["node"], - "moduleResolution": "node", + "module": "NodeNext", + "isolatedModules": true, "checkJs": true, "allowJs": true, + "noEmit": true, "strict": true, - "resolveJsonModule": true, - "lib": ["es2015", "es2017.object", "esnext", "dom"] + "lib": ["esnext", "dom"] }, "exclude": ["node_modules", "generated"] } From 492205bd99a207afa9adfe1481836f4f210730c7 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 3/8] chore: remove random file --- generator/src/codegen-template-builder.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 generator/src/codegen-template-builder.js diff --git a/generator/src/codegen-template-builder.js b/generator/src/codegen-template-builder.js deleted file mode 100644 index e69de29bb..000000000 From 49de008d0b2340e26af5c88feb931a4525208670 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 4/8] chore: run typesync to get types for which --- package-lock.json | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 6 +++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 163bb00d2..927274cec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,12 +37,17 @@ "elm-pages": "generator/src/cli.js" }, "devDependencies": { + "@types/busboy": "~1.5.4", + "@types/connect": "~3.4.38", + "@types/cookie-signature": "~1.1.2", "@types/cross-spawn": "^6.0.6", "@types/fs-extra": "^11.0.4", + "@types/jsesc": "~3.0.3", "@types/make-fetch-happen": "^10.0.4", "@types/micromatch": "^4.0.9", "@types/node": "^22.10.0", "@types/serve-static": "^1.15.7", + "@types/which": "~3.0.4", "cypress": "^13.16.0", "elm-codegen": "^0.6.1", "elm-optimize-level-2": "^0.3.5", @@ -1109,6 +1114,15 @@ "integrity": "sha512-+euflG6ygo4bn0JHtn4pYqcXwRtLvElQ7/nnjDu7iYG56H0+OhCd7d6Ug0IE3WcFpZozBKW2+80FUbv5QGk5AQ==", "dev": true }, + "node_modules/@types/busboy": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@types/busboy/-/busboy-1.5.4.tgz", + "integrity": "sha512-kG7WrUuAKK0NoyxfQHsVE6j1m01s6kMma64E+OZenQABMQyTJop1DumUWcLwAQ2JzpefU7PDYoRDKl8uZosFjw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/cacheable-request": { "version": "6.0.3", "resolved": "https://registry.npmjs.org/@types/cacheable-request/-/cacheable-request-6.0.3.tgz", @@ -1126,6 +1140,24 @@ "resolved": "https://registry.npmjs.org/@types/configstore/-/configstore-2.1.1.tgz", "integrity": "sha512-YY+hm3afkDHeSM2rsFXxeZtu0garnusBWNG1+7MknmDWQHqcH2w21/xOU9arJUi8ch4qyFklidANLCu3ihhVwQ==" }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/cookie-signature": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/cookie-signature/-/cookie-signature-1.1.2.tgz", + "integrity": "sha512-2OhrZV2LVnUAXklUFwuYUTokalh/dUb8rqt70OW6ByMSxYpauPZ+kfNLknX3aJyjY5iu8i3cUyoLZP9Fn37tTg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/cross-spawn": { "version": "6.0.6", "resolved": "https://registry.npmjs.org/@types/cross-spawn/-/cross-spawn-6.0.6.tgz", @@ -1192,6 +1224,12 @@ "pretty-format": "^27.0.0" } }, + "node_modules/@types/jsesc": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/jsesc/-/jsesc-3.0.3.tgz", + "integrity": "sha512-YZZ9ZOAiiSVC6KApWd/fTCDTdTOOMiRU4Lq3/VSmXNPse8IvCVOn5kYRRLu900Ub1lTPurVZFI5unEqLDJR7wg==", + "dev": true + }, "node_modules/@types/jsonfile": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/@types/jsonfile/-/jsonfile-6.1.1.tgz", @@ -1343,6 +1381,12 @@ "resolved": "https://registry.npmjs.org/@types/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-gVC1InwyVrO326wbBZw+AO3u2vRXz/iRWq9jYhpG4W8LXyIgDv3ZmcLQ5Q4Gs+gFMyqx+viFoFT+l3p61QFCmQ==" }, + "node_modules/@types/which": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/@types/which/-/which-3.0.4.tgz", + "integrity": "sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==", + "dev": true + }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", diff --git a/package.json b/package.json index f05b1b3ff..8743511e7 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,6 @@ "type": "module", "version": "3.0.17", "homepage": "https://elm-pages.com", - "moduleResolution": "node", "description": "Hybrid Elm framework with full-stack and static routes.", "main": "index.js", "scripts": { @@ -50,12 +49,17 @@ "which": "^5.0.0" }, "devDependencies": { + "@types/busboy": "~1.5.4", + "@types/connect": "~3.4.38", + "@types/cookie-signature": "~1.1.2", "@types/cross-spawn": "^6.0.6", "@types/fs-extra": "^11.0.4", + "@types/jsesc": "~3.0.3", "@types/make-fetch-happen": "^10.0.4", "@types/micromatch": "^4.0.9", "@types/node": "^22.10.0", "@types/serve-static": "^1.15.7", + "@types/which": "~3.0.4", "cypress": "^13.16.0", "elm-codegen": "^0.6.1", "elm-optimize-level-2": "^0.3.5", From 77774afc60e69f1feb86a963d36fc162b9e4ae26 Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 5/8] fix: allow @types to propgate --- generator/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/generator/tsconfig.json b/generator/tsconfig.json index 4adaaa343..dad6ca4f7 100644 --- a/generator/tsconfig.json +++ b/generator/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "types": ["node"], "module": "NodeNext", "isolatedModules": true, "checkJs": true, From bda7b971c28744abf6dc8cdd19b249bfee5c268e Mon Sep 17 00:00:00 2001 From: Eli <88557639+lishaduck@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:09:21 -0600 Subject: [PATCH 6/8] chore: delete another random file --- generator/src/hello.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 generator/src/hello.ts diff --git a/generator/src/hello.ts b/generator/src/hello.ts deleted file mode 100644 index 85f1f6912..000000000 --- a/generator/src/hello.ts +++ /dev/null @@ -1,5 +0,0 @@ -export function hello(): string { - console.log("HELLLO!!!!"); - - return "Hello World!"; -} From 80ecb268df67935d6d3ada213b6093dc25051a07 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 7/8] chore: remove jsconfig The tsconfig overrides it. --- jsconfig.json | 12 ------------ tsconfig.json | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json deleted file mode 100644 index b7504321c..000000000 --- a/jsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "module": "esnext", - "noImplicitAny": true, - "removeComments": true, - "strictNullChecks": true, - "sourceMap": false, - "resolveJsonModule": true, - "lib": ["es5", "es2015.promise", "dom", "es2015"], - "checkJs": true - } -} diff --git a/tsconfig.json b/tsconfig.json index 98dc31bd3..550e1020c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,7 @@ "strict": true, "target": "ESNext", "module": "NodeNext", - "moduleResolution": "NodeNext" + "moduleResolution": "NodeNext", + "checkJs": true } } From 7c832d1b80bf261f0d559386e237a03b235271bc 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 8/8] 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(`