071ecb0b7b
This updates the `outputFileTracing` to fix a few cases we noticed where files weren't caught and also ensures we match webpack's `esm` resolving so that we don't include `cjs` files when webpack expects `esm`, it also updates to the latest `@vercel/nft` version which removes the caching in favor of ensuring the `reasons` map contains all parents allowing us to trace all entries in one `nodeFileTrace` run and the collect the separate files for each entry from the `reasons` map giving us much better performance/reliability. This also ensures we don't include static image imports when enabled in the traces since they can drastically increase deployment size on larger projects.
31 lines
860 B
TypeScript
31 lines
860 B
TypeScript
import curry from 'next/dist/compiled/lodash.curry'
|
|
import { webpack } from 'next/dist/compiled/webpack/webpack'
|
|
import { nextImageLoaderRegex } from '../../../../webpack-config'
|
|
import { loader } from '../../helpers'
|
|
import { ConfigurationContext, ConfigurationFn, pipe } from '../../utils'
|
|
import { getCustomDocumentImageError } from './messages'
|
|
|
|
export const images = curry(async function images(
|
|
_ctx: ConfigurationContext,
|
|
config: webpack.Configuration
|
|
) {
|
|
const fns: ConfigurationFn[] = [
|
|
loader({
|
|
oneOf: [
|
|
{
|
|
test: nextImageLoaderRegex,
|
|
use: {
|
|
loader: 'error-loader',
|
|
options: {
|
|
reason: getCustomDocumentImageError(),
|
|
},
|
|
},
|
|
issuer: /pages[\\/]_document\./,
|
|
},
|
|
],
|
|
}),
|
|
]
|
|
|
|
const fn = pipe(...fns)
|
|
return fn(config)
|
|
})
|