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
7 changes: 1 addition & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -542,9 +542,7 @@ jobs:
uses: ./.github/workflows/build_reusable.yml
with:
nodeVersion: ${{ matrix.node }}
afterBuild: |
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true
node run-tests.js --type unit
afterBuild: node run-tests.js --type unit
stepName: 'test-unit-${{ matrix.node }}'

secrets: inherit
Expand Down Expand Up @@ -735,7 +733,6 @@ jobs:
export IS_WEBPACK_TEST=1
export NEXT_TEST_MODE=dev
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true

node run-tests.js \
--timings \
Expand Down Expand Up @@ -849,7 +846,6 @@ jobs:
export IS_WEBPACK_TEST=1
export NEXT_TEST_MODE=start
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true

node run-tests.js --timings -g ${{ matrix.group }} --type production
stepName: 'test-prod-react-${{ matrix.react }}-${{ matrix.group }}'
Expand Down Expand Up @@ -889,7 +885,6 @@ jobs:
afterBuild: |
export IS_WEBPACK_TEST=1
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
export __NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD=true

node run-tests.js \
--timings \
Expand Down
4 changes: 4 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,10 @@ export default async function build(
featureName: 'experimental/ppr',
invocationCount: config.experimental.ppr ? 1 : 0,
},
{
featureName: 'experimental/isolatedDevBuild',
invocationCount: config.experimental.isolatedDevBuild ? 1 : 0,
},
{
featureName: 'turbopackFileSystemCache',
invocationCount: isFileSystemCacheEnabledForBuild(config) ? 1 : 0,
Expand Down
3 changes: 1 addition & 2 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1525,9 +1525,8 @@ export const defaultConfig = Object.freeze({
slowModuleDetection: undefined,
globalNotFound: false,
browserDebugInfoInTerminal: false,
isolatedDevBuild:
process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true',
lockDistDir: true,
isolatedDevBuild: true,
},
htmlLimitedBots: undefined,
bundlePagesRouterDependencies: false,
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/telemetry/events/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export type EventBuildFeatureUsage = {
| 'experimental/cacheComponents'
| 'experimental/optimizeCss'
| 'experimental/ppr'
| 'experimental/isolatedDevBuild'
| 'swcLoader'
| 'swcRelay'
| 'swcStyledComponents'
Expand Down
1 change: 1 addition & 0 deletions scripts/devlow-bench.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ const nextDevWorkflow =
const cacheLocation = join(
benchmarkDir,
'.next',
'dev',
'cache',
'webpack',
'client-development'
Expand Down
6 changes: 1 addition & 5 deletions test/development/app-dir/isolated-dev-build/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: {
isolatedDevBuild: true,
},
}
const nextConfig = {}

module.exports = nextConfig
12 changes: 3 additions & 9 deletions test/integration/dist-dir/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,9 @@ describe('distDir', () => {

it('should build the app within the given `dist` directory', async () => {
// In isolated dev build, the distDir for development is `distDir/dev`
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
expect(
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
).toBeTruthy()
} else {
expect(
await fs.exists(join(__dirname, `/../dist/${BUILD_MANIFEST}`))
).toBeTruthy()
}
expect(
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
).toBeTruthy()
})
it('should not build the app within the default `.next` directory', async () => {
expect(
Expand Down
23 changes: 17 additions & 6 deletions test/integration/module-ids/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {
launchApp,
nextBuild,
renderViaHTTP,
getDistDir,
} from 'next-test-utils'

const appDir = join(__dirname, '../')

const originalIsNextDev = global.isNextDev
let appPort
let app

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

beforeAll(async () => {
// getDistDir depends on global.isNextDev
global.isNextDev = false
await nextBuild(appDir, [])

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

const staticPath = join(appDir, '.next/static/chunks/')
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
p.match(/\.js$/)
)
Expand All @@ -43,6 +46,9 @@ describe('minified module ids', () => {
staticBundles += output
}
})
afterAll(() => {
global.isNextDev = originalIsNextDev
})

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

beforeAll(async () => {
// getDistDir depends on global.isNextDev
global.isNextDev = true
appPort = await findPort()
app = await launchApp(appDir, appPort)

await renderViaHTTP(appPort, '/')

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

const staticPath = join(appDir, '.next/static/chunks/')
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
p.match(/\.js$/)
)
Expand All @@ -95,7 +103,10 @@ describe('minified module ids', () => {
staticBundles += output
}
})
afterAll(() => killApp(app))
afterAll(() => {
global.isNextDev = originalIsNextDev
killApp(app)
})

it('should have long module ids for basic modules', async () => {
expect(ssrBundles).toContain('module-with-long-name')
Expand Down
53 changes: 53 additions & 0 deletions test/integration/telemetry/test/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,59 @@ describe('config telemetry', () => {
)
}
})

it('emits telemetry for isolatedDevBuild enabled by default', async () => {
let stderr
try {
const app = await nextBuild(appDir, [], {
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
stderr = app.stderr

const featureUsageEvents = findAllTelemetryEvents(
stderr,
'NEXT_BUILD_FEATURE_USAGE'
)
expect(featureUsageEvents).toContainEqual({
featureName: 'experimental/isolatedDevBuild',
invocationCount: 1,
})
} catch (err) {
require('console').error('failing stderr', stderr, err)
throw err
}
})

it('emits telemetry for isolatedDevBuild disabled', async () => {
await fs.writeFile(
path.join(appDir, 'next.config.js'),
`module.exports = { experimental: { isolatedDevBuild: false } }`
)

let stderr
try {
const app = await nextBuild(appDir, [], {
stderr: true,
env: { NEXT_TELEMETRY_DEBUG: 1 },
})
stderr = app.stderr

const featureUsageEvents = findAllTelemetryEvents(
stderr,
'NEXT_BUILD_FEATURE_USAGE'
)
expect(featureUsageEvents).toContainEqual({
featureName: 'experimental/isolatedDevBuild',
invocationCount: 0,
})
} catch (err) {
require('console').error('failing stderr', stderr, err)
throw err
} finally {
await fs.remove(path.join(appDir, 'next.config.js'))
}
})
}
)
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
import "./.next/dev/types/routes.d.ts";

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ const appDir = join(__dirname, '..')
const appTypeDeclarations = join(appDir, 'next-env.d.ts')

describe('TypeScript App Type Declarations', () => {
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
it.skip('should skip on isolated dev build', () => {
// We use static fixture "next-env.d.ts" but the content should differ
// based on the isolated dev build flag. We can't do something like
// "next-env-dev.d.ts" because Next.js Types Plugin emits a file
// "next-env.d.ts", and we have to change its behavior for this test case.
// Rather than that, just skip the test as we're going to remove this flag soon.
// Then modify the content to be ".next/dev/types/routes.d.ts"
})
return
}

it('should write a new next-env.d.ts if none exist', async () => {
const prevContent = await fs.readFile(appTypeDeclarations, 'utf8')
try {
Expand Down
4 changes: 1 addition & 3 deletions test/lib/next-test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1893,9 +1893,7 @@ export function normalizeManifest<T>(
export function getDistDir(): '.next' | '.next/dev' {
// global.isNextDev is set in e2e/development/production tests.
// NEXT_TEST_MODE is set in CI or local test-* commands.
return ((global as any).isNextDev || process.env.NEXT_TEST_MODE === 'dev') &&
// Flag for incremental rollout of isolated dev build, set in CI.
process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true'
return (global as any).isNextDev || process.env.NEXT_TEST_MODE === 'dev'
? '.next/dev'
: '.next'
}
7 changes: 1 addition & 6 deletions test/unit/isolated/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ describe('config', () => {

it('Should assign object defaults deeply to user config', async () => {
const config = await loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfigFn)
// In isolatedDevBuild, the default distDir is ".next/dev" during PHASE_DEVELOPMENT_SERVER.
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
expect(config.distDir).toEqual('.next/dev')
} else {
expect(config.distDir).toEqual('.next')
}
expect(config.distDir.replace(/\\/g, '/')).toEqual('.next/dev')
expect(config.onDemandEntries.maxInactiveAge).toBeDefined()
})

Expand Down
Loading