Unverified Commit 143926d6 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Disable `supportsImmutableAssets` with `config.output` (#95521)

`output=export` and `output=standalone` don't use adapters.
But for `supportsImmutableAssets`, you really want the adapter to get
all necessary data.

Disable immutable assets for now in this case. Once `output=export` runs
the adapter (as it should), we can remove this override again
parent 66182eb3
...@@ -1624,6 +1624,17 @@ function finalizeConfig(config: NextConfigComplete): NextConfigComplete { ...@@ -1624,6 +1624,17 @@ function finalizeConfig(config: NextConfigComplete): NextConfigComplete {
config.experimental.supportsImmutableAssets = true config.experimental.supportsImmutableAssets = true
} }
if (
config.experimental.supportsImmutableAssets &&
(config.output === 'export' || config.output === 'standalone')
) {
// supportsImmutableAssets is designed to work with adapters. Disable it for output=export and
// output=standalone, which are currently using a non-adapter codepath.
// Particularly output=export should just run through the adapter, with only static assets.
// TODO remove again once output=export (and output=standalone) are using adapters.
config.experimental.supportsImmutableAssets = false
}
return config return config
} }
......
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>hello world</p>
}
import { nextTestSetup } from 'e2e-utils'
import { join } from 'path'
import { listClientChunks } from 'next-test-utils'
// Immutable static files are only supported with Turbopack anywy
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'output: export - immutable assets disabled',
() => {
const { next } = nextTestSetup({
files: __dirname,
// `next start` does not work with `output: 'export'`.
skipStart: true,
disableAutoSkewProtection: true,
})
// supportsImmutableAssets is designed to work with adapters. It must be
// force-disabled for `output: 'export'`, so even though it is requested here
// the build should not emit any `_next/static/immutable` assets.
// We can loosen this requirement in the future when using output=export together with an adapter
it('does not emit any _next/static/immutable files', async () => {
const { exitCode } = await next.build()
expect(exitCode).toBe(0)
const files = await listClientChunks(join(next.testDir, next.distDir))
expect(files).not.toBeEmpty()
expect(files).toSatisfyAll((f) => f.includes('static/'))
expect(files).toSatisfyAll((f) => !f.includes('static/immutable/'))
})
}
)
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
deploymentId: 'test-deployment-id',
experimental: {
supportsImmutableAssets: true,
},
}
module.exports = nextConfig
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment