first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1 @@
!node_modules

View File

@@ -0,0 +1,5 @@
import React from 'react'
export function Hello() {
return <>Hello</>
}

View File

@@ -0,0 +1,5 @@
import React from 'react'
export function World() {
return <>World</>
}

View File

@@ -0,0 +1,11 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@c/*": ["components/*"],
"@lib/*": ["lib/a/*", "lib/b/*"],
"@mycomponent": ["components/hello.js"]
}
},
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}

View File

@@ -0,0 +1,5 @@
import data from 'mypackage/data'
console.log(data)
export default () => 'Hello from a'

View File

@@ -0,0 +1 @@
export default () => 'Hello from b'

View File

@@ -0,0 +1 @@
export default () => 'Hello from only b'

View File

@@ -0,0 +1,6 @@
module.exports = {
onDemandEntries: {
// Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60,
},
}

View File

@@ -0,0 +1,3 @@
module.exports = {
hello: 'world',
}

View File

@@ -0,0 +1,3 @@
module.exports = {
hello: 'world',
}

View File

@@ -0,0 +1,17 @@
import React from 'react'
import { World } from '@c/world'
// prevent static generation
export function getServerSideProps() {
return {
props: {},
}
}
export default function HelloPage() {
return (
<div>
<World />
</div>
)
}

View File

@@ -0,0 +1,13 @@
import React from 'react'
import api from '@lib/b-only'
// prevent static generation
export function getServerSideProps() {
return {
props: {},
}
}
export default function ResolveOrder() {
return <div>{api()}</div>
}

View File

@@ -0,0 +1,13 @@
import React from 'react'
import api from '@lib/api'
// prevent static generation
export function getServerSideProps() {
return {
props: {},
}
}
export default function ResolveOrder() {
return <div>{api()}</div>
}

View File

@@ -0,0 +1,16 @@
import { Hello } from '@mycomponent'
// prevent static generation
export function getServerSideProps() {
return {
props: {},
}
}
export default function SingleAlias() {
return (
<div>
<Hello />
</div>
)
}

View File

@@ -0,0 +1,159 @@
/* eslint-env jest */
import fs from 'fs-extra'
import { join } from 'path'
import cheerio from 'cheerio'
import stripAnsi from 'next/dist/compiled/strip-ansi'
import * as path from 'path'
import {
renderViaHTTP,
findPort,
launchApp,
nextBuild,
killApp,
retry,
File,
} from 'next-test-utils'
import * as JSON5 from 'json5'
const appDir = join(__dirname, '..')
let appPort
let app
async function get$(path, query?: any) {
const html = await renderViaHTTP(appPort, path, query)
return cheerio.load(html)
}
function runTests() {
describe('default behavior', () => {
let output = ''
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
output += msg || ''
},
onStdout(msg) {
output += msg || ''
},
})
})
afterAll(() => killApp(app))
it('should alias components', async () => {
const $ = await get$('/basic-alias')
expect($('body').text()).toMatch(/World/)
})
it('should resolve the first item in the array first', async () => {
const $ = await get$('/resolve-order')
expect($('body').text()).toMatch(/Hello from a/)
})
it('should resolve the second item as fallback', async () => {
const $ = await get$('/resolve-fallback')
expect($('body').text()).toMatch(/Hello from only b/)
})
it('should resolve a single matching alias', async () => {
const $ = await get$('/single-alias')
expect($('body').text()).toMatch(/Hello/)
})
it('should have correct module not found error', async () => {
const basicPage = join(appDir, 'pages/basic-alias.js')
const contents = await fs.readFile(basicPage, 'utf8')
try {
await fs.writeFile(basicPage, contents.replace('@c/world', '@c/worldd'))
await retry(async () => {
await renderViaHTTP(appPort, '/basic-alias')
expect(stripAnsi(output)).toMatch(
/Module not found: Can't resolve '@c\/worldd'/
)
})
} finally {
await fs.writeFile(basicPage, contents)
}
})
})
describe('should build', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
beforeAll(async () => {
await nextBuild(appDir)
})
it('should trace correctly', async () => {
const singleAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/single-alias.js.nft.json')
)
const resolveOrderTrace = await fs.readJSON(
join(appDir, '.next/server/pages/resolve-order.js.nft.json')
)
const resolveFallbackTrace = await fs.readJSON(
join(appDir, '.next/server/pages/resolve-fallback.js.nft.json')
)
const basicAliasTrace = await fs.readJSON(
join(appDir, '.next/server/pages/basic-alias.js.nft.json')
)
expect(
singleAliasTrace.files.some((file) =>
file.includes('components/hello.js')
)
).toBe(false)
expect(
resolveOrderTrace.files.some((file) =>
file.includes('lib/a/api.js')
)
).toBe(false)
expect(
resolveOrderTrace.files.some((file) =>
file.includes('mypackage/data.js')
)
).toBe(true)
expect(
resolveFallbackTrace.files.some((file) =>
file.includes('lib/b/b-only.js')
)
).toBe(false)
expect(
basicAliasTrace.files.some((file) =>
file.includes('components/world.js')
)
).toBe(false)
})
}
)
})
}
describe('jsconfig paths', () => {
runTests()
})
const jsconfig = new File(path.resolve(__dirname, '../jsconfig.json'))
describe('jsconfig paths without baseurl', () => {
beforeAll(() => {
const jsconfigContent = JSON5.parse(jsconfig.originalContent)
delete jsconfigContent.compilerOptions.baseUrl
jsconfigContent.compilerOptions.paths = {
'@c/*': ['./components/*'],
'@lib/*': ['./lib/a/*', './lib/b/*'],
'@mycomponent': ['./components/hello.js'],
}
jsconfig.write(JSON.stringify(jsconfigContent, null, 2))
})
afterAll(() => {
jsconfig.restore()
})
runTests()
})