[ci] format
This commit is contained in:
parent
5e52814d97
commit
99414f76cf
11 changed files with 58 additions and 55 deletions
|
@ -14,7 +14,11 @@
|
||||||
"homepage": "https://astro.build",
|
"homepage": "https://astro.build",
|
||||||
"types": "./dist/types/@types/astro.d.ts",
|
"types": "./dist/types/@types/astro.d.ts",
|
||||||
"typesVersions": {
|
"typesVersions": {
|
||||||
"*": { "app/*": ["./dist/types/core/app/*"] }
|
"*": {
|
||||||
|
"app/*": [
|
||||||
|
"./dist/types/core/app/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": "./astro.js",
|
".": "./astro.js",
|
||||||
|
|
|
@ -665,7 +665,7 @@ export interface AstroIntegration {
|
||||||
// more generalized. Consider the SSR use-case as well.
|
// more generalized. Consider the SSR use-case as well.
|
||||||
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
|
// injectElement: (stage: vite.HtmlTagDescriptor, element: string) => void;
|
||||||
}) => void;
|
}) => void;
|
||||||
'astro:config:done'?: (options: {config: AstroConfig, setAdapter: (adapter: AstroAdapter) => void; }) => void | Promise<void>;
|
'astro:config:done'?: (options: { config: AstroConfig; setAdapter: (adapter: AstroAdapter) => void }) => void | Promise<void>;
|
||||||
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
|
'astro:server:setup'?: (options: { server: vite.ViteDevServer }) => void | Promise<void>;
|
||||||
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
||||||
'astro:server:done'?: () => void | Promise<void>;
|
'astro:server:done'?: () => void | Promise<void>;
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default function createIntegration(): AstroIntegration {
|
||||||
},
|
},
|
||||||
'astro:build:start': ({ buildConfig }) => {
|
'astro:build:start': ({ buildConfig }) => {
|
||||||
buildConfig.staticMode = true;
|
buildConfig.staticMode = true;
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { render } from '../render/core.js';
|
||||||
import { createLinkStylesheetElementSet, createModuleScriptElementWithSrcSet } from '../render/ssr-element.js';
|
import { createLinkStylesheetElementSet, createModuleScriptElementWithSrcSet } from '../render/ssr-element.js';
|
||||||
import { getOutRoot, getOutFolder, getOutFile } from './common.js';
|
import { getOutRoot, getOutFolder, getOutFile } from './common.js';
|
||||||
|
|
||||||
|
|
||||||
// Render is usually compute, which Node.js can't parallelize well.
|
// Render is usually compute, which Node.js can't parallelize well.
|
||||||
// In real world testing, dropping from 10->1 showed a notiable perf
|
// In real world testing, dropping from 10->1 showed a notiable perf
|
||||||
// improvement. In the future, we can revisit a smarter parallel
|
// improvement. In the future, we can revisit a smarter parallel
|
||||||
|
@ -41,7 +40,6 @@ export function getByFacadeId<T>(facadeId: string, map: Map<string, T>): T | und
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Throttle the rendering a paths to prevents creating too many Promises on the microtask queue.
|
// Throttle the rendering a paths to prevents creating too many Promises on the microtask queue.
|
||||||
function* throttle(max: number, inPaths: string[]) {
|
function* throttle(max: number, inPaths: string[]) {
|
||||||
let tmp = [];
|
let tmp = [];
|
||||||
|
@ -150,7 +148,6 @@ interface GeneratePathOptions {
|
||||||
renderers: SSRLoadedRenderer[];
|
renderers: SSRLoadedRenderer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addPageName(pathname: string, opts: StaticBuildOptions): void {
|
function addPageName(pathname: string, opts: StaticBuildOptions): void {
|
||||||
opts.pageNames.push(pathname.replace(/\/?$/, '/').replace(/^\//, ''));
|
opts.pageNames.push(pathname.replace(/\/?$/, '/').replace(/^\//, ''));
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,8 +128,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
}),
|
}),
|
||||||
...(viteConfig.plugins || []),
|
...(viteConfig.plugins || []),
|
||||||
// SSR needs to be last
|
// SSR needs to be last
|
||||||
opts.astroConfig._ctx.adapter?.serverEntrypoint &&
|
opts.astroConfig._ctx.adapter?.serverEntrypoint && vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter),
|
||||||
vitePluginSSR(opts, internals, opts.astroConfig._ctx.adapter),
|
|
||||||
],
|
],
|
||||||
publicDir: ssr ? false : viteConfig.publicDir,
|
publicDir: ssr ? false : viteConfig.publicDir,
|
||||||
root: viteConfig.root,
|
root: viteConfig.root,
|
||||||
|
@ -187,7 +186,6 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async function cleanSsrOutput(opts: StaticBuildOptions) {
|
async function cleanSsrOutput(opts: StaticBuildOptions) {
|
||||||
// The SSR output is all .mjs files, the client output is not.
|
// The SSR output is all .mjs files, the client output is not.
|
||||||
const files = await glob('**/*.mjs', {
|
const files = await glob('**/*.mjs', {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export function vitePluginSSR(buildOpts: StaticBuildOptions, internals: BuildInt
|
||||||
opts.input.push(virtualModuleId);
|
opts.input.push(virtualModuleId);
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
input: [virtualModuleId]
|
input: [virtualModuleId],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -35,9 +35,13 @@ export function vitePluginSSR(buildOpts: StaticBuildOptions, internals: BuildInt
|
||||||
import { deserializeManifest as _deserializeManifest } from 'astro/app';
|
import { deserializeManifest as _deserializeManifest } from 'astro/app';
|
||||||
const _manifest = _deserializeManifest('${manifestReplace}');
|
const _manifest = _deserializeManifest('${manifestReplace}');
|
||||||
|
|
||||||
${adapter.exports ? `const _exports = adapter.createExports(_manifest);
|
${
|
||||||
${adapter.exports.map(name => `export const ${name} = _exports['${name}'];`).join('\n')}
|
adapter.exports
|
||||||
` : ''}
|
? `const _exports = adapter.createExports(_manifest);
|
||||||
|
${adapter.exports.map((name) => `export const ${name} = _exports['${name}'];`).join('\n')}
|
||||||
|
`
|
||||||
|
: ''
|
||||||
|
}
|
||||||
const _start = 'start';
|
const _start = 'start';
|
||||||
if(_start in adapter) {
|
if(_start in adapter) {
|
||||||
adapter[_start](_manifest);
|
adapter[_start](_manifest);
|
||||||
|
@ -60,8 +64,8 @@ if(_start in adapter) {
|
||||||
chunk.fileName = 'entry.mjs';
|
chunk.fileName = 'entry.mjs';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildManifest(bundle: OutputBundle, opts: StaticBuildOptions, internals: BuildInternals): SerializedSSRManifest {
|
function buildManifest(bundle: OutputBundle, opts: StaticBuildOptions, internals: BuildInternals): SerializedSSRManifest {
|
||||||
|
|
|
@ -40,7 +40,7 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
|
||||||
throw new Error(`Adapter already set to ${config._ctx.adapter.name}. You can only have one adapter.`);
|
throw new Error(`Adapter already set to ${config._ctx.adapter.name}. You can only have one adapter.`);
|
||||||
}
|
}
|
||||||
config._ctx.adapter = adapter;
|
config._ctx.adapter = adapter;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ export async function runHookConfigDone({ config }: { config: AstroConfig }) {
|
||||||
config,
|
config,
|
||||||
setAdapter(adapter) {
|
setAdapter(adapter) {
|
||||||
config._ctx.adapter = adapter;
|
config._ctx.adapter = adapter;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ export async function runHookServerDone({ config }: { config: AstroConfig }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig, buildConfig: BuildConfig }) {
|
export async function runHookBuildStart({ config, buildConfig }: { config: AstroConfig; buildConfig: BuildConfig }) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration.hooks['astro:build:start']) {
|
if (integration.hooks['astro:build:start']) {
|
||||||
await integration.hooks['astro:build:start']({ buildConfig });
|
await integration.hooks['astro:build:start']({ buildConfig });
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe('Dynamic pages in SSR', () => {
|
||||||
buildOptions: {
|
buildOptions: {
|
||||||
experimentalSsr: true,
|
experimentalSsr: true,
|
||||||
},
|
},
|
||||||
adapter: testAdapter()
|
adapter: testAdapter(),
|
||||||
});
|
});
|
||||||
await fixture.build();
|
await fixture.build();
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,19 +25,19 @@ export default function() {
|
||||||
if (id === '@my-ssr') {
|
if (id === '@my-ssr') {
|
||||||
return `import { App } from 'astro/app';export function createExports(manifest) { return { manifest, createApp: (root) => new App(manifest, root) }; }`;
|
return `import { App } from 'astro/app';export function createExports(manifest) { return { manifest, createApp: (root) => new App(manifest, root) }; }`;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
'astro:config:done': ({ setAdapter }) => {
|
'astro:config:done': ({ setAdapter }) => {
|
||||||
setAdapter({
|
setAdapter({
|
||||||
name: 'my-ssr-adapter',
|
name: 'my-ssr-adapter',
|
||||||
serverEntrypoint: '@my-ssr',
|
serverEntrypoint: '@my-ssr',
|
||||||
exports: ['manifest', 'createApp']
|
exports: ['manifest', 'createApp'],
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default function createIntegration(): AstroIntegration {
|
||||||
hooks: {
|
hooks: {
|
||||||
'astro:config:done': ({ setAdapter }) => {
|
'astro:config:done': ({ setAdapter }) => {
|
||||||
setAdapter(getAdapter());
|
setAdapter(getAdapter());
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { NodeApp } from 'astro/app/node';
|
||||||
import { polyfill } from '@astrojs/webapi';
|
import { polyfill } from '@astrojs/webapi';
|
||||||
|
|
||||||
polyfill(globalThis, {
|
polyfill(globalThis, {
|
||||||
exclude: 'window document'
|
exclude: 'window document',
|
||||||
});
|
});
|
||||||
|
|
||||||
export function createExports(manifest: SSRManifest) {
|
export function createExports(manifest: SSRManifest) {
|
||||||
|
@ -27,8 +27,8 @@ export function createExports(manifest: SSRManifest) {
|
||||||
} else if (next) {
|
} else if (next) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeWebResponse(res: ServerResponse, webResponse: Response) {
|
async function writeWebResponse(res: ServerResponse, webResponse: Response) {
|
||||||
|
|
Loading…
Reference in a new issue