mirror of
https://github.com/withastro/astro.git
synced 2025-02-10 22:38:53 -05:00
Fix npm install (#1407)
This commit is contained in:
parent
1d2da117bd
commit
71e721c520
5 changed files with 60 additions and 58 deletions
|
@ -48,7 +48,7 @@
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
||||||
"@typescript-eslint/parser": "^4.18.0",
|
"@typescript-eslint/parser": "^4.18.0",
|
||||||
"autoprefixer": "^10.2.6",
|
"autoprefixer": "^10.2.6",
|
||||||
"cheerio": "^1.0.0-rc.6",
|
"cheerio": "^1.0.0-rc.10",
|
||||||
"cheerio-select-tmp": "^0.1.1",
|
"cheerio-select-tmp": "^0.1.1",
|
||||||
"del": "^6.0.0",
|
"del": "^6.0.0",
|
||||||
"esbuild": "^0.11.17",
|
"esbuild": "^0.11.17",
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
"@web/rollup-plugin-html": "^1.9.1",
|
"@web/rollup-plugin-html": "^1.9.1",
|
||||||
"acorn": "^7.4.0",
|
"acorn": "^7.4.0",
|
||||||
"astring": "^1.7.5",
|
"astring": "^1.7.5",
|
||||||
|
"cheerio": "^1.0.0-rc.10",
|
||||||
"ci-info": "^3.2.0",
|
"ci-info": "^3.2.0",
|
||||||
"connect": "^3.7.0",
|
"connect": "^3.7.0",
|
||||||
"es-module-lexer": "^0.7.1",
|
"es-module-lexer": "^0.7.1",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import '/@vite/client';
|
import '@vite/client';
|
||||||
|
|
||||||
if (import.meta.hot) {
|
if (import.meta.hot) {
|
||||||
const parser = new DOMParser();
|
const parser = new DOMParser();
|
||||||
|
|
|
@ -175,8 +175,7 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
|
|
||||||
const Component = await mod.default;
|
const Component = await mod.default;
|
||||||
const ext = path.posix.extname(filePath.pathname);
|
const ext = path.posix.extname(filePath.pathname);
|
||||||
if (!Component)
|
if (!Component) throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
|
||||||
throw new Error(`Expected an exported Astro component but received typeof ${typeof Component}`);
|
|
||||||
|
|
||||||
if (!Component.isAstroComponentFactory) throw new Error(`Unable to SSR non-Astro component (${route?.component})`);
|
if (!Component.isAstroComponentFactory) throw new Error(`Unable to SSR non-Astro component (${route?.component})`);
|
||||||
|
|
||||||
|
@ -187,18 +186,18 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
createAstro: (props: any) => {
|
createAstro: (props: any) => {
|
||||||
const site = new URL(origin);
|
const site = new URL(origin);
|
||||||
const url = new URL('.' + pathname, site);
|
const url = new URL('.' + pathname, site);
|
||||||
const canonicalURL = getCanonicalURL(pathname, astroConfig.buildOptions.site || origin)
|
const canonicalURL = getCanonicalURL(pathname, astroConfig.buildOptions.site || origin);
|
||||||
const fetchContent = createFetchContent(fileURLToPath(filePath));
|
const fetchContent = createFetchContent(fileURLToPath(filePath));
|
||||||
return {
|
return {
|
||||||
isPage: true,
|
isPage: true,
|
||||||
site,
|
site,
|
||||||
request: { url, canonicalURL },
|
request: { url, canonicalURL },
|
||||||
props,
|
props,
|
||||||
fetchContent
|
fetchContent,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
_metadata: { importedModules, renderers },
|
_metadata: { importedModules, renderers },
|
||||||
}
|
};
|
||||||
|
|
||||||
const createFetchContent = (currentFilePath: string) => {
|
const createFetchContent = (currentFilePath: string) => {
|
||||||
const fetchContentCache = new Map<string, any>();
|
const fetchContentCache = new Map<string, any>();
|
||||||
|
@ -209,14 +208,16 @@ export async function ssr({ astroConfig, filePath, logging, mode, origin, pathna
|
||||||
return fetchContentCache.get(cacheKey);
|
return fetchContentCache.get(cacheKey);
|
||||||
}
|
}
|
||||||
const files = await glob(pattern, { cwd, absolute: true });
|
const files = await glob(pattern, { cwd, absolute: true });
|
||||||
const contents = await Promise.all(files.map(async file => {
|
const contents = await Promise.all(
|
||||||
|
files.map(async (file) => {
|
||||||
const { metadata: astro = {}, frontmatter = {} } = (await viteServer.ssrLoadModule(file)) as any;
|
const { metadata: astro = {}, frontmatter = {} } = (await viteServer.ssrLoadModule(file)) as any;
|
||||||
return { ...frontmatter, astro };
|
return { ...frontmatter, astro };
|
||||||
}))
|
})
|
||||||
|
);
|
||||||
fetchContentCache.set(cacheKey, contents);
|
fetchContentCache.set(cacheKey, contents);
|
||||||
return contents;
|
return contents;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
let html = await renderPage(result, Component, {}, null);
|
let html = await renderPage(result, Component, {}, null);
|
||||||
|
|
||||||
|
|
|
@ -3496,7 +3496,7 @@ cheerio-select@^1.5.0:
|
||||||
domhandler "^4.2.0"
|
domhandler "^4.2.0"
|
||||||
domutils "^2.7.0"
|
domutils "^2.7.0"
|
||||||
|
|
||||||
cheerio@^1.0.0-rc.6, cheerio@~1.0.0-rc.3:
|
cheerio@^1.0.0-rc.10, cheerio@~1.0.0-rc.3:
|
||||||
version "1.0.0-rc.10"
|
version "1.0.0-rc.10"
|
||||||
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.10.tgz#2ba3dcdfcc26e7956fc1f440e61d51c643379f3e"
|
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.10.tgz#2ba3dcdfcc26e7956fc1f440e61d51c643379f3e"
|
||||||
integrity sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==
|
integrity sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw==
|
||||||
|
|
Loading…
Add table
Reference in a new issue