Buckets:
silverwolf-x/project / packages /next /src /server /app-render /create-component-styles-and-scripts.tsx
| import { interopDefault } from './interop-default' | |
| import { getLinkAndScriptTags } from './get-css-inlined-link-tags' | |
| import type { AppRenderContext } from './app-render' | |
| import { getAssetQueryString } from './get-asset-query-string' | |
| import { encodeURIPath } from '../../shared/lib/encode-uri-path' | |
| import { renderCssResource } from './render-css-resource' | |
| export async function createComponentStylesAndScripts({ | |
| filePath, | |
| getComponent, | |
| injectedCSS, | |
| injectedJS, | |
| ctx, | |
| }: { | |
| filePath: string | |
| getComponent: () => any | |
| injectedCSS: Set<string> | |
| injectedJS: Set<string> | |
| ctx: AppRenderContext | |
| }): Promise<[React.ComponentType<any>, React.ReactNode, React.ReactNode]> { | |
| const { | |
| componentMod: { createElement }, | |
| } = ctx | |
| const { styles: entryCssFiles, scripts: jsHrefs } = getLinkAndScriptTags( | |
| filePath, | |
| injectedCSS, | |
| injectedJS | |
| ) | |
| const styles = renderCssResource(entryCssFiles, ctx) | |
| const scripts: React.ReactNode[] = [] | |
| let scriptIndex = 0 | |
| for (const href of jsHrefs) { | |
| scripts.push( | |
| createElement('script', { | |
| src: `${ctx.assetPrefix}/_next/${encodeURIPath(href)}${getAssetQueryString(ctx, true)}`, | |
| async: true, | |
| key: `script-${scriptIndex}`, | |
| }) | |
| ) | |
| scriptIndex++ | |
| } | |
| const Comp = interopDefault(await getComponent()) | |
| return [Comp, styles, scripts.length ? scripts : null] | |
| } | |
Xet Storage Details
- Size:
- 1.37 kB
- Xet hash:
- ca4aa876dd7d0f3035e949e5ac47c316a0f215180790bedfeecb8918e4dc4d00
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.