-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nextjs): update workspace libs setup in weback config (#17795)
- Loading branch information
Showing
6 changed files
with
74 additions
and
148 deletions.
There are no files selected for viewing
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,71 @@ | ||
import { | ||
cleanupProject, | ||
newProject, | ||
runCLI, | ||
uniq, | ||
updateFile, | ||
} from '@nx/e2e/utils'; | ||
import { checkApp } from './utils'; | ||
|
||
describe('Next.js Experimental Features', () => { | ||
let proj: string; | ||
|
||
beforeEach(() => { | ||
proj = newProject(); | ||
}); | ||
|
||
afterEach(() => { | ||
cleanupProject(); | ||
}); | ||
|
||
it('should be able to define server actions in workspace libs', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI(`generate @nx/next:app ${appName}`); | ||
runCLI(`generate @nx/next:lib ${libName} --no-interactive`); | ||
|
||
// Update the app to test two scenarios: | ||
// 1. Workspace lib with server actions through 'use server' directive | ||
// 2. Workspace with a client component through 'use client' directive | ||
updateFile( | ||
`libs/${libName}/src/lib/action.ts`, | ||
` | ||
'use server'; | ||
export async function addItem() { | ||
console.log('adding item'); | ||
} | ||
` | ||
); | ||
updateFile( | ||
`libs/${libName}/src/lib/${libName}.tsx`, | ||
` | ||
'use client'; | ||
import { addItem } from './action'; | ||
export function TestComponent() { | ||
return ( | ||
<form action={addItem}> | ||
<button type="submit">Add</button> | ||
</form> | ||
); | ||
}; | ||
` | ||
); | ||
updateFile( | ||
`apps/${appName}/app/page.tsx`, | ||
` | ||
import { TestComponent } from '@proj/${libName}'; | ||
export default function Home() { | ||
return <TestComponent />; | ||
} | ||
` | ||
); | ||
|
||
await checkApp(appName, { | ||
checkUnitTest: false, | ||
checkLint: true, | ||
checkE2E: false, | ||
checkExport: false, | ||
}); | ||
}, 300_000); | ||
}); |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
fdf7555
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app