Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/.stats-app/image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Image from 'next/image'
import logo from './nextjs.png'

function ImagePage(props) {
return (
<>
<h1>next/image example</h1>
<Image src={logo} placeholder="blur" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also want a couple other usages, such as blur and external image?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If either of these could impact the resulting client bundle differently it would be good to add these as well yeah, potentially in separate pages so we can see the impact separately

Copy link
Member

@styfle styfle Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I guess it won't affect the client bundle because all of the code for the image component lives in a single file.

The only thing that might affect the client bundle is config in next.config.js when that gets serialized to JSON, but thats a 1-to-1 mapping so we don't really need to test it here 👍

</>
)
}

// we add getServerSideProps to prevent static optimization
// to allow us to compare server-side changes
export const getServerSideProps = () => {
return {
props: {},
}
}

export default ImagePage
8 changes: 7 additions & 1 deletion test/.stats-app/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const Page = () => 'Hello world 👋'

Page.getInitialProps = () => ({})
// we add getServerSideProps to prevent static optimization
// to allow us to compare server-side changes
export const getServerSideProps = () => {
return {
props: {},
}
}

export default Page
8 changes: 7 additions & 1 deletion test/.stats-app/pages/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ function aLink(props) {
)
}

aLink.getInitialProps = () => ({})
// we add getServerSideProps to prevent static optimization
// to allow us to compare server-side changes
export const getServerSideProps = () => {
return {
props: {},
}
}

export default aLink
8 changes: 7 additions & 1 deletion test/.stats-app/pages/routerDirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ function routerDirect(props) {
return <div>I import the router directly</div>
}

routerDirect.getInitialProps = () => ({})
// we add getServerSideProps to prevent static optimization
// to allow us to compare server-side changes
export const getServerSideProps = () => {
return {
props: {},
}
}

export default routerDirect
8 changes: 7 additions & 1 deletion test/.stats-app/pages/withRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ function useWithRouter(props) {
return <div>I use withRouter</div>
}

useWithRouter.getInitialProps = () => ({})
// we add getServerSideProps to prevent static optimization
// to allow us to compare server-side changes
export const getServerSideProps = () => {
return {
props: {},
}
}

export default withRouter(useWithRouter)
29 changes: 23 additions & 6 deletions test/.stats-app/stats-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
const fs = require('fs')
const path = require('path')
// this page is conditionally added when not testing
// in webpack 4 mode since it's not supported for webpack 4
const imagePageData = fs.readFileSync(
path.join(__dirname, './image.js'),
'utf8'
)

const clientGlobs = [
{
name: 'Client Bundles (main, webpack, commons)',
Expand All @@ -12,11 +21,11 @@ const clientGlobs = [
},
{
name: 'Client Pages',
globs: ['.next/static/*/pages/**/*', '.next/static/css/**/*'],
globs: ['.next/static/BUILD_ID/pages/**/*.js', '.next/static/css/**/*'],
},
{
name: 'Client Build Manifests',
globs: ['.next/static/*/_buildManifest*'],
globs: ['.next/static/BUILD_ID/_buildManifest*'],
},
{
name: 'Rendered Page Sizes',
Expand All @@ -26,19 +35,19 @@ const clientGlobs = [

const renames = [
{
srcGlob: '.next/static/*/pages',
srcGlob: '.next/static/chunks/pages',
dest: '.next/static/BUILD_ID/pages',
},
{
srcGlob: '.next/static/*/pages/**/*',
srcGlob: '.next/static/BUILD_ID/pages/**/*.js',
removeHash: true,
},
{
srcGlob: '.next/static/runtime/*',
srcGlob: '.next/static/runtime/*.js',
removeHash: true,
},
{
srcGlob: '.next/static/chunks/*',
srcGlob: '.next/static/chunks/*.js',
removeHash: true,
},
{
Expand All @@ -60,6 +69,10 @@ module.exports = {
title: 'Default Build',
diff: 'onOutputChange',
diffConfigFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
Expand All @@ -77,6 +90,10 @@ module.exports = {
// renames to apply to make file names deterministic
renames,
configFiles: [
{
path: 'pages/image.js',
content: imagePageData,
},
{
path: 'next.config.js',
content: `
Expand Down