Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exports for new router #41368

Merged
merged 5 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,7 +19,7 @@ import {
import type { DispatchFn } from './client'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import formatWebpackMessages from '../../dev/error-overlay/format-webpack-messages'
import { useRouter } from '../hooks-client'
import { useRouter } from '../navigation'
import { errorOverlayReducer } from './internal/error-overlay-reducer'

function getSocketProtocol(assetPrefix: string): string {
Expand Down
1 change: 1 addition & 0 deletions packages/next/headers.d.ts
@@ -0,0 +1 @@
export * from './dist/client/components/headers'
1 change: 1 addition & 0 deletions packages/next/headers.js
@@ -0,0 +1 @@
module.exports = require('./dist/client/components/headers')
1 change: 1 addition & 0 deletions packages/next/navigation.d.ts
@@ -0,0 +1 @@
export * from './dist/client/components/navigation'
1 change: 1 addition & 0 deletions packages/next/navigation.js
@@ -0,0 +1 @@
module.exports = require('./dist/client/components/navigation')
6 changes: 5 additions & 1 deletion packages/next/package.json
Expand Up @@ -48,7 +48,11 @@
"types/global.d.ts",
"types/compiled.d.ts",
"image-types/global.d.ts",
"font"
"font",
"navigation.js",
"navigation.d.ts",
"headers.js",
"headers.d.ts"
],
"bin": {
"next": "./dist/bin/next"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app-edge/app/app-edge/layout.tsx
Expand Up @@ -2,7 +2,7 @@

// TODO-APP: support typing for useSelectedLayoutSegment
// @ts-ignore
import { useSelectedLayoutSegment } from 'next/dist/client/components/hooks-client'
import { useSelectedLayoutSegment } from 'next/navigation'

export default function Layout({ children }: { children: React.ReactNode }) {
// useSelectedLayoutSegment should not be thrown
Expand Down
@@ -1,5 +1,5 @@
import ClientComp from './client-component'
import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

export default function Page() {
// Opt-in to SSR.
Expand Down
@@ -1,6 +1,6 @@
'use client'

import { cookies } from 'next/dist/client/components/hooks-server'
import { cookies } from 'next/headers'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-cookies/page.js
@@ -1,4 +1,4 @@
import { cookies } from 'next/dist/client/components/hooks-server'
import { cookies } from 'next/headers'

export default function Page() {
const cookiesList = cookies()
Expand Down
@@ -1,6 +1,6 @@
'use client'

import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-headers/page.js
@@ -1,4 +1,4 @@
import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

export default function Page() {
const headersList = headers()
Expand Down
@@ -1,6 +1,6 @@
'use client'
// TODO-APP: enable once test is not skipped.
// import { useLayoutSegments } from 'next/dist/client/components/hooks-client'
// import { useLayoutSegments } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-params/server/page.js
@@ -1,5 +1,5 @@
// TODO-APP: enable when implemented.
// import { useParams } from 'next/dist/client/components/hooks-client'
// import { useParams } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-pathname/page.js
@@ -1,6 +1,6 @@
'use client'

import { usePathname } from 'next/dist/client/components/hooks-client'
import { usePathname } from 'next/navigation'

export default function Page() {
const pathname = usePathname()
Expand Down
@@ -1,4 +1,4 @@
// import { usePathname } from 'next/dist/client/components/hooks-client'
// import { usePathname } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
@@ -1,6 +1,6 @@
'use client'

import { previewData } from 'next/dist/client/components/hooks-server'
import { previewData } from 'next/headers'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-preview-data/page.js
@@ -1,4 +1,4 @@
import { previewData } from 'next/dist/client/components/hooks-server'
import { previewData } from 'next/headers'

export default function Page() {
const data = previewData()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-router/page.js
@@ -1,6 +1,6 @@
'use client'

import { useRouter } from 'next/dist/client/components/hooks-client'
import { useRouter } from 'next/navigation'

export default function Page() {
const router = useRouter()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-router/server/page.js
@@ -1,4 +1,4 @@
// import { useRouter } from 'next/dist/client/components/hooks-client'
// import { useRouter } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/hooks/use-search-params/page.js
@@ -1,6 +1,6 @@
'use client'

import { useSearchParams } from 'next/dist/client/components/hooks-client'
import { useSearchParams } from 'next/navigation'

export default function Page() {
const params = useSearchParams()
Expand Down
@@ -1,4 +1,4 @@
// import { useSearchParams } from 'next/dist/client/components/hooks-client'
// import { useSearchParams } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
@@ -1,6 +1,6 @@
'use client'
// TODO-APP: enable once test is not skipped.
// import { useSelectedLayoutSegment } from 'next/dist/client/components/hooks-client'
// import { useSelectedLayoutSegment } from 'next/navigation'

export default function Page() {
// This should throw an error.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/navigation/link.js
@@ -1,6 +1,6 @@
'use client'

import { useRouter } from 'next/dist/client/components/hooks-client'
import { useRouter } from 'next/navigation'
import React from 'react'
import { useEffect } from 'react'

Expand Down
@@ -1,7 +1,7 @@
'use client'

import { TabNavItem } from './TabNavItem'
import { useSelectedLayoutSegment } from 'next/dist/client/components/hooks-client'
import { useSelectedLayoutSegment } from 'next/navigation'

const CategoryNav = ({ categories }) => {
const selectedLayoutSegment = useSelectedLayoutSegment()
Expand Down
@@ -1,7 +1,7 @@
'use client'

import { TabNavItem } from '../TabNavItem'
import { useSelectedLayoutSegment } from 'next/dist/client/components/hooks-client'
import { useSelectedLayoutSegment } from 'next/navigation'

const SubCategoryNav = ({ category }) => {
const selectedLayoutSegment = useSelectedLayoutSegment()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/not-found/clientcomponent/a.js
@@ -1,6 +1,6 @@
// TODO-APP: enable when flight error serialization is implemented
import ClientComp from './client-component'
import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

export default function Page() {
// Opt-in to SSR.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/app/app/old-router/page.js
@@ -1,4 +1,4 @@
import { cookies } from 'next/dist/client/components/hooks-server'
import { cookies } from 'next/headers'
import Router from './router'

export default function Page() {
Expand Down
@@ -1,5 +1,5 @@
import ClientComp from './client-component'
import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

export default function Page() {
// Opt-in to SSR.
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/rsc-basic/app/page.js
@@ -1,5 +1,5 @@
import Nav from '../components/nav'
import { headers } from 'next/dist/client/components/hooks-server'
import { headers } from 'next/headers'

const envVar = process.env.ENV_VAR_TEST
const headerKey = 'x-next-test-client'
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/app-dir/rsc-basic/app/root-style-registry.js
Expand Up @@ -3,7 +3,7 @@
import React from 'react'
import { StyleRegistry, createStyleRegistry } from 'styled-jsx'
import { ServerStyleSheet, StyleSheetManager } from 'styled-components'
import { useServerInsertedHTML } from 'next/dist/client/components/hooks-client'
import { useServerInsertedHTML } from 'next/navigation'
import { useState } from 'react'

export default function RootStyleRegistry({ children }) {
Expand Down