From fafecb8438576c2baadb0af014081cf279ee02a2 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 27 Apr 2023 15:28:10 +0200 Subject: [PATCH] add missing exports for static generation bailout (#48910) ### What? add missing exports from next-app-loader ### Why? avoid crashing Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../js/src/entry/app/layout-entry.tsx | 27 +++++++++++++------ .../app/force-dynamic/input/app/layout.tsx | 7 +++++ .../next/app/force-dynamic/input/app/page.tsx | 12 +++++++++ .../next/app/force-dynamic/input/app/test.tsx | 12 +++++++++ .../app/force-dynamic/input/next.config.js | 5 ++++ 5 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx create mode 100644 packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/next.config.js diff --git a/packages/next-swc/crates/next-core/js/src/entry/app/layout-entry.tsx b/packages/next-swc/crates/next-core/js/src/entry/app/layout-entry.tsx index c6bf4cf98e262..3aab98b573aab 100644 --- a/packages/next-swc/crates/next-core/js/src/entry/app/layout-entry.tsx +++ b/packages/next-swc/crates/next-core/js/src/entry/app/layout-entry.tsx @@ -1,10 +1,21 @@ -export { default as AppRouter } from 'next/dist/client/components/app-router.js' -export { default as LayoutRouter } from 'next/dist/client/components/layout-router.js' -export { default as RenderFromTemplateContext } from 'next/dist/client/components/render-from-template-context.js' -export { default as GlobalError } from 'next/dist/client/components/error-boundary.js' -export { staticGenerationAsyncStorage } from 'next/dist/client/components/static-generation-async-storage.js' -export { requestAsyncStorage } from 'next/dist/client/components/request-async-storage.js' -import * as serverHooks from 'next/dist/client/components/hooks-server-context.js' +export { default as AppRouter } from 'next/dist/client/components/app-router' +export { default as LayoutRouter } from 'next/dist/client/components/layout-router' +export { default as RenderFromTemplateContext } from 'next/dist/client/components/render-from-template-context' +export { default as GlobalError } from 'next/dist/client/components/error-boundary' + +export { staticGenerationAsyncStorage } from 'next/dist/client/components/static-generation-async-storage' + +export { requestAsyncStorage } from 'next/dist/client/components/request-async-storage' +export { actionAsyncStorage } from 'next/dist/client/components/action-async-storage' + +export { staticGenerationBailout } from 'next/dist/client/components/static-generation-bailout' +export { default as StaticGenerationSearchParamsBailoutProvider } from 'next/dist/client/components/static-generation-searchparams-bailout-provider' +export { createSearchParamsBailoutProxy } from 'next/dist/client/components/searchparams-bailout-proxy' + +import * as serverHooks from 'next/dist/client/components/hooks-server-context' export { serverHooks } -export { renderToReadableStream } from 'next/dist/compiled/react-server-dom-webpack/server.edge' +export { + renderToReadableStream, + decodeReply, +} from 'next/dist/compiled/react-server-dom-webpack/server.edge' export { preloadStyle } from 'next/dist/server/app-render/rsc/preloads' diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx new file mode 100644 index 0000000000000..12c84680889be --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/layout.tsx @@ -0,0 +1,7 @@ +export default function RootLayout({ children }: { children: any }) { + return ( + + {children} + + ) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx new file mode 100644 index 0000000000000..1b54d5f2e0a1a --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/page.tsx @@ -0,0 +1,12 @@ +import Test from './test' + +export const dynamic = 'force-dynamic' + +export default function Page({ searchParams }) { + return ( +
+

{JSON.stringify(searchParams)}

+ +
+ ) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx new file mode 100644 index 0000000000000..f4994b194885f --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/app/test.tsx @@ -0,0 +1,12 @@ +'use client' + +import { useEffect } from 'react' + +export default function Test() { + useEffect(() => { + import('@turbo/pack-test-harness').then(() => { + it('should run', () => {}) + }) + return () => {} + }, []) +} diff --git a/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/next.config.js b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/next.config.js new file mode 100644 index 0000000000000..cfa3ac3d7aa94 --- /dev/null +++ b/packages/next-swc/crates/next-dev-tests/tests/integration/next/app/force-dynamic/input/next.config.js @@ -0,0 +1,5 @@ +module.exports = { + experimental: { + appDir: true, + }, +}