diff --git a/crates/next-api/src/dynamic_imports.rs b/crates/next-api/src/dynamic_imports.rs index e49283bfc4a8b..72c1d3d8bdaae 100644 --- a/crates/next-api/src/dynamic_imports.rs +++ b/crates/next-api/src/dynamic_imports.rs @@ -56,8 +56,8 @@ where // [Note]: this seems to create duplicated chunks for the same module to the original import() call // and the explicit chunk we ask in here. So there'll be at least 2 // chunks for the same module, relying on - // naive hash to have additonal - // chunks in case if there are same modules being imported in differnt + // naive hash to have additional + // chunks in case if there are same modules being imported in different // origins. let chunk_group = build_chunk(module).await?; chunks_hash.insert(imported_raw_str.clone(), chunk_group); diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index ffefaefb20022..1ab87a3d46d90 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -792,7 +792,7 @@ impl NextConfig { #[turbo_tasks::function] pub async fn env(self: Vc) -> Result> { // The value expected for env is Record, but config itself - // allows arbitary object (https://github.com/vercel/next.js/blob/25ba8a74b7544dfb6b30d1b67c47b9cb5360cb4e/packages/next/src/server/config-schema.ts#L203) + // allows arbitrary object (https://github.com/vercel/next.js/blob/25ba8a74b7544dfb6b30d1b67c47b9cb5360cb4e/packages/next/src/server/config-schema.ts#L203) // then stringifies it. We do the interop here as well. let env = self .await? diff --git a/crates/next-custom-transforms/src/transforms/server_actions.rs b/crates/next-custom-transforms/src/transforms/server_actions.rs index 63a0f919bfa5c..2505247c12a30 100644 --- a/crates/next-custom-transforms/src/transforms/server_actions.rs +++ b/crates/next-custom-transforms/src/transforms/server_actions.rs @@ -761,7 +761,7 @@ impl VisitMut for ServerActions { if self.in_action_file { let mut disallowed_export_span = DUMMY_SP; - // Currrently only function exports are allowed. + // Currently only function exports are allowed. match &mut stmt { ModuleItem::ModuleDecl(ModuleDecl::ExportDecl(ExportDecl { decl, span })) => { match decl { diff --git a/examples/cms-sanity/app/(blog)/layout.tsx b/examples/cms-sanity/app/(blog)/layout.tsx index 7d934be6368c7..6a23f51370b07 100644 --- a/examples/cms-sanity/app/(blog)/layout.tsx +++ b/examples/cms-sanity/app/(blog)/layout.tsx @@ -14,14 +14,13 @@ import { Suspense } from "react"; import AlertBanner from "./alert-banner"; import PortableText from "./portable-text"; -import type { SettingsQueryResult } from "@/sanity.types"; import * as demo from "@/sanity/lib/demo"; import { sanityFetch } from "@/sanity/lib/fetch"; import { settingsQuery } from "@/sanity/lib/queries"; import { resolveOpenGraphImage } from "@/sanity/lib/utils"; export async function generateMetadata(): Promise { - const settings = await sanityFetch({ + const settings = await sanityFetch({ query: settingsQuery, // Metadata should never contain stega stega: false, @@ -58,9 +57,7 @@ const inter = Inter({ }); async function Footer() { - const data = await sanityFetch({ - query: settingsQuery, - }); + const data = await sanityFetch({ query: settingsQuery }); const footer = data?.footer || []; return ( diff --git a/examples/cms-sanity/app/(blog)/more-stories.tsx b/examples/cms-sanity/app/(blog)/more-stories.tsx index eda89220fa501..ea7a993ae42fd 100644 --- a/examples/cms-sanity/app/(blog)/more-stories.tsx +++ b/examples/cms-sanity/app/(blog)/more-stories.tsx @@ -4,7 +4,6 @@ import Avatar from "./avatar"; import CoverImage from "./cover-image"; import DateComponent from "./date"; -import type { MoreStoriesQueryResult } from "@/sanity.types"; import { sanityFetch } from "@/sanity/lib/fetch"; import { moreStoriesQuery } from "@/sanity/lib/queries"; @@ -12,10 +11,7 @@ export default async function MoreStories(params: { skip: string; limit: number; }) { - const data = await sanityFetch({ - query: moreStoriesQuery, - params, - }); + const data = await sanityFetch({ query: moreStoriesQuery, params }); return ( <> diff --git a/examples/cms-sanity/app/(blog)/posts/[slug]/page.tsx b/examples/cms-sanity/app/(blog)/posts/[slug]/page.tsx index 452f0447ccc86..397fb23e78dc0 100644 --- a/examples/cms-sanity/app/(blog)/posts/[slug]/page.tsx +++ b/examples/cms-sanity/app/(blog)/posts/[slug]/page.tsx @@ -1,5 +1,6 @@ +import { defineQuery } from "groq"; import type { Metadata, ResolvingMetadata } from "next"; -import { groq, type PortableTextBlock } from "next-sanity"; +import { type PortableTextBlock } from "next-sanity"; import Link from "next/link"; import { notFound } from "next/navigation"; import { Suspense } from "react"; @@ -10,11 +11,6 @@ import DateComponent from "../../date"; import MoreStories from "../../more-stories"; import PortableText from "../../portable-text"; -import type { - PostQueryResult, - PostSlugsResult, - SettingsQueryResult, -} from "@/sanity.types"; import * as demo from "@/sanity/lib/demo"; import { sanityFetch } from "@/sanity/lib/fetch"; import { postQuery, settingsQuery } from "@/sanity/lib/queries"; @@ -24,26 +20,23 @@ type Props = { params: { slug: string }; }; -const postSlugs = groq`*[_type == "post"]{slug}`; +const postSlugs = defineQuery( + `*[_type == "post" && defined(slug.current)]{"slug": slug.current}`, +); export async function generateStaticParams() { - const params = await sanityFetch({ + return await sanityFetch({ query: postSlugs, perspective: "published", stega: false, }); - return params.map(({ slug }) => ({ slug: slug?.current })); } export async function generateMetadata( { params }: Props, parent: ResolvingMetadata, ): Promise { - const post = await sanityFetch({ - query: postQuery, - params, - stega: false, - }); + const post = await sanityFetch({ query: postQuery, params, stega: false }); const previousImages = (await parent).openGraph?.images || []; const ogImage = resolveOpenGraphImage(post?.coverImage); @@ -59,13 +52,8 @@ export async function generateMetadata( export default async function PostPage({ params }: Props) { const [post, settings] = await Promise.all([ - sanityFetch({ - query: postQuery, - params, - }), - sanityFetch({ - query: settingsQuery, - }), + sanityFetch({ query: postQuery, params }), + sanityFetch({ query: settingsQuery }), ]); if (!post?._id) { diff --git a/examples/cms-sanity/package.json b/examples/cms-sanity/package.json index 4c428e8d241b5..15e03ccf69628 100644 --- a/examples/cms-sanity/package.json +++ b/examples/cms-sanity/package.json @@ -16,21 +16,22 @@ "@sanity/assist": "^3.0.5", "@sanity/icons": "^3.3.1", "@sanity/image-url": "^1.0.2", - "@sanity/preview-url-secret": "^1.6.18", - "@sanity/vision": "^3.52.4", + "@sanity/preview-url-secret": "^1.6.19", + "@sanity/vision": "^3.53.0", "@tailwindcss/typography": "^0.5.13", "@types/node": "^20.14.13", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@vercel/speed-insights": "^1.0.12", - "autoprefixer": "^10.4.19", + "autoprefixer": "^10.4.20", "date-fns": "^3.6.0", + "groq": "^3.53.0", "next": "^14.2.5", "next-sanity": "^9.4.3", - "postcss": "^8.4.40", + "postcss": "^8.4.41", "react": "^18.3.1", "react-dom": "^18.3.1", - "sanity": "^3.52.4", + "sanity": "^3.53.0", "sanity-plugin-asset-source-unsplash": "^3.0.1", "server-only": "^0.0.1", "styled-components": "^6.1.12", diff --git a/examples/cms-sanity/sanity-typegen.json b/examples/cms-sanity/sanity-typegen.json new file mode 100644 index 0000000000000..f178d69539f71 --- /dev/null +++ b/examples/cms-sanity/sanity-typegen.json @@ -0,0 +1 @@ +{ "overloadClientMethods": true } diff --git a/examples/cms-sanity/sanity.types.ts b/examples/cms-sanity/sanity.types.ts index 16bfd1b900f48..c27f9d02eb9ac 100644 --- a/examples/cms-sanity/sanity.types.ts +++ b/examples/cms-sanity/sanity.types.ts @@ -482,7 +482,7 @@ export type SettingsQueryResult = { }; } | null; // Variable: heroQuery -// Query: *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},} +// Query: *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture}, } export type HeroQueryResult = { content: Array<{ children?: Array<{ @@ -537,7 +537,7 @@ export type HeroQueryResult = { } | null; } | null; // Variable: moreStoriesQuery -// Query: *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},} +// Query: *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture}, } export type MoreStoriesQueryResult = Array<{ _id: string; status: "draft" | "published"; @@ -574,7 +574,7 @@ export type MoreStoriesQueryResult = Array<{ } | null; }>; // Variable: postQuery -// Query: *[_type == "post" && slug.current == $slug] [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture},} +// Query: *[_type == "post" && slug.current == $slug] [0] { content, _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{"name": coalesce(name, "Anonymous"), picture}, } export type PostQueryResult = { content: Array<{ children?: Array<{ @@ -628,9 +628,23 @@ export type PostQueryResult = { } | null; } | null; } | null; -// Source: ./app/(blog)/posts/[slug]/page.tsx +import "@sanity/client"; +declare module "@sanity/client" { + interface SanityQueries { + '*[_type == "settings"][0]': SettingsQueryResult; + '\n *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] {\n content,\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{"name": coalesce(name, "Anonymous"), picture},\n\n }\n': HeroQueryResult; + '\n *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{"name": coalesce(name, "Anonymous"), picture},\n\n }\n': MoreStoriesQueryResult; + '\n *[_type == "post" && slug.current == $slug] [0] {\n content,\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{"name": coalesce(name, "Anonymous"), picture},\n\n }\n': PostQueryResult; + } +} // Source: ./app/(blog)/posts/[slug]/page.tsx // Variable: postSlugs -// Query: *[_type == "post"]{slug} +// Query: *[_type == "post" && defined(slug.current)]{"slug": slug.current} export type PostSlugsResult = Array<{ - slug: Slug | null; + slug: string | null; }>; +import "@sanity/client"; +declare module "@sanity/client" { + interface SanityQueries { + '*[_type == "post" && defined(slug.current)]{"slug": slug.current}': PostSlugsResult; + } +} diff --git a/examples/cms-sanity/sanity/lib/fetch.ts b/examples/cms-sanity/sanity/lib/fetch.ts index 91796e437cf50..f4d79180f5ee2 100644 --- a/examples/cms-sanity/sanity/lib/fetch.ts +++ b/examples/cms-sanity/sanity/lib/fetch.ts @@ -10,7 +10,7 @@ import { token } from "@/sanity/lib/token"; * and will also fetch from the CDN. * When using the "previewDrafts" perspective then the data is fetched from the live API and isn't cached, it will also fetch draft content that isn't published yet. */ -export async function sanityFetch({ +export async function sanityFetch({ query, params = {}, perspective = draftMode().isEnabled ? "previewDrafts" : "published", @@ -22,13 +22,13 @@ export async function sanityFetch({ stega = perspective === "previewDrafts" || process.env.VERCEL_ENV === "preview", }: { - query: string; + query: QueryString; params?: QueryParams; perspective?: Omit; stega?: boolean; }) { if (perspective === "previewDrafts") { - return client.fetch(query, params, { + return client.fetch(query, params, { stega, perspective: "previewDrafts", // The token is required to fetch draft content @@ -39,7 +39,7 @@ export async function sanityFetch({ next: { revalidate: 0 }, }); } - return client.fetch(query, params, { + return client.fetch(query, params, { stega, perspective: "published", // The `published` perspective is available on the API CDN diff --git a/examples/cms-sanity/sanity/lib/queries.ts b/examples/cms-sanity/sanity/lib/queries.ts index 955060dcbb49f..47e3f7db6f92b 100644 --- a/examples/cms-sanity/sanity/lib/queries.ts +++ b/examples/cms-sanity/sanity/lib/queries.ts @@ -1,6 +1,6 @@ -import { groq } from "next-sanity"; +import { defineQuery } from "groq"; -export const settingsQuery = groq`*[_type == "settings"][0]`; +export const settingsQuery = defineQuery(`*[_type == "settings"][0]`); const postFields = /* groq */ ` _id, @@ -13,16 +13,22 @@ const postFields = /* groq */ ` "author": author->{"name": coalesce(name, "Anonymous"), picture}, `; -export const heroQuery = groq`*[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { - content, - ${postFields} -}`; +export const heroQuery = defineQuery(` + *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) [0] { + content, + ${postFields} + } +`); -export const moreStoriesQuery = groq`*[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { - ${postFields} -}`; +export const moreStoriesQuery = defineQuery(` + *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] { + ${postFields} + } +`); -export const postQuery = groq`*[_type == "post" && slug.current == $slug] [0] { - content, - ${postFields} -}`; +export const postQuery = defineQuery(` + *[_type == "post" && slug.current == $slug] [0] { + content, + ${postFields} + } +`); diff --git a/examples/cms-sitecore-xmcloud/sitecore/config/xmcloud-nextjs-starter.config b/examples/cms-sitecore-xmcloud/sitecore/config/xmcloud-nextjs-starter.config index e0a7e02d4a43f..f8d2e329d9885 100644 --- a/examples/cms-sitecore-xmcloud/sitecore/config/xmcloud-nextjs-starter.config +++ b/examples/cms-sitecore-xmcloud/sitecore/config/xmcloud-nextjs-starter.config @@ -111,7 +111,7 @@ Note: the parameter sets defined here are comma-delimited (,) instead of &-delimited like the query string. Multiple sets are endline-delimited. --> - + mw=100,mh=50 diff --git a/examples/with-docker-multi-env/docker/development/docker-compose.yml b/examples/with-docker-multi-env/docker/development/docker-compose.yml index 2a9c2d4a42662..9ad557faae9fd 100644 --- a/examples/with-docker-multi-env/docker/development/docker-compose.yml +++ b/examples/with-docker-multi-env/docker/development/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: with-docker-multi-env-development: build: diff --git a/examples/with-docker-multi-env/docker/production/docker-compose.yml b/examples/with-docker-multi-env/docker/production/docker-compose.yml index 4607e54450eca..ad46190b349bd 100644 --- a/examples/with-docker-multi-env/docker/production/docker-compose.yml +++ b/examples/with-docker-multi-env/docker/production/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: with-docker-multi-env-production: build: diff --git a/examples/with-docker-multi-env/docker/staging/docker-compose.yml b/examples/with-docker-multi-env/docker/staging/docker-compose.yml index 66bc42e26f1f9..f192e12b48c10 100644 --- a/examples/with-docker-multi-env/docker/staging/docker-compose.yml +++ b/examples/with-docker-multi-env/docker/staging/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - services: with-docker-multi-env-staging: build: diff --git a/packages/next/src/cli/next-info.ts b/packages/next/src/cli/next-info.ts index bbcd59c5f9464..7c68c35954586 100755 --- a/packages/next/src/cli/next-info.ts +++ b/packages/next/src/cli/next-info.ts @@ -360,7 +360,7 @@ async function printVerboseInfo() { const bindings = await loadBindings( nextConfig.experimental?.useWasmBinary ) - // Run arbitary function to verify the bindings are loaded correctly. + // Run arbitrary function to verify the bindings are loaded correctly. const target = bindings.getTargetTriple() // We think next-swc is installed correctly if getTargetTriple returns.