From 43801e816f1d8fb571d146040075fee63be29dca Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sun, 22 Oct 2023 23:08:56 +0800 Subject: [PATCH] feat(next-drupal)!: add App Router support for Server Components Fixes #442 BREAKING CHANGE: The useMenu() client hook has moved out of the main entry point and into its own entry point. Any import or require of that function needs to be updated: Old usage: ```js import { useMenu } from "next-drupal" ``` New usage: ```js import { useMenu } from "next-drupal/navigation" ``` --- packages/next-drupal/package.json | 15 ++++++++++++++- packages/next-drupal/src/index.ts | 1 - packages/next-drupal/src/navigation.ts | 1 + .../src/{use-menu.tsx => navigation/use-menu.ts} | 4 ++-- packages/next-drupal/tsup.config.ts | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 packages/next-drupal/src/navigation.ts rename packages/next-drupal/src/{use-menu.tsx => navigation/use-menu.ts} (90%) diff --git a/packages/next-drupal/package.json b/packages/next-drupal/package.json index 0b83511f..6def4c94 100644 --- a/packages/next-drupal/package.json +++ b/packages/next-drupal/package.json @@ -3,7 +3,10 @@ "description": "Helpers for Next.js + Drupal.", "version": "1.6.0", "sideEffects": false, - "source": "src/index.ts", + "source": [ + "src/index.ts", + "src/navigation.ts" + ], "type": "module", "main": "dist/index.cjs", "module": "dist/index.js", @@ -18,6 +21,16 @@ "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } + }, + "./navigation": { + "import": { + "types": "./dist/navigation.d.ts", + "default": "./dist/navigation.js" + }, + "require": { + "types": "./dist/navigation.d.cts", + "default": "./dist/navigation.cjs" + } } }, "license": "MIT", diff --git a/packages/next-drupal/src/index.ts b/packages/next-drupal/src/index.ts index bc107a47..fb7c2513 100644 --- a/packages/next-drupal/src/index.ts +++ b/packages/next-drupal/src/index.ts @@ -8,7 +8,6 @@ export * from "./get-resource" export * from "./get-search-index" export * from "./get-view" export * from "./types" -export * from "./use-menu" export * from "./translate-path" export { deserialize, diff --git a/packages/next-drupal/src/navigation.ts b/packages/next-drupal/src/navigation.ts new file mode 100644 index 00000000..33d5f232 --- /dev/null +++ b/packages/next-drupal/src/navigation.ts @@ -0,0 +1 @@ +export { useMenu } from "./navigation/use-menu" diff --git a/packages/next-drupal/src/use-menu.tsx b/packages/next-drupal/src/navigation/use-menu.ts similarity index 90% rename from packages/next-drupal/src/use-menu.tsx rename to packages/next-drupal/src/navigation/use-menu.ts index 441a2a43..cbc4b3f6 100644 --- a/packages/next-drupal/src/use-menu.tsx +++ b/packages/next-drupal/src/navigation/use-menu.ts @@ -1,7 +1,7 @@ import { useRouter } from "next/router" import { useEffect, useState } from "react" -import { getMenu } from "./get-menu" -import type { DrupalMenuLinkContent } from "./types" +import { getMenu } from "../get-menu" +import type { DrupalMenuLinkContent } from "../types" export function useMenu( name: string diff --git a/packages/next-drupal/tsup.config.ts b/packages/next-drupal/tsup.config.ts index 2562b07f..0690563c 100644 --- a/packages/next-drupal/tsup.config.ts +++ b/packages/next-drupal/tsup.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from "tsup" export const tsup = defineConfig({ - entry: ["src/index.ts"], + entry: ["src/index.ts", "src/navigation.ts"], // Enable experimental code splitting support in CommonJS. // splitting: true, // Use Rollup for tree shaking.