Skip to content

Commit

Permalink
Experimental feature changes (#21646)
Browse files Browse the repository at this point in the history
Adding test for experimental-serverless-trace + fix for the same
  • Loading branch information
janicklas-ralph authored Jan 29, 2021
1 parent 08846cf commit 8f21c28
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ export default async function getBaseWebpackConfig(
config.experimental.optimizeImages
),
'process.env.__NEXT_OPTIMIZE_CSS': JSON.stringify(
!!config.experimental.optimizeCss && !dev
config.experimental.optimizeCss && !dev
),
'process.env.__NEXT_SCROLL_RESTORATION': JSON.stringify(
config.experimental.scrollRestoration
Expand Down Expand Up @@ -1202,6 +1202,7 @@ export default async function getBaseWebpackConfig(
reactMode: config.experimental.reactMode,
optimizeFonts: config.experimental.optimizeFonts,
optimizeImages: config.experimental.optimizeImages,
optimizeCss: config.experimental.optimizeCss,
scrollRestoration: config.experimental.scrollRestoration,
basePath: config.basePath,
pageEnv: config.experimental.pageEnv,
Expand Down
2 changes: 2 additions & 0 deletions packages/next/next-server/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,8 @@ export default class Server {
locale,
locales,
defaultLocale,
optimizeCss: this.renderOpts.optimizeCss,
distDir: this.distDir,
fontManifest: this.renderOpts.fontManifest,
domainLocales: this.renderOpts.domainLocales,
}
Expand Down
2 changes: 2 additions & 0 deletions test/integration/critical-css/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export default function Home() {
</div>
)
}

Home.getInitialProps = () => ({})
18 changes: 18 additions & 0 deletions test/integration/critical-css/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,21 @@ describe('CSS optimization for serverless apps', () => {
afterAll(() => killApp(app))
runTests()
})

describe('Font optimization for emulated serverless apps', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'experimental-serverless-trace', experimental: {optimizeCss: true} }`,
'utf8'
)
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
await fs.remove(nextConfig)
})
runTests()
})

0 comments on commit 8f21c28

Please sign in to comment.