🚧 CDN pivot: stop building the webpack Pages bundle, serve eyereasoner from a CDN + redirect old Pages URLs - #1
Closed
jeswr wants to merge 1 commit into
Closed
🚧 CDN pivot: stop building the webpack Pages bundle, serve eyereasoner from a CDN + redirect old Pages URLs#1jeswr wants to merge 1 commit into
jeswr wants to merge 1 commit into
Conversation
…d of building the webpack bundle Stop building and publishing the ~4MB webpack bundle to the `pages` branch on every release (which grew the branch to ~7.5GB). Instead: - README and the prebuilt example now use a public ESM CDN (esm.sh, with jsDelivr as a drop-in alternative) for both ESM `import` and classic `<script>` usage. The package is self-contained (WASM + EYE image inlined), so there are no separate .wasm/.data assets to host. - Two tiny, self-deriving redirect stubs (redirects/index.js classic global, redirects/dynamic-import.js ESM) derive the requested version from their own URL and load it from the CDN. Broadcast byte-identically to every path they collapse to 2 unique blobs, so old Pages URLs keep working with ~0 growth. - scripts/generate-redirects.ts replaces the webpack + post-webpack Pages emission in the release workflow and also writes the `.nojekyll` marker; the gh-pages publish now ships the stub tree (dotfiles enabled). Refs eyereasoner#1845. Supersedes the build-and-prune approach of eyereasoner#1955. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
Relocated to the canonical repo: eyereasoner#1957 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚧 Stop building the webpack Pages bundle; serve
eyereasonerfrom a CDN and redirect the old Pages URLsReferences eyereasoner#1845. Supersedes / re-frames eyereasoner#1955: rather than keep building the bundle and prune it every release, this stops building it at all and replaces it with CDN redirects.
The pivot
Today each release builds a ~4MB webpack bundle and publishes it to the
pagesbranch, which has grown to ~7.5GB (~7× the 1GB Pages limit) and keeps breaking the Pages deployment. eyereasoner#1955 bounds that growth by pruning. This PR removes the cause instead:eyereasoneris already published to npm and is served, with no build step on our side, by public ESM CDNs. The README andexamples/prebuilt/index.htmlnow use esm.sh (with jsDelivr as a drop-in alternative) for both ESMimportand classic<script>usage.redirects/index.jsclassic global,redirects/dynamic-import.jsESM) read their own URL, work out the requested version, and load it from the CDN. Broadcast byte-identically across everyindex.js/dynamic-import.jspath they collapse (git blob dedup) to 2 unique blobs — so every existing URL keeps answering200 + JSwith ~0 per-release growth and zero per-version authoring. No "hundreds of redirect pages."scripts/generate-redirects.tsreplaces thebundle:webpack+post-webpackPages emission (deletedscripts/post-webpack.ts) and writes.nojekyll; the@qiwi/semantic-release-gh-pages-pluginpublish now ships the tiny stub tree (dotfiles: trueso.nojekyllis included).Verdict:
VIABLE_WITH_CAVEATSA CDN serves a fully working, actually-reasoning
eyereasonerfor ESMimport— proven end-to-end, not just "the JS resolves."The swipl-wasm gating risk does not apply to this package. eyereasoner uses the
swipl-bundle-no-datavariant: the SWI-Prolog WASM and the EYE.pvmimage are inlined in the JavaScript. There is no runtime.wasm/.dataasset to locate cross-origin (grep forlocateFile/instantiateStreaming/new URL(...wasm)/swipl-web.wasmin the eyereasoner code path = 0 hits). Verified in node: dynamic-import()ofhttps://esm.sh/eyereasoner@21.1.10over the network booted the inline WASM and inferred:Socrates a :Mortal.; decoding the inline binary from both the local npm bundle and the esm.sh.mjsreconstructs a byte-identical WASM.The one caveat (keeps this from a clean VIABLE): a classic
<script src=…>that expects a synchronouswindow.eyereasonerglobal cannot be reproduced from the current npm package by any CDN — eyereasoner publishes CJS only (no UMD/IIFE), and CDNs emit ESM. The classic redirect stub therefore populateswindow.eyereasonerasynchronously and uses aProxysoawait eyereasoner.n3reasoner(…)keeps working (matches the documented usage). A consumer reading a non-callable property synchronously, or not awaiting, would see a behavioural change. Optional fix (Option B, not in this PR): add oneesbuild --format=iife --global-name=eyereasonerartifact to the eyereasoner package so oldindex.jsURLs can 1:1 redirect to a true synchronous global.Everything above was verified headless in node; the browser WASM path is the one thing that could not be exercised here. Open a page containing:
Confirm (1) it prints
:Socrates a :Mortal.and (2) DevTools → Network shows no 404 / opaque request for anyswipl-web.wasm/swipl-web.data(there should be none — the WASM is inline). The browser WEB path instantiates the same byte-identical inline WASM viaWebAssembly.instantiate(ArrayBuffer)with no fetch, so risk is low — but it is the one path not exercised here.What's in this PR
README.mdexamples/prebuilt/index.html<script src=…pages…>→<script type="module">import { n3reasoner } from 'https://esm.sh/eyereasoner'redirects/index.jsredirects/dynamic-import.jseyereasoner)scripts/generate-redirects.tslatestshortcuts +.nojekyllscripts/post-webpack.ts.github/workflows/nodejs.ymlbundle:redirectsinstead ofbundle:webpack+bundle:latestpackage.jsonbundle:latest→bundle:redirects; gh-pages plugindotfiles: truewebpack.config.js/bundle:webpackare kept — still used by the browser E2E/memory tests (which are the in-browser WASM verification). See open question 1.Validation (headless, gated
flock+nice)npm run lint(eslint, project config): 0 errors on touched TS.tsc --noEmitonscripts/generate-redirects.ts: clean.ts-node scripts/generate-redirects --name=v21.1.10 --out=…: produced exactly21/1/10/,21/1/latest/,21/latest/,latest/(each withindex.js+dynamic-import.js) +.nojekyll; stubs byte-identical (md5) to the canonicalredirects/*.js.node --check-parse; URL→CDN derivation unit-checked forlatest,@M,@M.m,@M.m.p, root, and?queryshapes.esm.sh/eyereasoner,@21,@21.1,@21.1.10, andjsdelivr …/+esmallHTTP 200,content-type: application/javascript; charset=utf-8,access-control-allow-origin: *.Follow-ups (need @jeswr sign-off — NOT in this PR)
pagesas a single orphan commit = the 2 stubs broadcast to all existing paths +.nojekyll+404.html+example/+dev/bench/, then force-push. This prunes 7.5GB → a few MB and installs the redirects for all historical URLs in one step. Force-push needs explicit approval — deliberately excluded here..nojekyllmarker (the patch-prune logic is moot once bundles aren't produced).Open questions
bundle:webpackfor the browser E2E/memory tests (they provide the actual in-browser WASM check). Migrate those to the CDN/npmdistand delete webpack, or keep?latest/@M/@M.mlive, so a bad future npm publish would propagate to old URLs. Acceptable, or pin to a known-good range?dist/pin survive).🤖 Generated with Claude Code