-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid implicit head injection when there is a head element in the tree (
#6638) * Avoid implicit head injection when there is a head element in the tree * more * only do it once * Update the tests * Update more tests * update compiler version * See if scope stuff can be removed now * Move up where head injection occurs * Remove result scoping
- Loading branch information
Showing
37 changed files
with
260 additions
and
300 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Avoid implicit head injection when a head is in the tree |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import type { SSRResult, SSRComponentMetadata } from '../../../@types/astro'; | ||
|
||
import type { ModuleInfo, ModuleLoader } from '../../module-loader/index'; | ||
|
||
import { getAstroMetadata } from '../../../vite-plugin-astro/index.js'; | ||
import { viteID } from '../../util.js'; | ||
import { crawlGraph } from './vite.js'; | ||
|
||
export async function getComponentMetadata( | ||
filePath: URL, | ||
loader: ModuleLoader | ||
): Promise<SSRResult['componentMetadata']> { | ||
const map: SSRResult['componentMetadata'] = new Map(); | ||
|
||
const rootID = viteID(filePath); | ||
addMetadata(map, loader.getModuleInfo(rootID)); | ||
for await (const moduleNode of crawlGraph(loader, rootID, true)) { | ||
const id = moduleNode.id; | ||
if (id) { | ||
addMetadata(map, loader.getModuleInfo(id)); | ||
} | ||
} | ||
|
||
return map; | ||
} | ||
|
||
function addMetadata( | ||
map: SSRResult['componentMetadata'], | ||
modInfo: ModuleInfo | null | ||
) { | ||
if (modInfo) { | ||
const astro = getAstroMetadata(modInfo); | ||
if(astro) { | ||
let metadata: SSRComponentMetadata = { | ||
containsHead: false, | ||
propagation: 'none' | ||
}; | ||
if(astro.propagation) { | ||
metadata.propagation = astro.propagation; | ||
} | ||
if(astro.containsHead) { | ||
metadata.containsHead = astro.containsHead; | ||
} | ||
map.set(modInfo.id, metadata); | ||
} | ||
} | ||
} |
Oops, something went wrong.