[ci] format
This commit is contained in:
parent
aeab890971
commit
5a41ea1202
7 changed files with 25 additions and 26 deletions
|
@ -16,7 +16,6 @@ import { render } from '../render/core.js';
|
|||
import { RouteCache } from '../render/route-cache.js';
|
||||
import {
|
||||
createLinkStylesheetElementSet,
|
||||
createModuleScriptElementWithSrcSet,
|
||||
createModuleScriptElement,
|
||||
} from '../render/ssr-element.js';
|
||||
import { matchRoute } from '../routing/match.js';
|
||||
|
@ -83,7 +82,7 @@ export class App {
|
|||
|
||||
let scripts = new Set<SSRElement>();
|
||||
for (const script of info.scripts) {
|
||||
if (('stage' in script)) {
|
||||
if ('stage' in script) {
|
||||
if (script.stage === 'head-inline') {
|
||||
scripts.add({
|
||||
props: {},
|
||||
|
|
|
@ -12,12 +12,10 @@ export interface RouteInfo {
|
|||
routeData: RouteData;
|
||||
file: string;
|
||||
links: string[];
|
||||
scripts:
|
||||
(
|
||||
// Integration injected
|
||||
{ children: string; stage: string } |
|
||||
scripts: // Integration injected
|
||||
(| { children: string; stage: string }
|
||||
// Hoisted
|
||||
{ type: 'inline' | 'external'; value: string; }
|
||||
| { type: 'inline' | 'external'; value: string }
|
||||
)[];
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,7 @@ import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
|||
import { call as callEndpoint } from '../endpoint/index.js';
|
||||
import { debug, info } from '../logger/core.js';
|
||||
import { render } from '../render/core.js';
|
||||
import {
|
||||
createLinkStylesheetElementSet,
|
||||
createModuleScriptsSet,
|
||||
} from '../render/ssr-element.js';
|
||||
import { createLinkStylesheetElementSet, createModuleScriptsSet } from '../render/ssr-element.js';
|
||||
import { createRequest } from '../request.js';
|
||||
import { getOutputFilename, isBuildingToSSR } from '../util.js';
|
||||
import { getOutFile, getOutFolder } from './common.js';
|
||||
|
@ -167,7 +164,7 @@ interface GeneratePathOptions {
|
|||
pageData: PageBuildData;
|
||||
internals: BuildInternals;
|
||||
linkIds: string[];
|
||||
scripts: { type: 'inline' | 'external', value: string } | null;
|
||||
scripts: { type: 'inline' | 'external'; value: string } | null;
|
||||
mod: ComponentInstance;
|
||||
renderers: SSRLoadedRenderer[];
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export interface PageBuildData {
|
|||
route: RouteData;
|
||||
moduleSpecifier: string;
|
||||
css: Set<string>;
|
||||
hoistedScript: { type: 'inline' | 'external', value: string } | undefined;
|
||||
hoistedScript: { type: 'inline' | 'external'; value: string } | undefined;
|
||||
}
|
||||
export type AllPagesData = Record<ComponentPath, PageBuildData>;
|
||||
|
||||
|
|
|
@ -50,7 +50,9 @@ export function vitePluginHoistedScripts(
|
|||
output.facadeModuleId &&
|
||||
virtualHoistedEntry(output.facadeModuleId)
|
||||
) {
|
||||
const canBeInlined = output.imports.length === 0 && output.dynamicImports.length === 0 &&
|
||||
const canBeInlined =
|
||||
output.imports.length === 0 &&
|
||||
output.dynamicImports.length === 0 &&
|
||||
Buffer.byteLength(output.code) <= assetInlineLimit;
|
||||
let removeFromBundle = false;
|
||||
const facadeId = output.facadeModuleId!;
|
||||
|
@ -62,13 +64,13 @@ export function vitePluginHoistedScripts(
|
|||
if (canBeInlined) {
|
||||
pageInfo.hoistedScript = {
|
||||
type: 'inline',
|
||||
value: output.code
|
||||
value: output.code,
|
||||
};
|
||||
removeFromBundle = true;
|
||||
} else {
|
||||
pageInfo.hoistedScript = {
|
||||
type: 'external',
|
||||
value: id
|
||||
value: id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,10 @@ export function createLinkStylesheetElementSet(hrefs: string[], site?: string) {
|
|||
return new Set<SSRElement>(hrefs.map((href) => createLinkStylesheetElement(href, site)));
|
||||
}
|
||||
|
||||
export function createModuleScriptElement(script: { type: 'inline' | 'external'; value: string; }, site?: string): SSRElement {
|
||||
export function createModuleScriptElement(
|
||||
script: { type: 'inline' | 'external'; value: string },
|
||||
site?: string
|
||||
): SSRElement {
|
||||
if (script.type === 'external') {
|
||||
return createModuleScriptElementWithSrc(script.value, site);
|
||||
} else {
|
||||
|
@ -56,8 +59,8 @@ export function createModuleScriptElementWithSrcSet(
|
|||
}
|
||||
|
||||
export function createModuleScriptsSet(
|
||||
scripts: { type: 'inline' | 'external'; value: string; }[],
|
||||
scripts: { type: 'inline' | 'external'; value: string }[],
|
||||
site?: string
|
||||
): Set<SSRElement> {
|
||||
return new Set<SSRElement>(scripts.map(script => createModuleScriptElement(script, site)));
|
||||
return new Set<SSRElement>(scripts.map((script) => createModuleScriptElement(script, site)));
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ describe('Scripts (hoisted and not)', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('Inline scripts that are shared by multiple pages create chunks, and aren\'t inlined into the HTML', async () => {
|
||||
it("Inline scripts that are shared by multiple pages create chunks, and aren't inlined into the HTML", async () => {
|
||||
let html = await fixture.readFile('/inline-shared-one/index.html');
|
||||
let $ = cheerio.load(html);
|
||||
|
||||
|
|
Loading…
Reference in a new issue