From 0616ef255145bf173386b94474dede376e1f2037 Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Sat, 20 May 2023 09:00:31 -0700 Subject: [PATCH 1/7] [ci] release (#7130) Co-authored-by: github-actions[bot] --- .changeset/brown-goats-serve.md | 6 ------ .changeset/eleven-tables-speak.md | 5 ----- .changeset/friendly-garlics-chew.md | 5 ----- .changeset/good-frogs-report.md | 5 ----- .changeset/popular-rules-provide.md | 5 ----- .changeset/swift-lamps-doubt.md | 5 ----- .changeset/tasty-geese-fix.md | 5 ----- packages/astro/CHANGELOG.md | 14 ++++++++++++++ packages/astro/package.json | 2 +- packages/integrations/cloudflare/package.json | 2 +- packages/integrations/deno/package.json | 2 +- packages/integrations/image/package.json | 2 +- packages/integrations/markdoc/CHANGELOG.md | 9 +++++++++ packages/integrations/markdoc/package.json | 4 ++-- packages/integrations/netlify/package.json | 2 +- packages/integrations/node/package.json | 2 +- packages/integrations/prefetch/CHANGELOG.md | 6 ++++++ packages/integrations/prefetch/package.json | 2 +- packages/integrations/svelte/package.json | 2 +- packages/integrations/tailwind/package.json | 2 +- packages/integrations/vercel/package.json | 2 +- packages/integrations/vue/package.json | 2 +- 22 files changed, 42 insertions(+), 49 deletions(-) delete mode 100644 .changeset/brown-goats-serve.md delete mode 100644 .changeset/eleven-tables-speak.md delete mode 100644 .changeset/friendly-garlics-chew.md delete mode 100644 .changeset/good-frogs-report.md delete mode 100644 .changeset/popular-rules-provide.md delete mode 100644 .changeset/swift-lamps-doubt.md delete mode 100644 .changeset/tasty-geese-fix.md diff --git a/.changeset/brown-goats-serve.md b/.changeset/brown-goats-serve.md deleted file mode 100644 index c4fe4d0167fab..0000000000000 --- a/.changeset/brown-goats-serve.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@astrojs/prefetch': patch ---- - -Fix the inclusion of `@types/network-information`. - diff --git a/.changeset/eleven-tables-speak.md b/.changeset/eleven-tables-speak.md deleted file mode 100644 index 44aff3211034d..0000000000000 --- a/.changeset/eleven-tables-speak.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/markdoc': patch ---- - -Fix inconsistent Markdoc heading IDs for documents with the same headings. diff --git a/.changeset/friendly-garlics-chew.md b/.changeset/friendly-garlics-chew.md deleted file mode 100644 index cf45ecd77f571..0000000000000 --- a/.changeset/friendly-garlics-chew.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix routes created by `injectRoute` for SSR diff --git a/.changeset/good-frogs-report.md b/.changeset/good-frogs-report.md deleted file mode 100644 index fdac3299ecdf9..0000000000000 --- a/.changeset/good-frogs-report.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Emit middleware as an entrypoint during build diff --git a/.changeset/popular-rules-provide.md b/.changeset/popular-rules-provide.md deleted file mode 100644 index ada5a2da0c7e5..0000000000000 --- a/.changeset/popular-rules-provide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Emit pages as dynamic import chunks during the build diff --git a/.changeset/swift-lamps-doubt.md b/.changeset/swift-lamps-doubt.md deleted file mode 100644 index 2ee2f6fb35fe3..0000000000000 --- a/.changeset/swift-lamps-doubt.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Add route information when warning of `getStaticPaths()` ignored diff --git a/.changeset/tasty-geese-fix.md b/.changeset/tasty-geese-fix.md deleted file mode 100644 index 5c02621a686a0..0000000000000 --- a/.changeset/tasty-geese-fix.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fix unnecessary warning showing on start when a collection folder was empty. The warning was also enhanced to add more information about possible causes. diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index e2f8db0b5c017..df863fc9459ea 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,19 @@ # astro +## 2.5.1 + +### Patch Changes + +- [#7128](https://github.com/withastro/astro/pull/7128) [`72f686a68`](https://github.com/withastro/astro/commit/72f686a68930de52f9a274c13c98acad59925b31) Thanks [@johannesspohr](https://github.com/johannesspohr)! - Fix routes created by `injectRoute` for SSR + +- [#7132](https://github.com/withastro/astro/pull/7132) [`319a0a7a0`](https://github.com/withastro/astro/commit/319a0a7a0a6a950387c942b467746d590bb32fda) Thanks [@ematipico](https://github.com/ematipico)! - Emit middleware as an entrypoint during build + +- [#7036](https://github.com/withastro/astro/pull/7036) [`852d59a8d`](https://github.com/withastro/astro/commit/852d59a8d68e124f10852609e0f1619d5838ac76) Thanks [@ematipico](https://github.com/ematipico)! - Emit pages as dynamic import chunks during the build + +- [#7126](https://github.com/withastro/astro/pull/7126) [`530fb9ebe`](https://github.com/withastro/astro/commit/530fb9ebee77646921ec29d45d9b66484bdfb521) Thanks [@bluwy](https://github.com/bluwy)! - Add route information when warning of `getStaticPaths()` ignored + +- [#7118](https://github.com/withastro/astro/pull/7118) [`3257dd289`](https://github.com/withastro/astro/commit/3257dd28901c785a6a661211b98c5ef2cb3b9aa4) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fix unnecessary warning showing on start when a collection folder was empty. The warning was also enhanced to add more information about possible causes. + ## 2.5.0 ### Minor Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 7acfa77e64ff4..ddfa988c4709b 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "2.5.0", + "version": "2.5.1", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 5541200ba6400..6a0081fe9b901 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -42,7 +42,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/deno/package.json b/packages/integrations/deno/package.json index f5f9657d8bb6c..e58e3549141c7 100644 --- a/packages/integrations/deno/package.json +++ b/packages/integrations/deno/package.json @@ -36,7 +36,7 @@ "esbuild": "^0.15.18" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/image/package.json b/packages/integrations/image/package.json index a685dcd74e01b..f3cd9f772abe9 100644 --- a/packages/integrations/image/package.json +++ b/packages/integrations/image/package.json @@ -62,7 +62,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.0", + "astro": "workspace:^2.5.1", "sharp": ">=0.31.0" }, "peerDependenciesMeta": { diff --git a/packages/integrations/markdoc/CHANGELOG.md b/packages/integrations/markdoc/CHANGELOG.md index 4728f1863785c..f39c514c468d3 100644 --- a/packages/integrations/markdoc/CHANGELOG.md +++ b/packages/integrations/markdoc/CHANGELOG.md @@ -1,5 +1,14 @@ # @astrojs/markdoc +## 0.2.1 + +### Patch Changes + +- [#7141](https://github.com/withastro/astro/pull/7141) [`a9e1cd7e5`](https://github.com/withastro/astro/commit/a9e1cd7e58794fe220539c2ed935c9eb96bab55a) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix inconsistent Markdoc heading IDs for documents with the same headings. + +- Updated dependencies [[`72f686a68`](https://github.com/withastro/astro/commit/72f686a68930de52f9a274c13c98acad59925b31), [`319a0a7a0`](https://github.com/withastro/astro/commit/319a0a7a0a6a950387c942b467746d590bb32fda), [`852d59a8d`](https://github.com/withastro/astro/commit/852d59a8d68e124f10852609e0f1619d5838ac76), [`530fb9ebe`](https://github.com/withastro/astro/commit/530fb9ebee77646921ec29d45d9b66484bdfb521), [`3257dd289`](https://github.com/withastro/astro/commit/3257dd28901c785a6a661211b98c5ef2cb3b9aa4)]: + - astro@2.5.1 + ## 0.2.0 ### Minor Changes diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index acda2e24001b9..e67ff83e0458d 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/markdoc", "description": "Add support for Markdoc pages in your Astro site", - "version": "0.2.0", + "version": "0.2.1", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", @@ -47,7 +47,7 @@ "zod": "^3.17.3" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "@astrojs/markdown-remark": "^2.2.1", diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index fce39c646a7d5..09dc06567b168 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -42,7 +42,7 @@ "esbuild": "^0.15.18" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "@netlify/edge-functions": "^2.0.0", diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index f98b58f5927d5..980614b158592 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -38,7 +38,7 @@ "server-destroy": "^1.0.1" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "@types/send": "^0.17.1", diff --git a/packages/integrations/prefetch/CHANGELOG.md b/packages/integrations/prefetch/CHANGELOG.md index 96cd904bb6054..aef6973624677 100644 --- a/packages/integrations/prefetch/CHANGELOG.md +++ b/packages/integrations/prefetch/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/prefetch +## 0.2.3 + +### Patch Changes + +- [#7123](https://github.com/withastro/astro/pull/7123) [`147373722`](https://github.com/withastro/astro/commit/147373722b37126af949bb054a1cdfb0aed6c2ff) Thanks [@connor-baer](https://github.com/connor-baer)! - Fix the inclusion of `@types/network-information`. + ## 0.2.2 ### Patch Changes diff --git a/packages/integrations/prefetch/package.json b/packages/integrations/prefetch/package.json index 03c7508e91ddc..899d41d41567f 100644 --- a/packages/integrations/prefetch/package.json +++ b/packages/integrations/prefetch/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/prefetch", "description": "Prefetch page navigations in your Astro site", - "version": "0.2.2", + "version": "0.2.3", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 8f646974527e3..bb3b0e7c35b33 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -48,7 +48,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.0", + "astro": "workspace:^2.5.1", "svelte": "^3.54.0" }, "engines": { diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index ad8ee6b37956c..236e42bd5af87 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -44,7 +44,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.0", + "astro": "workspace:^2.5.1", "tailwindcss": "^3.0.24" }, "pnpm": { diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 012eb264a29be..eab3cd41fb2ae 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -59,7 +59,7 @@ "web-vitals": "^3.1.1" }, "peerDependencies": { - "astro": "workspace:^2.5.0" + "astro": "workspace:^2.5.1" }, "devDependencies": { "@types/set-cookie-parser": "^2.4.2", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index b49456f5ec3c1..3c226be405c55 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -56,7 +56,7 @@ "vue": "^3.2.37" }, "peerDependencies": { - "astro": "workspace:^2.5.0", + "astro": "workspace:^2.5.1", "vue": "^3.2.30" }, "engines": { From 8f418d13c5d5c9c40f05020205f24380b718654b Mon Sep 17 00:00:00 2001 From: Happydev <81974850+MoustaphaDev@users.noreply.github.com> Date: Mon, 22 May 2023 12:58:03 +0000 Subject: [PATCH 2/7] fix(hybrid-output): no matched route when using `getStaticPaths` (#7150) * `isPrenderDefault` ---> `isPrerenderDefault` * test: add test fixture * test: add hybrid getStaticPaths tests * try fix in ci * bring back edit lost on merge conflict fix * back static paths guard * move function to new file to avoid bundling issues * remove unsued import * debugging cleanup * chore: update fixture's package.json * cleanup test * small test refactoring * `status.ts` --> `metadata.ts` * smol refactor * chore: changeset * just return the prerender metadata * refactor tests * chore: update lock file --- .changeset/strange-ties-cry.md | 5 + .../core/build/plugins/plugin-prerender.ts | 3 +- packages/astro/src/core/endpoint/index.ts | 2 +- packages/astro/src/core/render/core.ts | 2 +- packages/astro/src/core/render/dev/index.ts | 1 + packages/astro/src/core/render/route-cache.ts | 2 +- .../astro/src/core/routing/manifest/create.ts | 6 +- packages/astro/src/core/routing/validation.ts | 4 +- packages/astro/src/prerender/metadata.ts | 22 ++ .../src/vite-plugin-astro-server/route.ts | 12 + .../ssr-prerender-get-static-paths.test.js | 358 +++++++++++++----- pnpm-lock.yaml | 21 +- 12 files changed, 318 insertions(+), 120 deletions(-) create mode 100644 .changeset/strange-ties-cry.md create mode 100644 packages/astro/src/prerender/metadata.ts diff --git a/.changeset/strange-ties-cry.md b/.changeset/strange-ties-cry.md new file mode 100644 index 0000000000000..0c6139cfcba73 --- /dev/null +++ b/.changeset/strange-ties-cry.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +fix no matched path when using `getStaticPaths` without `prerender` export. diff --git a/packages/astro/src/core/build/plugins/plugin-prerender.ts b/packages/astro/src/core/build/plugins/plugin-prerender.ts index e787b17d66912..b950a83ea5ac4 100644 --- a/packages/astro/src/core/build/plugins/plugin-prerender.ts +++ b/packages/astro/src/core/build/plugins/plugin-prerender.ts @@ -4,6 +4,7 @@ import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; import type { StaticBuildOptions } from '../types'; import { extendManualChunks } from './util.js'; +import { getPrerenderMetadata } from '../../../prerender/metadata.js'; function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals): VitePlugin { return { @@ -20,7 +21,7 @@ function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals if (pageInfo) { // prerendered pages should be split into their own chunk // Important: this can't be in the `pages/` directory! - if (meta.getModuleInfo(id)?.meta.astro?.pageOptions?.prerender) { + if (getPrerenderMetadata(meta.getModuleInfo(id))) { pageInfo.route.prerender = true; return 'prerender'; } diff --git a/packages/astro/src/core/endpoint/index.ts b/packages/astro/src/core/endpoint/index.ts index c005efb1f4e95..7d298a80226d9 100644 --- a/packages/astro/src/core/endpoint/index.ts +++ b/packages/astro/src/core/endpoint/index.ts @@ -138,7 +138,7 @@ export async function callEndpoint }; } - if (env.ssr && !mod.prerender) { + if (env.ssr && !ctx.route?.prerender) { if (response.hasOwnProperty('headers')) { warn( logging, diff --git a/packages/astro/src/core/render/core.ts b/packages/astro/src/core/render/core.ts index 1c12a1a8d6e56..2d6fb088ee27d 100644 --- a/packages/astro/src/core/render/core.ts +++ b/packages/astro/src/core/render/core.ts @@ -89,7 +89,7 @@ export async function getParamsAndProps( routeCache.set(route, routeCacheEntry); } const matchedStaticPath = findPathItemByKey(routeCacheEntry.staticPaths, params, route); - if (!matchedStaticPath && (ssr ? mod.prerender : true)) { + if (!matchedStaticPath && (ssr ? route.prerender : true)) { return GetParamsAndPropsError.NoMatchingStaticPath; } // Note: considered using Object.create(...) for performance diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index 267c6515d31cc..26e7c85d53b55 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -66,6 +66,7 @@ export async function preload({ try { // Load the module from the Vite SSR Runtime. const mod = (await env.loader.import(fileURLToPath(filePath))) as ComponentInstance; + return [renderers, mod]; } catch (error) { // If the error came from Markdown or CSS, we already handled it and there's no need to enhance it diff --git a/packages/astro/src/core/render/route-cache.ts b/packages/astro/src/core/render/route-cache.ts index 7f5678669c1d0..227928267dae7 100644 --- a/packages/astro/src/core/render/route-cache.ts +++ b/packages/astro/src/core/render/route-cache.ts @@ -31,7 +31,7 @@ export async function callGetStaticPaths({ }: CallGetStaticPathsOptions): Promise { validateDynamicRouteModule(mod, { ssr, logging, route }); // No static paths in SSR mode. Return an empty RouteCacheEntry. - if (ssr && !mod.prerender) { + if (ssr && !route.prerender) { return { staticPaths: Object.assign([], { keyed: new Map() }) }; } // Add a check here to make TypeScript happy. diff --git a/packages/astro/src/core/routing/manifest/create.ts b/packages/astro/src/core/routing/manifest/create.ts index 51f495e8b4681..a673e199ba2f0 100644 --- a/packages/astro/src/core/routing/manifest/create.ts +++ b/packages/astro/src/core/routing/manifest/create.ts @@ -227,7 +227,7 @@ export function createRouteManifest( ]); const validEndpointExtensions: Set = new Set(['.js', '.ts']); const localFs = fsMod ?? nodeFs; - const isPrenderDefault = isHybridOutput(settings.config); + const isPrerenderDefault = isHybridOutput(settings.config); const foundInvalidFileExtensions: Set = new Set(); @@ -340,7 +340,7 @@ export function createRouteManifest( component, generate, pathname: pathname || undefined, - prerender: isPrenderDefault, + prerender: isPrerenderDefault, }); } }); @@ -416,7 +416,7 @@ export function createRouteManifest( component, generate, pathname: pathname || void 0, - prerender: isPrenderDefault, + prerender: isPrerenderDefault, }); }); diff --git a/packages/astro/src/core/routing/validation.ts b/packages/astro/src/core/routing/validation.ts index 911a97a9e4a99..1a3bab82a2eed 100644 --- a/packages/astro/src/core/routing/validation.ts +++ b/packages/astro/src/core/routing/validation.ts @@ -32,14 +32,14 @@ export function validateDynamicRouteModule( route: RouteData; } ) { - if (ssr && mod.getStaticPaths && !mod.prerender) { + if (ssr && mod.getStaticPaths && !route.prerender) { warn( logging, 'getStaticPaths', `getStaticPaths() in ${bold(route.component)} is ignored when "output: server" is set.` ); } - if ((!ssr || mod.prerender) && !mod.getStaticPaths) { + if ((!ssr || route.prerender) && !mod.getStaticPaths) { throw new AstroError({ ...AstroErrorData.GetStaticPathsRequired, location: { file: route.component }, diff --git a/packages/astro/src/prerender/metadata.ts b/packages/astro/src/prerender/metadata.ts new file mode 100644 index 0000000000000..15527af37aaa1 --- /dev/null +++ b/packages/astro/src/prerender/metadata.ts @@ -0,0 +1,22 @@ +import type { ModuleInfo, ModuleLoader } from '../core/module-loader'; +import { viteID } from '../core/util.js'; + +type GetPrerenderStatusParams = { + filePath: URL; + loader: ModuleLoader; +}; + +export function getPrerenderStatus({ + filePath, + loader, +}: GetPrerenderStatusParams): boolean | undefined { + const fileID = viteID(filePath); + const moduleInfo = loader.getModuleInfo(fileID); + if (!moduleInfo) return; + const prerenderStatus = getPrerenderMetadata(moduleInfo); + return prerenderStatus; +} + +export function getPrerenderMetadata(moduleInfo: ModuleInfo) { + return moduleInfo?.meta?.astro?.pageOptions?.prerender; +} diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 259acd2eb95e6..2f6e3259e9b62 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -19,6 +19,7 @@ import { matchAllRoutes } from '../core/routing/index.js'; import { isHybridOutput } from '../prerender/utils.js'; import { log404 } from './common.js'; import { handle404Response, writeSSRResult, writeWebResponse } from './response.js'; +import { getPrerenderStatus } from '../prerender/metadata.js'; type AsyncReturnType Promise> = T extends ( ...args: any @@ -50,6 +51,17 @@ export async function matchRoute( for await (const maybeRoute of matches) { const filePath = new URL(`./${maybeRoute.component}`, settings.config.root); const preloadedComponent = await preload({ env, filePath }); + + // gets the prerender metadata set by the `astro:scanner` vite plugin + const prerenderStatus = getPrerenderStatus({ + filePath, + loader: env.loader, + }); + + if (prerenderStatus !== undefined) { + maybeRoute.prerender = prerenderStatus; + } + const [, mod] = preloadedComponent; // attempt to get static paths // if this fails, we have a bad URL match! diff --git a/packages/astro/test/ssr-prerender-get-static-paths.test.js b/packages/astro/test/ssr-prerender-get-static-paths.test.js index f7100372b6fa0..1a17123041682 100644 --- a/packages/astro/test/ssr-prerender-get-static-paths.test.js +++ b/packages/astro/test/ssr-prerender-get-static-paths.test.js @@ -1,131 +1,291 @@ import { expect } from 'chai'; import { loadFixture } from './test-utils.js'; import * as cheerio from 'cheerio'; +import testAdapter from './test-adapter.js'; -describe('prerender getStaticPaths - build calls', () => { +describe('Prerender', () => { /** @type {import('./test-utils').Fixture} */ let fixture; + describe('output: "server"', () => { + describe('getStaticPaths - build calls', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/ssr-prerender-get-static-paths/', + site: 'https://mysite.dev/', + adapter: testAdapter(), + base: '/blog', + output: 'server', + }); + await fixture.build(); + }); - before(async () => { - fixture = await loadFixture({ - root: './fixtures/ssr-prerender-get-static-paths/', - site: 'https://mysite.dev/', - base: '/blog', + after(async () => { + await fixture.clean(); + }); + + afterEach(() => { + // reset the flag used by [...calledTwiceTest].astro between each test + globalThis.isCalledOnce = false; + }); + + it('is only called once during build', () => { + // useless expect; if build() throws in setup then this test fails + expect(true).to.equal(true); + }); + + it('Astro.url sets the current pathname', async () => { + const html = await fixture.readFile('/client/food/tacos/index.html'); + const $ = cheerio.load(html); + + expect($('#props').text()).to.equal('10'); + expect($('#url').text()).to.equal('/blog/food/tacos/'); + }); }); - await fixture.build(); - }); - afterEach(() => { - // reset the flag used by [...calledTwiceTest].astro between each test - globalThis.isCalledOnce = false; - }); + describe('getStaticPaths - dev calls', () => { + let devServer; - it('is only called once during build', () => { - // useless expect; if build() throws in setup then this test fails - expect(true).to.equal(true); - }); + before(async () => { + globalThis.isCalledOnce = false; + devServer = await fixture.startDevServer(); + }); - it('Astro.url sets the current pathname', async () => { - const html = await fixture.readFile('/food/tacos/index.html'); - const $ = cheerio.load(html); + afterEach(() => { + // reset the flag used by [...calledTwiceTest].astro between each test + globalThis.isCalledOnce = false; + }); - expect($('#props').text()).to.equal('10'); - expect($('#url').text()).to.equal('/blog/food/tacos/'); - }); -}); + after(async () => { + devServer.stop(); + }); -describe('prerender getStaticPaths - dev calls', () => { - let fixture; - let devServer; + it('only calls prerender getStaticPaths once', async () => { + let res = await fixture.fetch('/blog/a'); + expect(res.status).to.equal(200); - before(async () => { - globalThis.isCalledOnce = false; - fixture = await loadFixture({ - root: './fixtures/ssr-prerender-get-static-paths/', - site: 'https://mysite.dev/', - }); - devServer = await fixture.startDevServer(); - }); + res = await fixture.fetch('/blog/b'); + expect(res.status).to.equal(200); - afterEach(() => { - // reset the flag used by [...calledTwiceTest].astro between each test - globalThis.isCalledOnce = false; - }); + res = await fixture.fetch('/blog/c'); + expect(res.status).to.equal(200); + }); - after(async () => { - devServer.stop(); - }); + describe('404 behavior', () => { + it('resolves 200 on matching static path - named params', async () => { + const res = await fixture.fetch('/blog/pizza/provolone-sausage'); + expect(res.status).to.equal(200); + }); - it('only calls prerender getStaticPaths once', async () => { - let res = await fixture.fetch('/a'); - expect(res.status).to.equal(200); + it('resolves 404 on pattern match without static path - named params', async () => { + const res = await fixture.fetch('/blog/pizza/provolone-pineapple'); + const html = await res.text(); + expect(res.status).to.equal(404); + expect(html).to.match(/404/); + }); - res = await fixture.fetch('/b'); - expect(res.status).to.equal(200); + it('resolves 200 on matching static path - rest params', async () => { + const res = await fixture.fetch('/blog/pizza/grimaldis/new-york'); + expect(res.status).to.equal(200); + }); - res = await fixture.fetch('/c'); - expect(res.status).to.equal(200); - }); + it('resolves 404 on pattern match without static path - rest params', async () => { + const res = await fixture.fetch('/blog/pizza/pizza-hut'); + const html = await res.text(); - describe('404 behavior', () => { - it('resolves 200 on matching static path - named params', async () => { - const res = await fixture.fetch('/pizza/provolone-sausage'); - expect(res.status).to.equal(200); - }); + expect(res.status).to.equal(404); + expect(html).to.match(/404/); + }); + }); - it('resolves 404 on pattern match without static path - named params', async () => { - const res = await fixture.fetch('/pizza/provolone-pineapple'); - const html = await res.text(); - expect(res.status).to.equal(404); - expect(html).to.match(/404/); - }); + describe('route params type validation', () => { + it('resolves 200 on nested array parameters', async () => { + const res = await fixture.fetch('/blog/nested-arrays/slug1'); + expect(res.status).to.equal(200); + }); - it('resolves 200 on matching static path - rest params', async () => { - const res = await fixture.fetch('/pizza/grimaldis/new-york'); - expect(res.status).to.equal(200); - }); + it('resolves 200 on matching static path - string params', async () => { + // route provided with { params: { year: "2022", slug: "post-2" }} + const res = await fixture.fetch('/blog/blog/2022/post-1'); + expect(res.status).to.equal(200); + }); - it('resolves 404 on pattern match without static path - rest params', async () => { - const res = await fixture.fetch('/pizza/pizza-hut'); - const html = await res.text(); - expect(res.status).to.equal(404); - expect(html).to.match(/404/); + it('resolves 200 on matching static path - numeric params', async () => { + // route provided with { params: { year: 2022, slug: "post-2" }} + const res = await fixture.fetch('/blog/blog/2022/post-2'); + expect(res.status).to.equal(200); + }); + }); + + it('resolves 200 on matching static paths', async () => { + // routes params provided for pages /posts/1, /posts/2, and /posts/3 + for (const page of [1, 2, 3]) { + let res = await fixture.fetch(`/blog/posts/${page}`); + expect(res.status).to.equal(200); + + const html = await res.text(); + const $ = cheerio.load(html); + + const canonical = $('link[rel=canonical]'); + expect(canonical.attr('href')).to.equal( + `https://mysite.dev/blog/posts/${page}`, + `doesn't trim the /${page} route param` + ); + } + }); }); }); - describe('route params type validation', () => { - it('resolves 200 on nested array parameters', async () => { - const res = await fixture.fetch('/nested-arrays/slug1'); - expect(res.status).to.equal(200); - }); + describe('output: "hybrid"', () => { + describe('getStaticPaths - build calls', () => { + before(async () => { + fixture = await loadFixture({ + root: './fixtures/ssr-prerender-get-static-paths/', + site: 'https://mysite.dev/', + adapter: testAdapter(), + base: '/blog', + output: 'hybrid', + experimental: { + hybridOutput: true, + }, + vite: { + plugins: [vitePluginRemovePrerenderExport()], + }, + }); + await fixture.build(); + }); - it('resolves 200 on matching static path - string params', async () => { - // route provided with { params: { year: "2022", slug: "post-2" }} - const res = await fixture.fetch('/blog/2022/post-1'); - expect(res.status).to.equal(200); - }); + after(async () => { + await fixture.clean(); + }); - it('resolves 200 on matching static path - numeric params', async () => { - // route provided with { params: { year: 2022, slug: "post-2" }} - const res = await fixture.fetch('/blog/2022/post-2'); - expect(res.status).to.equal(200); + afterEach(() => { + // reset the flag used by [...calledTwiceTest].astro between each test + globalThis.isCalledOnce = false; + }); + + it('is only called once during build', () => { + // useless expect; if build() throws in setup then this test fails + expect(true).to.equal(true); + }); + + it('Astro.url sets the current pathname', async () => { + const html = await fixture.readFile('/client/food/tacos/index.html'); + const $ = cheerio.load(html); + + expect($('#props').text()).to.equal('10'); + expect($('#url').text()).to.equal('/blog/food/tacos/'); + }); }); - }); - it('resolves 200 on matching static paths', async () => { - // routes params provided for pages /posts/1, /posts/2, and /posts/3 - for (const page of [1, 2, 3]) { - let res = await fixture.fetch(`/posts/${page}`); - expect(res.status).to.equal(200); - - const html = await res.text(); - const $ = cheerio.load(html); - - const canonical = $('link[rel=canonical]'); - expect(canonical.attr('href')).to.equal( - `https://mysite.dev/posts/${page}`, - `doesn't trim the /${page} route param` - ); - } + describe('getStaticPaths - dev calls', () => { + let devServer; + + before(async () => { + globalThis.isCalledOnce = false; + devServer = await fixture.startDevServer(); + }); + + afterEach(() => { + // reset the flag used by [...calledTwiceTest].astro between each test + globalThis.isCalledOnce = false; + }); + + after(async () => { + devServer.stop(); + }); + + it('only calls hybrid getStaticPaths once', async () => { + let res = await fixture.fetch('/blog/a'); + expect(res.status).to.equal(200); + + res = await fixture.fetch('/blog/b'); + expect(res.status).to.equal(200); + + res = await fixture.fetch('/blog/c'); + expect(res.status).to.equal(200); + }); + + describe('404 behavior', () => { + it('resolves 200 on matching static path - named params', async () => { + const res = await fixture.fetch('/blog/pizza/provolone-sausage'); + expect(res.status).to.equal(200); + }); + + it('resolves 404 on pattern match without static path - named params', async () => { + const res = await fixture.fetch('/blog/pizza/provolone-pineapple'); + const html = await res.text(); + expect(res.status).to.equal(404); + expect(html).to.match(/404/); + }); + + it('resolves 200 on matching static path - rest params', async () => { + const res = await fixture.fetch('/blog/pizza/grimaldis/new-york'); + expect(res.status).to.equal(200); + }); + + it('resolves 404 on pattern match without static path - rest params', async () => { + const res = await fixture.fetch('/blog/pizza/pizza-hut'); + const html = await res.text(); + + expect(res.status).to.equal(404); + expect(html).to.match(/404/); + }); + }); + + describe('route params type validation', () => { + it('resolves 200 on nested array parameters', async () => { + const res = await fixture.fetch('/blog/nested-arrays/slug1'); + expect(res.status).to.equal(200); + }); + + it('resolves 200 on matching static path - string params', async () => { + // route provided with { params: { year: "2022", slug: "post-2" }} + const res = await fixture.fetch('/blog/blog/2022/post-1'); + expect(res.status).to.equal(200); + }); + + it('resolves 200 on matching static path - numeric params', async () => { + // route provided with { params: { year: 2022, slug: "post-2" }} + const res = await fixture.fetch('/blog/blog/2022/post-2'); + expect(res.status).to.equal(200); + }); + }); + + it('resolves 200 on matching static paths', async () => { + // routes params provided for pages /posts/1, /posts/2, and /posts/3 + for (const page of [1, 2, 3]) { + let res = await fixture.fetch(`/blog/posts/${page}`); + expect(res.status).to.equal(200); + + const html = await res.text(); + const $ = cheerio.load(html); + + const canonical = $('link[rel=canonical]'); + expect(canonical.attr('href')).to.equal( + `https://mysite.dev/blog/posts/${page}`, + `doesn't trim the /${page} route param` + ); + } + }); + }); }); }); + +/** @returns {import('vite').Plugin} */ +function vitePluginRemovePrerenderExport() { + const EXTENSIONS = ['.astro', '.ts']; + /** @type {import('vite').Plugin} */ + const plugin = { + name: 'remove-prerender-export', + transform(code, id) { + if (!EXTENSIONS.some((ext) => id.endsWith(ext))) return; + return code.replace(/export\s+const\s+prerender\s+=\s+true;/g, ''); + }, + }; + return { + name: 'remove-prerender-export-injector', + configResolved(resolved) { + resolved.plugins.unshift(plugin); + }, + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d75e43cba08bb..20ca7bcb57b4e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5756,7 +5756,7 @@ packages: resolution: {integrity: sha512-kkH7sWzKPq0xt3H1n+ghb4xEMP8k0U7XV3kkB+ZGy69kDk2ySFW1qPi06sjKzFY3t1j6XbJSqr4mF9L7CYVyhg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.4 + '@babel/types': 7.21.5 dev: false /@babel/helper-module-imports@7.21.4: @@ -5850,7 +5850,6 @@ packages: /@babel/helper-string-parser@7.21.5: resolution: {integrity: sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==} engines: {node: '>=6.9.0'} - dev: false /@babel/helper-validator-identifier@7.19.1: resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} @@ -5904,8 +5903,7 @@ packages: engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.18.4 - dev: false + '@babel/types': 7.21.5 /@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.18.6(@babel/core@7.18.2): resolution: {integrity: sha512-Dgxsyg54Fx1d4Nge8UnvTrED63vrwOdPmyvPzlNN/boaliRP54pm3pGzZD1SJUwrBA+Cs/xdG8kXX6Mn/RfISQ==} @@ -6993,7 +6991,7 @@ packages: '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-proposal-unicode-property-regex': 7.18.6(@babel/core@7.18.2) '@babel/plugin-transform-dotall-regex': 7.18.6(@babel/core@7.18.2) - '@babel/types': 7.18.4 + '@babel/types': 7.21.5 esutils: 2.0.3 dev: false @@ -7066,7 +7064,6 @@ packages: '@babel/helper-string-parser': 7.21.5 '@babel/helper-validator-identifier': 7.19.1 to-fast-properties: 2.0.0 - dev: false /@builder.io/partytown@0.7.4: resolution: {integrity: sha512-dcZBPNQiHbMhvDGmdWRFNe75Z/XYmeZ2bubYmC5BeQpF09ObbPcbSqIP2NaNOFonKlWLfsE6u1790o9ZmlfpIw==} @@ -8717,7 +8714,7 @@ packages: /@ts-morph/common@0.16.0: resolution: {integrity: sha512-SgJpzkTgZKLKqQniCjLaE3c2L2sdL7UShvmTmPBejAKd2OKV/yfMpQ2IWpAuA+VY5wy7PkSUaEObIqEK6afFuw==} dependencies: - fast-glob: 3.2.11 + fast-glob: 3.2.12 minimatch: 5.1.6 mkdirp: 1.0.4 path-browserify: 1.0.1 @@ -9419,7 +9416,7 @@ packages: /@vue/compiler-core@3.2.47: resolution: {integrity: sha512-p4D7FDnQb7+YJmO2iPEv0SQNeNzcbHdGByJDsT4lynf63AFkOTFN07HsiRSvjGo0QrxR/o3d0hUyNCUnBU2Tig==} dependencies: - '@babel/parser': 7.18.4 + '@babel/parser': 7.21.8 '@vue/shared': 3.2.47 estree-walker: 2.0.2 source-map: 0.6.1 @@ -9492,7 +9489,7 @@ packages: /@vue/reactivity-transform@3.2.47: resolution: {integrity: sha512-m8lGXw8rdnPVVIdIFhf0LeQ/ixyHkH5plYuS83yop5n7ggVJU+z5v0zecwEnX7fa7HNLBhh2qngJJkxpwEEmYA==} dependencies: - '@babel/parser': 7.18.4 + '@babel/parser': 7.21.8 '@vue/compiler-core': 3.2.47 '@vue/shared': 3.2.47 estree-walker: 2.0.2 @@ -10124,7 +10121,7 @@ packages: /builtins@5.0.1: resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} dependencies: - semver: 7.3.8 + semver: 7.5.1 dev: true /bundle-name@3.0.0: @@ -14531,7 +14528,7 @@ packages: resolution: {integrity: sha512-zNy02qivjjRosswoYmPi8hIKJRr8MpQyeKT6qlcq/OnOgA3Rhoae+IYOqsM9V5+JnHWmxKnWOT2GxvtqdtOCXA==} engines: {node: '>=10'} dependencies: - semver: 7.3.8 + semver: 7.5.1 /node-addon-api@6.1.0: resolution: {integrity: sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==} @@ -14665,7 +14662,7 @@ packages: dependencies: execa: 6.1.0 parse-package-name: 1.0.0 - semver: 7.3.8 + semver: 7.5.1 validate-npm-package-name: 4.0.0 dev: true From 49bfeacdeca4b32b1532dea4a63e5332d7d3729c Mon Sep 17 00:00:00 2001 From: MoustaphaDev Date: Mon, 22 May 2023 13:00:23 +0000 Subject: [PATCH 3/7] [ci] format --- packages/astro/src/core/build/plugins/plugin-prerender.ts | 2 +- packages/astro/src/vite-plugin-astro-server/route.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/astro/src/core/build/plugins/plugin-prerender.ts b/packages/astro/src/core/build/plugins/plugin-prerender.ts index b950a83ea5ac4..a0d6a9c7bf6dc 100644 --- a/packages/astro/src/core/build/plugins/plugin-prerender.ts +++ b/packages/astro/src/core/build/plugins/plugin-prerender.ts @@ -1,10 +1,10 @@ import path from 'node:path'; import type { Plugin as VitePlugin } from 'vite'; +import { getPrerenderMetadata } from '../../../prerender/metadata.js'; import type { BuildInternals } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; import type { StaticBuildOptions } from '../types'; import { extendManualChunks } from './util.js'; -import { getPrerenderMetadata } from '../../../prerender/metadata.js'; function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals): VitePlugin { return { diff --git a/packages/astro/src/vite-plugin-astro-server/route.ts b/packages/astro/src/vite-plugin-astro-server/route.ts index 2f6e3259e9b62..86b8e5814e463 100644 --- a/packages/astro/src/vite-plugin-astro-server/route.ts +++ b/packages/astro/src/vite-plugin-astro-server/route.ts @@ -16,10 +16,10 @@ import { preload, renderPage } from '../core/render/dev/index.js'; import { getParamsAndProps, GetParamsAndPropsError } from '../core/render/index.js'; import { createRequest } from '../core/request.js'; import { matchAllRoutes } from '../core/routing/index.js'; +import { getPrerenderStatus } from '../prerender/metadata.js'; import { isHybridOutput } from '../prerender/utils.js'; import { log404 } from './common.js'; import { handle404Response, writeSSRResult, writeWebResponse } from './response.js'; -import { getPrerenderStatus } from '../prerender/metadata.js'; type AsyncReturnType Promise> = T extends ( ...args: any From ba0636240996f9f082d122a8414240196881cb96 Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Mon, 22 May 2023 18:45:21 +0530 Subject: [PATCH 4/7] fix(hoisted scripts): consider script's dependents (#7144) --- .changeset/perfect-oranges-tease.md | 5 ++ .../build/plugins/plugin-hoisted-scripts.ts | 69 +++++++++++-------- 2 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 .changeset/perfect-oranges-tease.md diff --git a/.changeset/perfect-oranges-tease.md b/.changeset/perfect-oranges-tease.md new file mode 100644 index 0000000000000..a5aca06f4205d --- /dev/null +++ b/.changeset/perfect-oranges-tease.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed an issue where scripts that weren't safe to inline were inlined. diff --git a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts index 38d8323848da5..4c9b48597882d 100644 --- a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts +++ b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts @@ -4,7 +4,7 @@ import { viteID } from '../../util.js'; import type { BuildInternals } from '../internal.js'; import { getPageDataByViteID } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin'; -import type { StaticBuildOptions } from '../types'; +import type { OutputChunk, StaticBuildOptions } from '../types'; function virtualHoistedEntry(id: string) { return id.startsWith('/astro/hoisted.js?q='); @@ -50,46 +50,55 @@ export function vitePluginHoistedScripts( assetInlineLimit = settings.config.vite?.build.assetsInlineLimit; } + const considerInlining = new Map(); + const importedByOtherScripts = new Set(); + // Find all page entry points and create a map of the entry point to the hashed hoisted script. // This is used when we render so that we can add the script to the head. - for (const [id, output] of Object.entries(bundle)) { + Object.entries(bundle).forEach(([ id, output ]) => { if ( output.type === 'chunk' && output.facadeModuleId && virtualHoistedEntry(output.facadeModuleId) ) { - const canBeInlined = - output.imports.length === 0 && - output.dynamicImports.length === 0 && - Buffer.byteLength(output.code) <= assetInlineLimit; - let removeFromBundle = false; - const facadeId = output.facadeModuleId!; - const pages = internals.hoistedScriptIdToPagesMap.get(facadeId)!; - for (const pathname of pages) { - const vid = viteID(new URL('.' + pathname, settings.config.root)); - const pageInfo = getPageDataByViteID(internals, vid); - if (pageInfo) { - if (canBeInlined) { - pageInfo.hoistedScript = { - type: 'inline', - value: output.code, - }; - removeFromBundle = true; - } else { - pageInfo.hoistedScript = { - type: 'external', - value: id, - }; - } + considerInlining.set(id, output); + output.imports.forEach(imported => importedByOtherScripts.add(imported)); + } + }); + + for (const [ id, output ] of considerInlining.entries()) { + const canBeInlined = + importedByOtherScripts.has(output.fileName) === false && + output.imports.length === 0 && + output.dynamicImports.length === 0 && + Buffer.byteLength(output.code) <= assetInlineLimit; + let removeFromBundle = false; + const facadeId = output.facadeModuleId!; + const pages = internals.hoistedScriptIdToPagesMap.get(facadeId)!; + for (const pathname of pages) { + const vid = viteID(new URL('.' + pathname, settings.config.root)); + const pageInfo = getPageDataByViteID(internals, vid); + if (pageInfo) { + if (canBeInlined) { + pageInfo.hoistedScript = { + type: 'inline', + value: output.code, + }; + removeFromBundle = true; + } else { + pageInfo.hoistedScript = { + type: 'external', + value: id, + }; } } + } - // Remove the bundle if it was inlined - if (removeFromBundle) { - delete bundle[id]; - } + // Remove the bundle if it was inlined + if (removeFromBundle) { + delete bundle[id]; } - } + }; }, }; } From f962348f76cde9a854359777b2d34c8e23206f67 Mon Sep 17 00:00:00 2001 From: matthewp Date: Mon, 22 May 2023 13:18:18 +0000 Subject: [PATCH 5/7] [ci] format --- .../src/core/build/plugins/plugin-hoisted-scripts.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts index 4c9b48597882d..d31e42807c038 100644 --- a/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts +++ b/packages/astro/src/core/build/plugins/plugin-hoisted-scripts.ts @@ -55,18 +55,18 @@ export function vitePluginHoistedScripts( // Find all page entry points and create a map of the entry point to the hashed hoisted script. // This is used when we render so that we can add the script to the head. - Object.entries(bundle).forEach(([ id, output ]) => { + Object.entries(bundle).forEach(([id, output]) => { if ( output.type === 'chunk' && output.facadeModuleId && virtualHoistedEntry(output.facadeModuleId) ) { considerInlining.set(id, output); - output.imports.forEach(imported => importedByOtherScripts.add(imported)); + output.imports.forEach((imported) => importedByOtherScripts.add(imported)); } }); - for (const [ id, output ] of considerInlining.entries()) { + for (const [id, output] of considerInlining.entries()) { const canBeInlined = importedByOtherScripts.has(output.fileName) === false && output.imports.length === 0 && @@ -98,7 +98,7 @@ export function vitePluginHoistedScripts( if (removeFromBundle) { delete bundle[id]; } - }; + } }, }; } From e17ed0727ef1acb512c77723a1b641326de8ca84 Mon Sep 17 00:00:00 2001 From: Akash Rajpurohit Date: Mon, 22 May 2023 18:50:10 +0530 Subject: [PATCH 6/7] feat: :art: export rss feeditem type (#7153) --- .changeset/lemon-flies-smoke.md | 5 +++++ packages/astro-rss/src/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/lemon-flies-smoke.md diff --git a/.changeset/lemon-flies-smoke.md b/.changeset/lemon-flies-smoke.md new file mode 100644 index 0000000000000..9755e27af0b20 --- /dev/null +++ b/.changeset/lemon-flies-smoke.md @@ -0,0 +1,5 @@ +--- +'@astrojs/rss': patch +--- + +exposes RSSFeedItem type diff --git a/packages/astro-rss/src/index.ts b/packages/astro-rss/src/index.ts index 2a35bd573c5fe..47c7c1db42b3b 100644 --- a/packages/astro-rss/src/index.ts +++ b/packages/astro-rss/src/index.ts @@ -32,7 +32,7 @@ export type RSSOptions = { trailingSlash?: z.infer['trailingSlash']; }; -type RSSFeedItem = { +export type RSSFeedItem = { /** Link to item */ link: string; /** Full content of the item. Should be valid HTML */ From d880293f7949385693fbd627a96bdfc9e9478def Mon Sep 17 00:00:00 2001 From: "Houston (Bot)" <108291165+astrobot-houston@users.noreply.github.com> Date: Mon, 22 May 2023 06:48:21 -0700 Subject: [PATCH 7/7] [ci] release (#7161) Co-authored-by: github-actions[bot] --- .changeset/lemon-flies-smoke.md | 5 ----- .changeset/perfect-oranges-tease.md | 5 ----- .changeset/strange-ties-cry.md | 5 ----- packages/astro-rss/CHANGELOG.md | 6 ++++++ packages/astro-rss/package.json | 2 +- packages/astro/CHANGELOG.md | 8 ++++++++ packages/astro/package.json | 2 +- packages/integrations/cloudflare/package.json | 2 +- packages/integrations/deno/package.json | 2 +- packages/integrations/image/package.json | 2 +- packages/integrations/markdoc/package.json | 2 +- packages/integrations/netlify/package.json | 2 +- packages/integrations/node/package.json | 2 +- packages/integrations/svelte/package.json | 2 +- packages/integrations/tailwind/package.json | 2 +- packages/integrations/vercel/package.json | 2 +- packages/integrations/vue/package.json | 2 +- 17 files changed, 26 insertions(+), 27 deletions(-) delete mode 100644 .changeset/lemon-flies-smoke.md delete mode 100644 .changeset/perfect-oranges-tease.md delete mode 100644 .changeset/strange-ties-cry.md diff --git a/.changeset/lemon-flies-smoke.md b/.changeset/lemon-flies-smoke.md deleted file mode 100644 index 9755e27af0b20..0000000000000 --- a/.changeset/lemon-flies-smoke.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@astrojs/rss': patch ---- - -exposes RSSFeedItem type diff --git a/.changeset/perfect-oranges-tease.md b/.changeset/perfect-oranges-tease.md deleted file mode 100644 index a5aca06f4205d..0000000000000 --- a/.changeset/perfect-oranges-tease.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -Fixed an issue where scripts that weren't safe to inline were inlined. diff --git a/.changeset/strange-ties-cry.md b/.changeset/strange-ties-cry.md deleted file mode 100644 index 0c6139cfcba73..0000000000000 --- a/.changeset/strange-ties-cry.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'astro': patch ---- - -fix no matched path when using `getStaticPaths` without `prerender` export. diff --git a/packages/astro-rss/CHANGELOG.md b/packages/astro-rss/CHANGELOG.md index cd17b4fa9f633..d2120b6282092 100644 --- a/packages/astro-rss/CHANGELOG.md +++ b/packages/astro-rss/CHANGELOG.md @@ -1,5 +1,11 @@ # @astrojs/rss +## 2.4.3 + +### Patch Changes + +- [#7153](https://github.com/withastro/astro/pull/7153) [`e17ed0727`](https://github.com/withastro/astro/commit/e17ed0727ef1acb512c77723a1b641326de8ca84) Thanks [@AkashRajpurohit](https://github.com/AkashRajpurohit)! - exposes RSSFeedItem type + ## 2.4.2 ### Patch Changes diff --git a/packages/astro-rss/package.json b/packages/astro-rss/package.json index a6f65ae67009f..e9a97157c316a 100644 --- a/packages/astro-rss/package.json +++ b/packages/astro-rss/package.json @@ -1,7 +1,7 @@ { "name": "@astrojs/rss", "description": "Add RSS feeds to your Astro projects", - "version": "2.4.2", + "version": "2.4.3", "type": "module", "types": "./dist/index.d.ts", "author": "withastro", diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index df863fc9459ea..7c16de997f958 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,13 @@ # astro +## 2.5.2 + +### Patch Changes + +- [#7144](https://github.com/withastro/astro/pull/7144) [`ba0636240`](https://github.com/withastro/astro/commit/ba0636240996f9f082d122a8414240196881cb96) Thanks [@lilnasy](https://github.com/lilnasy)! - Fixed an issue where scripts that weren't safe to inline were inlined. + +- [#7150](https://github.com/withastro/astro/pull/7150) [`8f418d13c`](https://github.com/withastro/astro/commit/8f418d13c5d5c9c40f05020205f24380b718654b) Thanks [@MoustaphaDev](https://github.com/MoustaphaDev)! - fix no matched path when using `getStaticPaths` without `prerender` export. + ## 2.5.1 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index ddfa988c4709b..a29ee4eb8f48d 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "2.5.1", + "version": "2.5.2", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", diff --git a/packages/integrations/cloudflare/package.json b/packages/integrations/cloudflare/package.json index 6a0081fe9b901..29b58521b31b9 100644 --- a/packages/integrations/cloudflare/package.json +++ b/packages/integrations/cloudflare/package.json @@ -42,7 +42,7 @@ "tiny-glob": "^0.2.9" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/deno/package.json b/packages/integrations/deno/package.json index e58e3549141c7..6d4aafd495cdb 100644 --- a/packages/integrations/deno/package.json +++ b/packages/integrations/deno/package.json @@ -36,7 +36,7 @@ "esbuild": "^0.15.18" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/image/package.json b/packages/integrations/image/package.json index f3cd9f772abe9..4768f65919ea8 100644 --- a/packages/integrations/image/package.json +++ b/packages/integrations/image/package.json @@ -62,7 +62,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.1", + "astro": "workspace:^2.5.2", "sharp": ">=0.31.0" }, "peerDependenciesMeta": { diff --git a/packages/integrations/markdoc/package.json b/packages/integrations/markdoc/package.json index e67ff83e0458d..4bdc84deb9bfc 100644 --- a/packages/integrations/markdoc/package.json +++ b/packages/integrations/markdoc/package.json @@ -47,7 +47,7 @@ "zod": "^3.17.3" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "@astrojs/markdown-remark": "^2.2.1", diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index 09dc06567b168..1c2fe497c1db8 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -42,7 +42,7 @@ "esbuild": "^0.15.18" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "@netlify/edge-functions": "^2.0.0", diff --git a/packages/integrations/node/package.json b/packages/integrations/node/package.json index 980614b158592..b045a3601a9ed 100644 --- a/packages/integrations/node/package.json +++ b/packages/integrations/node/package.json @@ -38,7 +38,7 @@ "server-destroy": "^1.0.1" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "@types/send": "^0.17.1", diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index bb3b0e7c35b33..1d012a4acee14 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -48,7 +48,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.1", + "astro": "workspace:^2.5.2", "svelte": "^3.54.0" }, "engines": { diff --git a/packages/integrations/tailwind/package.json b/packages/integrations/tailwind/package.json index 236e42bd5af87..86e690a025e69 100644 --- a/packages/integrations/tailwind/package.json +++ b/packages/integrations/tailwind/package.json @@ -44,7 +44,7 @@ "vite": "^4.3.1" }, "peerDependencies": { - "astro": "workspace:^2.5.1", + "astro": "workspace:^2.5.2", "tailwindcss": "^3.0.24" }, "pnpm": { diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index eab3cd41fb2ae..4e04c67a8195d 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -59,7 +59,7 @@ "web-vitals": "^3.1.1" }, "peerDependencies": { - "astro": "workspace:^2.5.1" + "astro": "workspace:^2.5.2" }, "devDependencies": { "@types/set-cookie-parser": "^2.4.2", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index 3c226be405c55..e422ff82aed56 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -56,7 +56,7 @@ "vue": "^3.2.37" }, "peerDependencies": { - "astro": "workspace:^2.5.1", + "astro": "workspace:^2.5.2", "vue": "^3.2.30" }, "engines": {