Unverified Commit 62a4de9f authored by Alex Castle's avatar Alex Castle Committed by GitHub

Remove feature flags for static image and blurry placeholder (#25797)

Co-authored-by: 's avatarSteven <steven@ceriously.com>
Co-authored-by: 's avatarTim Neutkens <timneutkens@me.com>
Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
Co-authored-by: 's avatarkodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
parent a09425f6
...@@ -51,6 +51,7 @@ import WebpackConformancePlugin, { ...@@ -51,6 +51,7 @@ import WebpackConformancePlugin, {
ReactSyncScriptsConformanceCheck, ReactSyncScriptsConformanceCheck,
} from './webpack/plugins/webpack-conformance-plugin' } from './webpack/plugins/webpack-conformance-plugin'
import { WellKnownErrorsPlugin } from './webpack/plugins/wellknown-errors-plugin' import { WellKnownErrorsPlugin } from './webpack/plugins/wellknown-errors-plugin'
import { regexLikeCss } from './webpack/config/blocks/css'
type ExcludesFalse = <T>(x: T | false) => x is T type ExcludesFalse = <T>(x: T | false) => x is T
...@@ -1013,11 +1014,12 @@ export default async function getBaseWebpackConfig( ...@@ -1013,11 +1014,12 @@ export default async function getBaseWebpackConfig(
] ]
: defaultLoaders.babel, : defaultLoaders.babel,
}, },
...(config.experimental.enableStaticImages ...(!config.images.disableStaticImages && isWebpack5
? [ ? [
{ {
test: /\.(png|svg|jpg|jpeg|gif|webp|ico|bmp)$/i, test: /\.(png|svg|jpg|jpeg|gif|webp|ico|bmp)$/i,
loader: 'next-image-loader', loader: 'next-image-loader',
issuer: { not: regexLikeCss },
dependency: { not: ['url'] }, dependency: { not: ['url'] },
}, },
] ]
...@@ -1110,7 +1112,6 @@ export default async function getBaseWebpackConfig( ...@@ -1110,7 +1112,6 @@ export default async function getBaseWebpackConfig(
domains: config.images.domains, domains: config.images.domains,
} }
: {}), : {}),
enableBlurryPlaceholder: config.experimental.enableBlurryPlaceholder,
}), }),
'process.env.__NEXT_ROUTER_BASEPATH': JSON.stringify(config.basePath), 'process.env.__NEXT_ROUTER_BASEPATH': JSON.stringify(config.basePath),
'process.env.__NEXT_HAS_REWRITES': JSON.stringify(hasRewrites), 'process.env.__NEXT_HAS_REWRITES': JSON.stringify(hasRewrites),
......
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
import { getPostCssPlugins } from './plugins' import { getPostCssPlugins } from './plugins'
// RegExps for all Style Sheet variants // RegExps for all Style Sheet variants
const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/ export const regexLikeCss = /\.(css|scss|sass)(\.webpack\[javascript\/auto\])?$/
// RegExps for Style Sheets // RegExps for Style Sheets
const regexCssGlobal = /(?<!\.module)\.css$/ const regexCssGlobal = /(?<!\.module)\.css$/
......
...@@ -117,7 +117,6 @@ const { ...@@ -117,7 +117,6 @@ const {
loader: configLoader, loader: configLoader,
path: configPath, path: configPath,
domains: configDomains, domains: configDomains,
enableBlurryPlaceholder: configEnableBlurryPlaceholder,
} = } =
((process.env.__NEXT_IMAGE_OPTS as any) as ImageConfig) || imageConfigDefault ((process.env.__NEXT_IMAGE_OPTS as any) as ImageConfig) || imageConfigDefault
// sort smallest to largest // sort smallest to largest
...@@ -298,9 +297,6 @@ export default function Image({ ...@@ -298,9 +297,6 @@ export default function Image({
delete rest['layout'] delete rest['layout']
} }
if (!configEnableBlurryPlaceholder) {
placeholder = 'empty'
}
const isStatic = typeof src === 'object' const isStatic = typeof src === 'object'
let staticSrc = '' let staticSrc = ''
if (isStaticImport(src)) { if (isStaticImport(src)) {
......
...@@ -44,7 +44,6 @@ export type NextConfig = { [key: string]: any } & { ...@@ -44,7 +44,6 @@ export type NextConfig = { [key: string]: any } & {
workerThreads?: boolean workerThreads?: boolean
pageEnv?: boolean pageEnv?: boolean
optimizeImages?: boolean optimizeImages?: boolean
enableStaticImages?: boolean
optimizeCss?: boolean optimizeCss?: boolean
scrollRestoration?: boolean scrollRestoration?: boolean
stats?: boolean stats?: boolean
...@@ -56,7 +55,6 @@ export type NextConfig = { [key: string]: any } & { ...@@ -56,7 +55,6 @@ export type NextConfig = { [key: string]: any } & {
skipValidation?: boolean skipValidation?: boolean
} }
reactRoot?: boolean reactRoot?: boolean
enableBlurryPlaceholder?: boolean
disableOptimizedLoading?: boolean disableOptimizedLoading?: boolean
gzipSize?: boolean gzipSize?: boolean
} }
...@@ -106,13 +104,11 @@ export const defaultConfig: NextConfig = { ...@@ -106,13 +104,11 @@ export const defaultConfig: NextConfig = {
workerThreads: false, workerThreads: false,
pageEnv: false, pageEnv: false,
optimizeImages: false, optimizeImages: false,
enableStaticImages: false,
optimizeCss: false, optimizeCss: false,
scrollRestoration: false, scrollRestoration: false,
stats: false, stats: false,
externalDir: false, externalDir: false,
reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0, reactRoot: Number(process.env.NEXT_PRIVATE_REACT_ROOT) > 0,
enableBlurryPlaceholder: false,
disableOptimizedLoading: true, disableOptimizedLoading: true,
gzipSize: true, gzipSize: true,
}, },
......
...@@ -13,7 +13,7 @@ export type ImageConfig = { ...@@ -13,7 +13,7 @@ export type ImageConfig = {
loader: LoaderValue loader: LoaderValue
path: string path: string
domains?: string[] domains?: string[]
enableBlurryPlaceholder: boolean disableStaticImages: boolean
} }
export const imageConfigDefault: ImageConfig = { export const imageConfigDefault: ImageConfig = {
...@@ -22,5 +22,5 @@ export const imageConfigDefault: ImageConfig = { ...@@ -22,5 +22,5 @@ export const imageConfigDefault: ImageConfig = {
path: '/_next/image', path: '/_next/image',
loader: 'default', loader: 'default',
domains: [], domains: [],
enableBlurryPlaceholder: false, disableStaticImages: false,
} }
...@@ -103,6 +103,7 @@ ...@@ -103,6 +103,7 @@
"raw-body": "2.4.1", "raw-body": "2.4.1",
"react-is": "17.0.2", "react-is": "17.0.2",
"react-refresh": "0.8.3", "react-refresh": "0.8.3",
"image-size": "1.0.0",
"stream-browserify": "3.0.0", "stream-browserify": "3.0.0",
"stream-http": "3.1.1", "stream-http": "3.1.1",
"string_decoder": "1.3.0", "string_decoder": "1.3.0",
......
/* eslint-env jest */ /* eslint-env jest */
import cheerio from 'cheerio' import cheerio from 'cheerio'
import fs from 'fs-extra'
import { import {
check, check,
findPort, findPort,
...@@ -20,7 +19,6 @@ import { join } from 'path' ...@@ -20,7 +19,6 @@ import { join } from 'path'
jest.setTimeout(1000 * 60) jest.setTimeout(1000 * 60)
const appDir = join(__dirname, '../') const appDir = join(__dirname, '../')
const nextConfig = join(appDir, 'next.config.js')
let appPort let appPort
let app let app
...@@ -553,21 +551,10 @@ function runTests(mode) { ...@@ -553,21 +551,10 @@ function runTests(mode) {
describe('Image Component Tests', () => { describe('Image Component Tests', () => {
describe('dev mode', () => { describe('dev mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.writeFile(
nextConfig,
`
module.exports = {
experimental: {
enableStaticImages: true
},
}
`
)
appPort = await findPort() appPort = await findPort()
app = await launchApp(appDir, appPort) app = await launchApp(appDir, appPort)
}) })
afterAll(async () => { afterAll(async () => {
await fs.unlink(nextConfig)
await killApp(app) await killApp(app)
}) })
...@@ -576,22 +563,11 @@ describe('Image Component Tests', () => { ...@@ -576,22 +563,11 @@ describe('Image Component Tests', () => {
describe('server mode', () => { describe('server mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.writeFile(
nextConfig,
`
module.exports = {
experimental: {
enableStaticImages: true
},
}
`
)
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(async () => { afterAll(async () => {
await fs.unlink(nextConfig)
await killApp(app) await killApp(app)
}) })
...@@ -600,24 +576,11 @@ describe('Image Component Tests', () => { ...@@ -600,24 +576,11 @@ describe('Image Component Tests', () => {
describe('serverless mode', () => { describe('serverless mode', () => {
beforeAll(async () => { beforeAll(async () => {
await fs.writeFile(
nextConfig,
`
module.exports = {
target: 'serverless',
experimental: {
enableBlurryPlaceholder: true,
enableStaticImages: true
},
}
`
)
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
}) })
afterAll(async () => { afterAll(async () => {
await fs.unlink(nextConfig)
await killApp(app) await killApp(app)
}) })
......
...@@ -18,7 +18,6 @@ let browser ...@@ -18,7 +18,6 @@ let browser
let html let html
const indexPage = new File(join(appDir, 'pages/static.js')) const indexPage = new File(join(appDir, 'pages/static.js'))
const nextConfig = new File(join(appDir, 'next.config.js'))
const runTests = () => { const runTests = () => {
it('Should allow an image with a static src to omit height and width', async () => { it('Should allow an image with a static src to omit height and width', async () => {
...@@ -77,17 +76,6 @@ describe('Build Error Tests', () => { ...@@ -77,17 +76,6 @@ describe('Build Error Tests', () => {
}) })
describe('Static Image Component Tests', () => { describe('Static Image Component Tests', () => {
beforeAll(async () => { beforeAll(async () => {
nextConfig.write(
`
module.exports = {
experimental: {
enableStaticImages: true,
enableBlurryPlaceholder: true,
},
}
`
)
await nextBuild(appDir) await nextBuild(appDir)
appPort = await findPort() appPort = await findPort()
app = await nextStart(appDir, appPort) app = await nextStart(appDir, appPort)
...@@ -95,7 +83,6 @@ describe('Static Image Component Tests', () => { ...@@ -95,7 +83,6 @@ describe('Static Image Component Tests', () => {
browser = await webdriver(appPort, '/static') browser = await webdriver(appPort, '/static')
}) })
afterAll(() => { afterAll(() => {
nextConfig.delete()
killApp(app) killApp(app)
}) })
runTests() runTests()
......
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