Posterverse: on the dev server, read the built tree from its root, not /public/
On a staging page the manifest fallback was /public/<tree>/manifest.json, which
made /public/<tree>/ the base for every child script. The dev server treats a
/public/… request as source and injects an import into the built IIFE, so the
child failed as a classic script ("Cannot use import statement outside a
module"). The fallback is now /<tree>/manifest.json, where the dev server serves
the built tree unchanged. Built trees are unaffected (they resolve the manifest
before this fallback).
This commit is contained in:
parent
8c05f6207a
commit
09d884ce3a
1 changed files with 4 additions and 2 deletions
|
|
@ -281,7 +281,9 @@ export default defineComponent({
|
|||
// 2. <tree>/doxa-maps-spa/manifest.json, the byte-identical copy generate-tree writes for the
|
||||
// Research Gallery. The live static layer sends CORS headers only inside a tree folder, not
|
||||
// on the root manifest, so a partner page's script embed reads this copy FIRST;
|
||||
// 3. /public/<tree>/manifest.json, where the dev server keeps the built manifest.
|
||||
// 3. /<tree>/manifest.json, the built tree as the dev server serves it (at the ROOT). NOT /public/<tree>/:
|
||||
// the dev server treats a /public/… request as SOURCE and injects an import into each built IIFE, which
|
||||
// then fails as a classic script ("Cannot use import statement outside a module").
|
||||
// Script URLs always resolve against the tree ROOT, never the copy's folder.
|
||||
loadManifest() {
|
||||
const dirOf = (u) => { try { return new URL(u, location.href).href.replace(/[^/]*$/, '') } catch { return '' } }
|
||||
|
|
@ -291,7 +293,7 @@ export default defineComponent({
|
|||
let crossOrigin = false
|
||||
try { crossOrigin = new URL(rootUrl, location.href).origin !== location.origin } catch { /* relative = same */ }
|
||||
const candidates = crossOrigin ? [copy, root] : [root, copy]
|
||||
const devFallback = '/public/' + __DOXA_TREE_NAME__ + '/manifest.json'
|
||||
const devFallback = '/' + __DOXA_TREE_NAME__ + '/manifest.json'
|
||||
if (!candidates.some((c) => c.url === devFallback)) candidates.push({ url: devFallback, root: dirOf(devFallback) })
|
||||
const tried = []
|
||||
const attempt = (i) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue