Skip to content

Commit 22c5a06

Browse files
authored
[Breaking] Enable experimental.isolatedDevBuild by default (#84561)
### Why? This PR cleans up the incremental rollout of enabling `isolatedDevBuild` throughout the CI, as it required many test changes (x-ref: #84043). - #84556 - #84558 - #84559 - #84562 This PR enables `experimental.isolatedDevBuild` by default so that users can run `next dev` and `next build` in the same directory, and they would not conflict. This occasionally happens when developing with AI tools, where you have a running dev server, but the Agent runs `next build`. ### How? - Removed `__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD` flag and its usage from CI and tests - Updated tests that were not caught via rollout (e.g., missed out on test-*-windows) - Moved `isolatedDevBuild` option out of experimental - Added Telemetry Will follow up with docs.
1 parent d60d235 commit 22c5a06

File tree

13 files changed

+85
-50
lines changed

13 files changed

+85
-50
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,9 +542,7 @@ jobs:
542542
uses: ./.github/workflows/build_reusable.yml
543543
with:
544544
nodeVersion: ${{ matrix.node }}
545-
afterBuild: |
546-
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
547-
node run-tests.js --type unit
545+
afterBuild: node run-tests.js --type unit
548546
stepName: 'test-unit-${{ matrix.node }}'
549547

550548
secrets: inherit
@@ -735,7 +733,6 @@ jobs:
735733
export IS_WEBPACK_TEST=1
736734
export NEXT_TEST_MODE=dev
737735
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
738-
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
739736
740737
node run-tests.js \
741738
--timings \
@@ -849,7 +846,6 @@ jobs:
849846
export IS_WEBPACK_TEST=1
850847
export NEXT_TEST_MODE=start
851848
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
852-
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
853849
854850
node run-tests.js --timings -g ${{ matrix.group }} --type production
855851
stepName: 'test-prod-react-${{ matrix.react }}-${{ matrix.group }}'
@@ -889,7 +885,6 @@ jobs:
889885
afterBuild: |
890886
export IS_WEBPACK_TEST=1
891887
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
892-
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
893888
894889
node run-tests.js \
895890
--timings \

packages/next/src/build/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,10 @@ export default async function build(
27302730
featureName: 'experimental/ppr',
27312731
invocationCount: config.experimental.ppr ? 1 : 0,
27322732
},
2733+
{
2734+
featureName: 'experimental/isolatedDevBuild',
2735+
invocationCount: config.experimental.isolatedDevBuild ? 1 : 0,
2736+
},
27332737
{
27342738
featureName: 'turbopackFileSystemCache',
27352739
invocationCount: isFileSystemCacheEnabledForBuild(config) ? 1 : 0,

packages/next/src/server/config-shared.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,9 +1506,8 @@ export const defaultConfig = Object.freeze({
15061506
slowModuleDetection: undefined,
15071507
globalNotFound: false,
15081508
browserDebugInfoInTerminal: false,
1509-
isolatedDevBuild:
1510-
process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true',
15111509
lockDistDir: true,
1510+
isolatedDevBuild: true,
15121511
},
15131512
htmlLimitedBots: undefined,
15141513
bundlePagesRouterDependencies: false,

packages/next/src/telemetry/events/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export type EventBuildFeatureUsage = {
175175
| 'experimental/cacheComponents'
176176
| 'experimental/optimizeCss'
177177
| 'experimental/ppr'
178+
| 'experimental/isolatedDevBuild'
178179
| 'swcLoader'
179180
| 'swcRelay'
180181
| 'swcStyledComponents'

scripts/devlow-bench.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ const nextDevWorkflow =
482482
const cacheLocation = join(
483483
benchmarkDir,
484484
'.next',
485+
'dev',
485486
'cache',
486487
'webpack',
487488
'client-development'
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
/**
22
* @type {import('next').NextConfig}
33
*/
4-
const nextConfig = {
5-
experimental: {
6-
isolatedDevBuild: true,
7-
},
8-
}
4+
const nextConfig = {}
95

106
module.exports = nextConfig

test/integration/dist-dir/test/index.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ describe('distDir', () => {
6868

6969
it('should build the app within the given `dist` directory', async () => {
7070
// In isolated dev build, the distDir for development is `distDir/dev`
71-
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
72-
expect(
73-
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
74-
).toBeTruthy()
75-
} else {
76-
expect(
77-
await fs.exists(join(__dirname, `/../dist/${BUILD_MANIFEST}`))
78-
).toBeTruthy()
79-
}
71+
expect(
72+
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
73+
).toBeTruthy()
8074
})
8175
it('should not build the app within the default `.next` directory', async () => {
8276
expect(

test/integration/module-ids/test/index.test.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
launchApp,
99
nextBuild,
1010
renderViaHTTP,
11+
getDistDir,
1112
} from 'next-test-utils'
1213

1314
const appDir = join(__dirname, '../')
14-
15+
const originalIsNextDev = global.isNextDev
1516
let appPort
1617
let app
1718

@@ -23,9 +24,11 @@ describe('minified module ids', () => {
2324
let staticBundles = ''
2425

2526
beforeAll(async () => {
27+
// getDistDir depends on global.isNextDev
28+
global.isNextDev = false
2629
await nextBuild(appDir, [])
2730

28-
const ssrPath = join(appDir, '.next/server/chunks/ssr/')
31+
const ssrPath = join(appDir, `${getDistDir()}/server/chunks/ssr/`)
2932
const ssrBundleBasenames = (await fs.readdir(ssrPath)).filter((p) =>
3033
p.match(/\.js$/)
3134
)
@@ -34,7 +37,7 @@ describe('minified module ids', () => {
3437
ssrBundles += output
3538
}
3639

37-
const staticPath = join(appDir, '.next/static/chunks/')
40+
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
3841
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
3942
p.match(/\.js$/)
4043
)
@@ -43,6 +46,9 @@ describe('minified module ids', () => {
4346
staticBundles += output
4447
}
4548
})
49+
afterAll(() => {
50+
global.isNextDev = originalIsNextDev
51+
})
4652

4753
it('should have no long module ids for basic modules', async () => {
4854
expect(ssrBundles).not.toContain('module-with-long-name')
@@ -72,12 +78,14 @@ describe('minified module ids', () => {
7278
let staticBundles = ''
7379

7480
beforeAll(async () => {
81+
// getDistDir depends on global.isNextDev
82+
global.isNextDev = true
7583
appPort = await findPort()
7684
app = await launchApp(appDir, appPort)
7785

7886
await renderViaHTTP(appPort, '/')
7987

80-
const ssrPath = join(appDir, '.next/server/chunks/ssr/')
88+
const ssrPath = join(appDir, `${getDistDir()}/server/chunks/ssr/`)
8189
const ssrBundleBasenames = (await fs.readdir(ssrPath)).filter((p) =>
8290
p.match(/\.js$/)
8391
)
@@ -86,7 +94,7 @@ describe('minified module ids', () => {
8694
ssrBundles += output
8795
}
8896

89-
const staticPath = join(appDir, '.next/static/chunks/')
97+
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
9098
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
9199
p.match(/\.js$/)
92100
)
@@ -95,7 +103,10 @@ describe('minified module ids', () => {
95103
staticBundles += output
96104
}
97105
})
98-
afterAll(() => killApp(app))
106+
afterAll(() => {
107+
global.isNextDev = originalIsNextDev
108+
killApp(app)
109+
})
99110

100111
it('should have long module ids for basic modules', async () => {
101112
expect(ssrBundles).toContain('module-with-long-name')

test/integration/telemetry/test/config.test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,59 @@ describe('config telemetry', () => {
836836
)
837837
}
838838
})
839+
840+
it('emits telemetry for isolatedDevBuild enabled by default', async () => {
841+
let stderr
842+
try {
843+
const app = await nextBuild(appDir, [], {
844+
stderr: true,
845+
env: { NEXT_TELEMETRY_DEBUG: 1 },
846+
})
847+
stderr = app.stderr
848+
849+
const featureUsageEvents = findAllTelemetryEvents(
850+
stderr,
851+
'NEXT_BUILD_FEATURE_USAGE'
852+
)
853+
expect(featureUsageEvents).toContainEqual({
854+
featureName: 'experimental/isolatedDevBuild',
855+
invocationCount: 1,
856+
})
857+
} catch (err) {
858+
require('console').error('failing stderr', stderr, err)
859+
throw err
860+
}
861+
})
862+
863+
it('emits telemetry for isolatedDevBuild disabled', async () => {
864+
await fs.writeFile(
865+
path.join(appDir, 'next.config.js'),
866+
`module.exports = { experimental: { isolatedDevBuild: false } }`
867+
)
868+
869+
let stderr
870+
try {
871+
const app = await nextBuild(appDir, [], {
872+
stderr: true,
873+
env: { NEXT_TELEMETRY_DEBUG: 1 },
874+
})
875+
stderr = app.stderr
876+
877+
const featureUsageEvents = findAllTelemetryEvents(
878+
stderr,
879+
'NEXT_BUILD_FEATURE_USAGE'
880+
)
881+
expect(featureUsageEvents).toContainEqual({
882+
featureName: 'experimental/isolatedDevBuild',
883+
invocationCount: 0,
884+
})
885+
} catch (err) {
886+
require('console').error('failing stderr', stderr, err)
887+
throw err
888+
} finally {
889+
await fs.remove(path.join(appDir, 'next.config.js'))
890+
}
891+
})
839892
}
840893
)
841894
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)