Skip to content

Commit

Permalink
Remove remaining granular chunks references (vercel#13672)
Browse files Browse the repository at this point in the history
This removes remaining references to `granularChunks` in configs, error messages, and comments.

Also removed the `process.env.__NEXT_GRANULAR_CHUNKS` value.

---

Follow up to: vercel#13663
  • Loading branch information
Timer authored Jun 2, 2020
1 parent 0769a82 commit a92e976
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/next/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function createEntrypoints(
pageLoaderOpts
)}!`

// Make sure next/router is a dependency of _app or else granularChunks
// Make sure next/router is a dependency of _app or else chunk splitting
// might cause the router to not be able to load causing hydration
// to fail

Expand Down
1 change: 0 additions & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,6 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_MODERN_BUILD': JSON.stringify(
config.experimental.modern && !dev
),
'process.env.__NEXT_GRANULAR_CHUNKS': JSON.stringify(!dev),
'process.env.__NEXT_BUILD_INDICATOR': JSON.stringify(
config.devIndicators.buildActivity
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ export interface GranularChunksConformanceCheck

function getWarningMessage(modifiedProp: string) {
return (
`${CONFORMANCE_WARNING_PREFIX}: The splitChunks config as part of the granularChunks flag has ` +
`been carefully crafted to optimize build size and build times. Modifying - ${chalk.bold(
`${CONFORMANCE_WARNING_PREFIX}: The splitChunks config has been carefully ` +
`crafted to optimize build size and build times. Modifying - ${chalk.bold(
modifiedProp
)} could result in slower builds and increased code duplication`
)
}

function getErrorMessage(message: string) {
return (
`${CONFORMANCE_ERROR_PREFIX}: The splitChunks config as part of the granularChunks flag has ` +
`been carefully crafted to optimize build size and build times. Please avoid changes to ${chalk.bold(
`${CONFORMANCE_ERROR_PREFIX}: The splitChunks config has been carefully ` +
`crafted to optimize build size and build times. Please avoid changes to ${chalk.bold(
message
)}`
)
Expand Down
6 changes: 3 additions & 3 deletions packages/next/client/page-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class PageLoader {
this.pageCache = {}
this.pageRegisterEvents = mitt()
this.loadingRoutes = {}
if (process.env.__NEXT_GRANULAR_CHUNKS) {
if (process.env.NODE_ENV === 'production') {
this.promisedBuildManifest = new Promise((resolve) => {
if (window.__BUILD_MANIFEST) {
resolve(window.__BUILD_MANIFEST)
Expand Down Expand Up @@ -215,7 +215,7 @@ export default class PageLoader {

if (!this.loadingRoutes[route]) {
this.loadingRoutes[route] = true
if (process.env.__NEXT_GRANULAR_CHUNKS) {
if (process.env.NODE_ENV === 'production') {
this.getDependencies(route).then((deps) => {
deps.forEach((d) => {
if (
Expand Down Expand Up @@ -348,7 +348,7 @@ export default class PageLoader {
relPrefetch,
url.match(/\.css$/) ? 'style' : 'script'
),
process.env.__NEXT_GRANULAR_CHUNKS &&
process.env.NODE_ENV === 'production' &&
!isDependency &&
this.getDependencies(route).then((urls) =>
Promise.all(
Expand Down
9 changes: 3 additions & 6 deletions test/.stats-app/stats-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ module.exports = {
return config
},
experimental: {
modern: true,
granularChunks: true
modern: true
}
}
`,
Expand All @@ -128,8 +127,7 @@ module.exports = {
module.exports = {
generateBuildId: () => 'BUILD_ID',
experimental: {
modern: true,
granularChunks: true
modern: true
}
}
`,
Expand Down Expand Up @@ -164,8 +162,7 @@ module.exports = {
generateBuildId: () => 'BUILD_ID',
target: 'serverless',
experimental: {
modern: true,
granularChunks: true
modern: true
}
}
`,
Expand Down
2 changes: 1 addition & 1 deletion test/integration/chunking/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Chunking', () => {

afterAll(() => stopApp(server))

it('should hydrate with granularChunks config', async () => {
it('should hydrate with aggressive chunking', async () => {
const browser = await webdriver(appPort, '/page2')
const text = await browser.elementByCss('#padded-str').text()

Expand Down
6 changes: 3 additions & 3 deletions test/integration/conformance/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ describe('Conformance system', () => {
)
})

it('Should warn about changes to granularChunks config', async () => {
it('Should warn about changes to splitChunks config', async () => {
const { stderr } = build
expect(stderr).toContain(
'[BUILD CONFORMANCE ERROR]: The splitChunks config as part of the granularChunks flag has ' +
`been carefully crafted to optimize build size and build times. Please avoid changes to ${chalk.bold(
'[BUILD CONFORMANCE ERROR]: The splitChunks config has been carefully ' +
`crafted to optimize build size and build times. Please avoid changes to ${chalk.bold(
'splitChunks.cacheGroups.vendors'
)}`
)
Expand Down

0 comments on commit a92e976

Please sign in to comment.