Files
zeekay 1830fcf955 Dev and the export are built by Turbopack, whose compile takes 4 s warm and 30 s cold on six cores where webpack's took 79 s and 3 minutes
next dev and next build run Turbopack, Next 16's default, and the
webpack() hook and --webpack flags are gone. react-native is
react-native-web by turbopack.resolveAlias, and .web files resolve first
by turbopack.resolveExtensions, which Turbopack applies to the project
and transpilePackages only: react-native-svg joins that list, or its
native build is bundled (Flow source, TurboModuleRegistry) and the build
fails.

The export has the same 1,020 pages and the same 1,463 other files byte
for byte. With chunk names set aside, 973 pages are identical and the
rest differ as two webpack builds differ from each other (gui style
order, a race in the code samples' colors), except /benchmarks, whose
bars move by 1e-14 % because Turbopack parses a JSON float one bit off.
Every head gains a same-origin preconnect and next-size-adjust.

The font preload reads Turbopack's asset hash, the stale-chunk reload
keys on ChunkLoadError, which Turbopack names every failed chunk, and
the deploy carries turbopack/ in its cache in place of webpack/.
2026-10-18 16:25:37 -07:00

28 lines
1.7 KiB
TypeScript

/**
* Scripts that run in the document head, before any module: what has to hold
* before the router, the tags or the app read the page.
*/
/**
* One slash at the front of the address. `hanzo.ai//models/x` serves the page,
* but `//models/x` is a URL with a host: the router's first `replaceState` reads it
* as https://models/x and the browser refuses it (SecurityError), and every later
* write from `location.pathname` would do the same. Rewritten as the head is
* parsed, nothing after it sees the doubled slash.
*/
export const ONE_SLASH = `(function(){try{var l=location;if(/^\\/\\/+/.test(l.pathname))history.replaceState(null,'',l.pathname.replace(/^\\/+/,'/')+l.search+l.hash)}catch(_){}})()`
/** Where `STALE` writes down when it last reloaded, in this tab. */
export const RELOADED = 'hz:stale-reload'
/**
* A chunk that no longer exists is a page from before a deploy: the export it
* named has been replaced, and nothing on this page can load the rest. One
* reload takes the current page. Once per minute per tab, so a chunk that is
* missing from the current deploy too reports instead of reloading forever;
* `window.hzStale` says a reload is under way, so the error reporter does not
* count the failure it is recovering from. Turbopack's runtime names every
* failed chunk, script or stylesheet, `ChunkLoadError`.
*/
export const STALE = `(function(){function s(x){var e=x&&(x.reason||x.error)||x;return!!e&&e.name==='ChunkLoadError'}function r(x){if(!s(x))return;try{var t=+sessionStorage.getItem('${RELOADED}')||0;if(Date.now()-t<60000)return;sessionStorage.setItem('${RELOADED}',String(Date.now()))}catch(_){return}window.hzStale=true;location.reload()}addEventListener('error',r);addEventListener('unhandledrejection',r)})()`