Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
ebb6a303
Commit
ebb6a303
authored
Aug 11, 2021
by
Tim Neutkens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Add warning during `next build` when sharp is missing (#27933)"
This reverts commit
51a2a028
.
parent
52486cec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
55 deletions
+12
-55
index.ts
packages/next/build/index.ts
+0
-16
index.test.js
test/integration/image-optimizer/test/index.test.js
+12
-39
No files found.
packages/next/build/index.ts
View file @
ebb6a303
...
...
@@ -930,22 +930,6 @@ export default async function build(
return
returnValue
})
if
(
isNextImageImported
)
{
try
{
if
(
process
.
env
.
NEXT_SHARP_PATH
)
{
require
(
process
.
env
.
NEXT_SHARP_PATH
)
}
else
{
require
.
resolve
(
'sharp'
,
{
paths
:
[
path
.
join
(
dir
,
'node_modules'
)],
})
}
}
catch
(
e
)
{
Log
.
warn
(
'Detected `next/image` usage without `sharp`. https://nextjs.org/docs/messages/sharp-missing-in-production'
)
}
}
if
(
customAppGetInitialProps
)
{
console
.
warn
(
chalk
.
bold
.
yellow
(
`Warning: `
)
+
...
...
test/integration/image-optimizer/test/index.test.js
View file @
ebb6a303
...
...
@@ -23,11 +23,10 @@ const imagesDir = join(appDir, '.next', 'cache', 'images')
const
nextConfig
=
new
File
(
join
(
appDir
,
'next.config.js'
))
const
largeSize
=
1080
// defaults defined in server/config.ts
let
nextOutput
let
buildOutput
let
appPort
let
app
const
sharpRuntimeWarning
=
`For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended`
const
sharp
BuildWarning
=
'Detected `next/image` usage without `sharp`.'
const
sharp
MissingText
=
`For production Image Optimization with Next.js, the optional 'sharp' package is strongly recommended`
async
function
fsToJson
(
dir
,
output
=
{})
{
const
files
=
await
fs
.
readdir
(
dir
)
...
...
@@ -727,29 +726,13 @@ function runTests({ w, isDev, domains = [], ttl, isSharp }) {
expect
(
Object
.
keys
(
json1
).
length
).
toBe
(
1
)
})
if
(
isDev
)
{
it
(
'should not have runtime warning in dev'
,
()
=>
{
expect
(
nextOutput
).
not
.
toContain
(
sharpRuntimeWarning
)
})
it
(
'should not have build warning in dev'
,
()
=>
{
expect
(
buildOutput
).
not
.
toContain
(
sharpBuildWarning
)
})
}
else
if
(
isSharp
)
{
it
(
'should not have runtime warning when sharp is installed'
,
()
=>
{
expect
(
nextOutput
).
not
.
toContain
(
sharpRuntimeWarning
)
})
it
(
'should not have build warning when sharp is installed'
,
()
=>
{
expect
(
buildOutput
).
not
.
toContain
(
sharpBuildWarning
)
if
(
isDev
||
isSharp
)
{
it
(
'should not have sharp missing warning'
,
()
=>
{
expect
(
nextOutput
).
not
.
toContain
(
sharpMissingText
)
})
}
else
{
it
(
'should have runtime warning when sharp is not installed'
,
()
=>
{
expect
(
nextOutput
).
toContain
(
sharpRuntimeWarning
)
})
it
(
'should have build warning when sharp is not installed'
,
()
=>
{
expect
(
buildOutput
).
toContain
(
sharpBuildWarning
)
it
(
'should have sharp missing warning'
,
()
=>
{
expect
(
nextOutput
).
toContain
(
sharpMissingText
)
})
}
}
...
...
@@ -927,10 +910,8 @@ describe('Image Optimizer', () => {
},
})
nextOutput
=
''
buildOutput
=
''
nextConfig
.
replace
(
'{ /* replaceme */ }'
,
json
)
const
out
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
buildOutput
=
out
.
stderr
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
,
{
onStderr
(
msg
)
{
...
...
@@ -968,8 +949,7 @@ describe('Image Optimizer', () => {
},
}`
)
const
out
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
buildOutput
=
out
.
stderr
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
...
...
@@ -1045,8 +1025,7 @@ describe('Image Optimizer', () => {
},
}`
nextConfig
.
replace
(
'{ /* replaceme */ }'
,
newConfig
)
const
out
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
buildOutput
=
out
.
stderr
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
)
})
...
...
@@ -1105,7 +1084,6 @@ describe('Image Optimizer', () => {
const
size
=
384
// defaults defined in server/config.ts
beforeAll
(
async
()
=>
{
nextOutput
=
''
buildOutput
=
''
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
,
{
onStderr
(
msg
)
{
...
...
@@ -1133,7 +1111,6 @@ describe('Image Optimizer', () => {
},
})
nextOutput
=
''
buildOutput
=
''
nextConfig
.
replace
(
'{ /* replaceme */ }'
,
json
)
appPort
=
await
findPort
()
app
=
await
launchApp
(
appDir
,
appPort
,
{
...
...
@@ -1156,9 +1133,7 @@ describe('Image Optimizer', () => {
const
size
=
384
// defaults defined in server/config.ts
beforeAll
(
async
()
=>
{
nextOutput
=
''
buildOutput
=
''
const
out
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
buildOutput
=
out
.
stderr
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
,
{
onStderr
(
msg
)
{
...
...
@@ -1192,10 +1167,8 @@ describe('Image Optimizer', () => {
},
})
nextOutput
=
''
buildOutput
=
''
nextConfig
.
replace
(
'{ /* replaceme */ }'
,
json
)
const
out
=
await
nextBuild
(
appDir
,
[],
{
stderr
:
true
})
buildOutput
=
out
.
stderr
await
nextBuild
(
appDir
)
appPort
=
await
findPort
()
app
=
await
nextStart
(
appDir
,
appPort
,
{
onStderr
(
msg
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment