-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
351 additions
and
52 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react' | ||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/monorepo-package-rsc/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { text } from 'my-package/typescript.ts' | ||
|
||
export default function Page() { | ||
return <p>{text}</p> | ||
} |
7 changes: 7 additions & 0 deletions
7
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/monorepo-package-ssr/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use client' | ||
|
||
import { text } from 'my-package/typescript.ts' | ||
|
||
export default function Page() { | ||
return <p>{text}</p> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>hello world</p> | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/separate-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
throw new Error('Expected error') |
18 changes: 18 additions & 0 deletions
18
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/source-maps-client/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
|
||
export default function Page() { | ||
useEffect(function effectCallback() { | ||
innerFunction() | ||
}) | ||
return <p>Hello Source Maps</p> | ||
} | ||
|
||
function innerFunction() { | ||
innerArrowFunction() | ||
} | ||
|
||
const innerArrowFunction = () => { | ||
require('../separate-file') | ||
} |
11 changes: 11 additions & 0 deletions
11
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/source-maps-rsc/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default async function Page({ searchParams }) { | ||
innerFunction() | ||
} | ||
|
||
function innerFunction() { | ||
innerArrowFunction() | ||
} | ||
|
||
const innerArrowFunction = () => { | ||
require('../separate-file') | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/non-root-project-monorepo/apps/web/app/source-maps-ssr/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use client' | ||
|
||
export default function Page() { | ||
innerFunction() | ||
} | ||
|
||
function innerFunction() { | ||
innerArrowFunction() | ||
} | ||
|
||
const innerArrowFunction = () => { | ||
require('../separate-file') | ||
} |
6 changes: 6 additions & 0 deletions
6
test/e2e/app-dir/non-root-project-monorepo/apps/web/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = {} | ||
|
||
module.exports = nextConfig |
12 changes: 12 additions & 0 deletions
12
test/e2e/app-dir/non-root-project-monorepo/apps/web/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "web", | ||
"version": "0.0.0", | ||
"dependencies": { | ||
"my-package": "workspace:*" | ||
}, | ||
"scripts": { | ||
"dev": "next dev", | ||
"start": "next start", | ||
"build": "next build" | ||
} | ||
} |
223 changes: 223 additions & 0 deletions
223
test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
import { nextTestSetup, FileRef } from 'e2e-utils' | ||
import { | ||
assertHasRedbox, | ||
assertNoRedbox, | ||
getRedboxCallStack, | ||
getRedboxSource, | ||
} from 'next-test-utils' | ||
import * as path from 'path' | ||
|
||
describe('non-root-project-monorepo', () => { | ||
const { next, skipped, isTurbopack, isNextDev } = nextTestSetup({ | ||
files: { | ||
apps: new FileRef(path.resolve(__dirname, 'apps')), | ||
packages: new FileRef(path.resolve(__dirname, 'packages')), | ||
'pnpm-workspace.yaml': `packages: | ||
- 'apps/*' | ||
- 'packages/*' | ||
`, | ||
}, | ||
packageJson: require('./package.json'), | ||
buildCommand: 'pnpm build', | ||
startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start', | ||
installCommand: 'pnpm i', | ||
skipDeployment: true, | ||
}) | ||
|
||
if (skipped) { | ||
return | ||
} | ||
|
||
describe('monorepo-package', () => { | ||
it('should work during RSC', async () => { | ||
const $ = await next.render$('/monorepo-package-rsc') | ||
expect($('p').text()).toBe('Hello Typescript') | ||
}) | ||
|
||
it('should work during SSR', async () => { | ||
const $ = await next.render$('/monorepo-package-ssr') | ||
expect($('p').text()).toBe('Hello Typescript') | ||
}) | ||
|
||
it('should work on client-side', async () => { | ||
const browser = await next.browser('/monorepo-package-ssr') | ||
expect(await browser.elementByCss('p').text()).toBe('Hello Typescript') | ||
await assertNoRedbox(browser) | ||
expect(await browser.elementByCss('p').text()).toBe('Hello Typescript') | ||
await browser.close() | ||
}) | ||
}) | ||
|
||
if (isNextDev) { | ||
describe('source-maps', () => { | ||
function normalizeStackTrace(stack: string): string { | ||
const isolatedPath = /file:\/\/.*\/next-install-[^/]+\//g | ||
const nonIsolatedPath = | ||
/file:\/\/.*\/test\/e2e\/app-dir\/non-root-project-monorepo\//g | ||
return stack | ||
.replaceAll(nonIsolatedPath, 'file://<full-path>/') | ||
.replaceAll(isolatedPath, 'file://<full-path>/') | ||
} | ||
|
||
it('should work on RSC', async () => { | ||
const browser = await next.browser('/source-maps-rsc') | ||
await assertHasRedbox(browser) | ||
|
||
if (isTurbopack) { | ||
// TODO the function name should be hidden | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"./app/source-maps-rsc/page.tsx (9:28) @ innerArrowFunction | ||
7 | } | ||
8 | | ||
> 9 | const innerArrowFunction = () => { | ||
| ^ | ||
10 | require('../separate-file') | ||
11 | } | ||
12 |" | ||
`) | ||
// TODO stacktrace-parser breaks in some cases with the rsc:// protocol | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"<unknown> | ||
[project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript) (rsc://React/Server/file://<full-path>/apps/web/.next/server/chunks/ssr/apps_web_8d1c0a._.js (7:7) | ||
innerFunction | ||
./app/source-maps-rsc/page.tsx (6:3) | ||
Page | ||
./app/source-maps-rsc/page.tsx (2:3)" | ||
`) | ||
} else { | ||
// TODO the function name is incorrect | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"app/separate-file.ts (1:11) @ Error | ||
> 1 | throw new Error('Expected error') | ||
| ^ | ||
2 |" | ||
`) | ||
// TODO webpack runtime code shouldn't be included in stack trace | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"<unknown> | ||
rsc)/./app/separate-file.ts (rsc://React/Server/file://<full-path>/apps/web/.next/server/app/source-maps-rsc/page.js | ||
__webpack_require__ | ||
file://<full-path>/apps/web/.next/server/webpack-runtime.js | ||
require | ||
app/source-maps-rsc/page.tsx (10:3) | ||
innerArrowFunction | ||
app/source-maps-rsc/page.tsx (6:3) | ||
innerFunction | ||
app/source-maps-rsc/page.tsx (2:3)" | ||
`) | ||
} | ||
await browser.close() | ||
}) | ||
|
||
it('should work on SSR', async () => { | ||
const browser = await next.browser('/source-maps-ssr') | ||
await assertHasRedbox(browser) | ||
|
||
if (isTurbopack) { | ||
// TODO the function name should be hidden | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"./app/separate-file.ts (1:7) @ [project]/apps/web/app/separate-file.ts [app-client] (ecmascript) | ||
> 1 | throw new Error('Expected error') | ||
| ^ | ||
2 |" | ||
`) | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"innerArrowFunction | ||
./app/source-maps-ssr/page.tsx (11:28) | ||
innerFunction | ||
./app/source-maps-ssr/page.tsx (8:3) | ||
Page | ||
./app/source-maps-ssr/page.tsx (4:3)" | ||
`) | ||
} else { | ||
// TODO the function name should be hidden | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"app/separate-file.ts (1:7) @ eval | ||
> 1 | throw new Error('Expected error') | ||
| ^ | ||
2 |" | ||
`) | ||
// TODO webpack runtime code shouldn't be included in stack trace | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"./app/separate-file.ts | ||
file://<full-path>/apps/web/.next/static/chunks/app/source-maps-ssr/page.js (27:1) | ||
options.factory | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (700:31) | ||
__webpack_require__ | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (37:33) | ||
fn | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (357:21) | ||
require | ||
app/source-maps-ssr/page.tsx (12:3) | ||
innerArrowFunction | ||
app/source-maps-ssr/page.tsx (8:3) | ||
innerFunction | ||
app/source-maps-ssr/page.tsx (4:3)" | ||
`) | ||
} | ||
await browser.close() | ||
}) | ||
|
||
it('should work on client-side', async () => { | ||
const browser = await next.browser('/source-maps-client') | ||
await assertHasRedbox(browser) | ||
|
||
if (isTurbopack) { | ||
// TODO the function name should be hidden | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"./app/separate-file.ts (1:7) @ [project]/apps/web/app/separate-file.ts [app-client] (ecmascript) | ||
> 1 | throw new Error('Expected error') | ||
| ^ | ||
2 |" | ||
`) | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"innerArrowFunction | ||
./app/source-maps-client/page.tsx (16:28) | ||
innerFunction | ||
./app/source-maps-client/page.tsx (13:3) | ||
effectCallback | ||
./app/source-maps-client/page.tsx (7:5)" | ||
`) | ||
} else { | ||
// TODO the function name should be hidden | ||
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` | ||
"app/separate-file.ts (1:7) @ eval | ||
> 1 | throw new Error('Expected error') | ||
| ^ | ||
2 |" | ||
`) | ||
// TODO webpack runtime code shouldn't be included in stack trace | ||
expect(normalizeStackTrace(await getRedboxCallStack(browser))) | ||
.toMatchInlineSnapshot(` | ||
"./app/separate-file.ts | ||
file://<full-path>/apps/web/.next/static/chunks/app/source-maps-client/page.js (27:1) | ||
options.factory | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (712:31) | ||
__webpack_require__ | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (37:33) | ||
fn | ||
file://<full-path>/apps/web/.next/static/chunks/webpack.js (369:21) | ||
require | ||
app/source-maps-client/page.tsx (17:3) | ||
innerArrowFunction | ||
app/source-maps-client/page.tsx (13:3) | ||
innerFunction | ||
app/source-maps-client/page.tsx (7:5)" | ||
`) | ||
} | ||
await browser.close() | ||
}) | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "monorepo-root", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "pnpm i && pnpm run --dir apps/web build", | ||
"start": "pnpm run --dir apps/web start", | ||
"dev": "pnpm i && pnpm run --dir apps/web dev" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
test/e2e/app-dir/non-root-project-monorepo/packages/my-package/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "my-package", | ||
"version": "0.0.0" | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/app-dir/non-root-project-monorepo/packages/my-package/typescript.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const text: string = 'Hello Typescript' |
Oops, something went wrong.