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

Enabel appDir when flag and dir existed at the same time #41233

Merged
merged 2 commits into from Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/preset.js
Expand Up @@ -7,7 +7,7 @@ const CWD = process.cwd()

async function webpackFinal(config) {
const nextConfig = await loadConfig(PHASE_PRODUCTION_BUILD, CWD)
const pagesDir = findPagesDir(CWD, !!nextConfig.experimental.appDir)
const { pagesDir } = findPagesDir(CWD, !!nextConfig.experimental.appDir)
const nextWebpackConfig = await getWebpackConfig(CWD, {
pagesDir,
entrypoints: {},
Expand Down
8 changes: 4 additions & 4 deletions packages/next/build/index.ts
Expand Up @@ -301,8 +301,8 @@ export default async function build(
setGlobal('telemetry', telemetry)

const publicDir = path.join(dir, 'public')
const hasAppDir = !!config.experimental.appDir
const { pagesDir, appDir } = findPagesDir(dir, hasAppDir)
const isAppDirEnabled = !!config.experimental.appDir
const { pagesDir, appDir } = findPagesDir(dir, isAppDirEnabled)

const hasPublicDir = await fileExists(publicDir)

Expand Down Expand Up @@ -394,7 +394,7 @@ export default async function build(
config.experimental.cpus,
config.experimental.workerThreads,
telemetry,
hasAppDir
isAppDirEnabled && !!appDir
)
}),
])
Expand Down Expand Up @@ -1988,7 +1988,7 @@ export default async function build(
combinedPages.length > 0 ||
useStatic404 ||
useDefaultStatic500 ||
hasAppDir
isAppDirEnabled
) {
const staticGenerationSpan =
nextBuildSpan.traceChild('static-generation')
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/jest/jest.ts
Expand Up @@ -72,8 +72,8 @@ export default function nextJest(options: { dir?: string } = {}) {
isEsmProject = packageConfig.type === 'module'

nextConfig = await getConfig(resolvedDir)
const hasAppDir = !!nextConfig.experimental.appDir
const findPagesDirResult = findPagesDir(resolvedDir, hasAppDir)
const isAppDirEnabled = !!nextConfig.experimental.appDir
const findPagesDirResult = findPagesDir(resolvedDir, isAppDirEnabled)
hasServerComponents = !!findPagesDirResult.appDir
pagesDir = findPagesDirResult.pagesDir
setUpEnv(resolvedDir, nextConfig)
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack-config.ts
Expand Up @@ -563,7 +563,7 @@ export default async function getBaseWebpackConfig(
rewrites.afterFiles.length > 0 ||
rewrites.fallback.length > 0

const hasAppDir = !!config.experimental.appDir
const hasAppDir = !!config.experimental.appDir && !!appDir
const hasConcurrentFeatures = hasReactRoot
const hasServerComponents = hasAppDir

Expand Down Expand Up @@ -1587,7 +1587,7 @@ export default async function getBaseWebpackConfig(
]
: []),
// Alias `next/dynamic` to React.lazy implementation for RSC
...(hasServerComponents && appDir
...(hasServerComponents
? [
{
test: codeCondition.test,
Expand Down
3 changes: 2 additions & 1 deletion packages/next/server/base-server.ts
Expand Up @@ -368,7 +368,8 @@ export default abstract class Server<ServerOptions extends Options = Options> {
this.buildId = this.getBuildId()
this.minimalMode = minimalMode || !!process.env.NEXT_PRIVATE_MINIMAL_MODE

this.hasAppDir = this.getHasAppDir(dev)
this.hasAppDir =
!!this.nextConfig.experimental.appDir && this.getHasAppDir(dev)
const serverComponents = this.hasAppDir
this.serverComponentManifest = serverComponents
? this.getServerComponentManifest()
Expand Down
5 changes: 4 additions & 1 deletion packages/next/server/dev/next-dev-server.ts
Expand Up @@ -191,7 +191,10 @@ export default class DevServer extends Server {

this.isCustomServer = !options.isNextDevCommand

const { pagesDir, appDir } = findPagesDir(this.dir, this.hasAppDir)
const { pagesDir, appDir } = findPagesDir(
this.dir,
!!this.nextConfig.experimental.appDir
)
this.pagesDir = pagesDir
this.appDir = appDir
}
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/streaming-ssr/index.test.ts
Expand Up @@ -22,6 +22,11 @@ describe('react 18 streaming SSR with custom next configs', () => {
beforeAll(async () => {
next = await createNext({
files: {
'app/page.js': `
export default function Page() {
return 'fake-app' /* this should not enable appDir */
}
`,
pages: new FileRef(join(__dirname, 'streaming-ssr/pages')),
},
nextConfig: require(join(__dirname, 'streaming-ssr/next.config.js')),
Expand Down