From baa02c16a289c0ee786d953e135104a21915371a Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Tue, 12 May 2026 10:19:28 -0600 Subject: [PATCH] fix(docs-site): patch elm-pages urlToRoute to strip base path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The elm-pages v3.5.1 --base flag has a bug: the generated urlToRoute function doesn't strip the base path before matching routes, causing all pages to pre-render as "Page not found." This patch fixes the codegen to inline the base path stripping logic into urlToRoute. Also simplifies the CI workflow — the patched build outputs files at the dist root with correct /devtools/ prefixed links, so we just upload dist/ directly instead of restructuring the output. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/docs.yml | 11 +++-------- package.json | 5 ++++- patches/elm-pages@3.5.1.patch | 25 +++++++++++++++++++++++++ pnpm-lock.yaml | 9 +++++++-- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 patches/elm-pages@3.5.1.patch diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0b80947..0295202 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -33,19 +33,14 @@ jobs: - name: Build docs site run: pnpm --filter docs-site build - - name: Prepare deploy directory + - name: Fix elm.js script path run: | cd apps/docs/dist - cp -r assets devtools/assets - cp elm.*.js devtools/ - cp style.css devtools/ 2>/dev/null || true - cp favicon.ico devtools/ 2>/dev/null || true - cp content.dat devtools/ 2>/dev/null || true - find devtools -name '*.html' -exec sed -i 's|src="/elm\.|src="/devtools/elm.|g' {} + + find . -name '*.html' -exec sed -i 's|src="/elm\.|src="/devtools/elm.|g' {} + - uses: actions/upload-pages-artifact@v3 with: - path: apps/docs/dist/devtools + path: apps/docs/dist deploy: environment: diff --git a/package.json b/package.json index 58c1599..26d089d 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,9 @@ "onlyBuiltDependencies": [ "esbuild", "lamdera" - ] + ], + "patchedDependencies": { + "elm-pages@3.5.1": "patches/elm-pages@3.5.1.patch" + } } } diff --git a/patches/elm-pages@3.5.1.patch b/patches/elm-pages@3.5.1.patch new file mode 100644 index 0000000..40adf07 --- /dev/null +++ b/patches/elm-pages@3.5.1.patch @@ -0,0 +1,25 @@ +diff --git a/codegen/elm-pages-codegen.cjs b/codegen/elm-pages-codegen.cjs +index 23614931f4601b018de0551b2991afdbdf64ddf9..9b9d540dde9a20ffba31cb82dfe8fb6dfd0e44f9 100644 +--- a/codegen/elm-pages-codegen.cjs ++++ b/codegen/elm-pages-codegen.cjs +@@ -23712,11 +23712,18 @@ var $author$project$Generate$file$ = function (templates, basePath) { + _Utils_Tuple2('path', $mdgriffith$elm_codegen$Elm$Annotation$string) + ]))), + function (url) { ++ var urlPath = $mdgriffith$elm_codegen$Elm$get$('path', url); ++ var strippedPath = $mdgriffith$elm_codegen$Elm$ifThen$( ++ A2($author$project$Gen$String$call_.startsWith, $mdgriffith$elm_codegen$Elm$string(basePath), urlPath), ++ A2( ++ $author$project$Gen$String$call_.dropLeft, ++ $author$project$Gen$String$call_.length($mdgriffith$elm_codegen$Elm$string(basePath)), ++ urlPath), ++ urlPath); + return $mdgriffith$elm_codegen$Elm$withType$( + $mdgriffith$elm_codegen$Elm$Annotation$maybe(routeType.annotation), + segmentsToRouteFn.call( +- $author$project$Generate$splitPath.call( +- $mdgriffith$elm_codegen$Elm$get$('path', url)))); ++ $author$project$Generate$splitPath.call(strippedPath))); + })); + var routeToPathFn = $author$project$Generate$routeToPath$(routeType, routes); + var baseUrl = $mdgriffith$elm_codegen$Elm$Declare$value$( diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f6285f2..7139fce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -30,6 +30,11 @@ catalogs: specifier: ^3.2.0 version: 3.2.4 +patchedDependencies: + elm-pages@3.5.1: + hash: 9b98923a1e6000f00f537833aef8b2c1f83b93bf044b5339ec5b62848787ff5c + path: patches/elm-pages@3.5.1.patch + importers: .: @@ -103,7 +108,7 @@ importers: version: 0.6.3 elm-pages: specifier: 3.5.1 - version: 3.5.1(@types/node@22.19.18)(tslib@2.8.1)(yaml@2.9.0) + version: 3.5.1(patch_hash=9b98923a1e6000f00f537833aef8b2c1f83b93bf044b5339ec5b62848787ff5c)(@types/node@22.19.18)(tslib@2.8.1)(yaml@2.9.0) elm-review: specifier: ^2.13.5 version: 2.13.5 @@ -6921,7 +6926,7 @@ snapshots: ts-union: 2.3.0 typescript: 4.9.5 - elm-pages@3.5.1(@types/node@22.19.18)(tslib@2.8.1)(yaml@2.9.0): + elm-pages@3.5.1(patch_hash=9b98923a1e6000f00f537833aef8b2c1f83b93bf044b5339ec5b62848787ff5c)(@types/node@22.19.18)(tslib@2.8.1)(yaml@2.9.0): dependencies: '@sindresorhus/merge-streams': 4.0.0 busboy: 1.6.0