Unverified Commit 26ef468d authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test: add monorepo fixture to Turbopack build cache portability test

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 5fc17bbd
'use server'
export async function increment(count) {
return count + 1
}
'use client'
import { useState } from 'react'
import { increment } from './actions'
export function Counter() {
const [count, setCount] = useState(0)
return (
<button onClick={async () => setCount(await increment(count))}>
count {count}
</button>
)
}
import { Counter } from './counter'
export default function ActionPage() {
return <Counter />
}
export function GET() {
return Response.json({ hello: 'world' })
}
export function generateStaticParams() {
return [{ slug: 'first' }, { slug: 'second' }]
}
export default async function BlogPost({ params }) {
const { slug } = await params
return <p>blog post {slug}</p>
}
export default function Root({ children }) {
return (
<html>
<body>{children}</body>
</html>
)
}
import { Button } from '@portable/ui/button'
import { markers } from '../lib/markers'
export default function Page() {
return (
<>
<ul>
{markers.map((marker) => (
<li key={marker}>{marker}</li>
))}
</ul>
<Button />
</>
)
}
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@shared/*": ["../../packages/shared/*"]
}
}
}
import { loaderMarker } from './loaded.marker.js'
import { resolveAliasMarker } from 'resolve-alias-target'
// Resolved through the `paths` alias in `jsconfig.json`, outside of the app.
import { jsconfigPathsMarker } from '@shared/paths-target.js'
// `linked` is a relative symlink to `packages/shared`, created by the test.
import { symlinkMarker } from '../linked/symlink-target.js'
// `node_modules/@portable/ui` is a relative workspace symlink to `packages/ui`.
import { workspaceMarker } from '@portable/ui'
export const markers = [
loaderMarker,
resolveAliasMarker,
jsconfigPathsMarker,
symlinkMarker,
workspaceMarker,
]
// Replaces the placeholder in `*.marker.js` modules, so the build output proves
// that the loader ran.
module.exports = function markerLoader(source) {
return source.replace('__LOADER_PLACEHOLDER__', 'loader-applied')
}
const path = require('path')
// The workspace root (two levels up) is the project root, so that the shared
// packages outside of the app directory are part of the build.
const workspaceRoot = path.join(__dirname, '..', '..')
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
outputFileTracingRoot: workspaceRoot,
transpilePackages: ['@portable/ui'],
turbopack: {
root: workspaceRoot,
resolveAlias: {
'resolve-alias-target': './lib/resolve-alias-target.js',
},
rules: {
'*.marker.js': {
loaders: ['./loaders/marker-loader.js'],
as: '*.js',
},
},
},
}
module.exports = nextConfig
export default function handler(req, res) {
res.status(200).json({ router: 'pages' })
}
export default function LegacyPage() {
return <p>pages router</p>
}
import { NextResponse } from 'next/server'
export function proxy() {
const response = NextResponse.next()
response.headers.set('x-portable-proxy', '1')
return response
}
export const config = {
matcher: '/api/:path*',
}
{
"name": "portable-monorepo",
"version": "1.0.0",
"private": true
}
'use client'
import { useState } from 'react'
export function Button() {
const [clicked, setClicked] = useState(false)
return (
<button onClick={() => setClicked(true)}>
{clicked ? 'clicked' : 'client component'}
</button>
)
}
export const workspaceMarker = 'workspace-package-resolved'
{
"name": "@portable/ui",
"version": "1.0.0",
"private": true,
"exports": {
".": "./index.js",
"./button": "./button.jsx"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment