-
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.
feat(rspack): non-inferred targets should work OOTB (#29733)
- Loading branch information
1 parent
d601561
commit 21a1f4e
Showing
3 changed files
with
83 additions
and
38 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,60 @@ | ||
import { | ||
checkFilesExist, | ||
cleanupProject, | ||
killPorts, | ||
newProject, | ||
readFile, | ||
runCLI, | ||
runE2ETests, | ||
uniq, | ||
updateFile, | ||
} from '@nx/e2e/utils'; | ||
|
||
describe('Build React applications and libraries with Rspack', () => { | ||
let proj: string; | ||
beforeAll(() => { | ||
proj = newProject({ | ||
packages: ['@nx/react'], | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
cleanupProject(); | ||
}); | ||
|
||
it('should be able to use Rspack to build and test apps', async () => { | ||
const appName = uniq('app'); | ||
const libName = uniq('lib'); | ||
|
||
runCLI( | ||
`generate @nx/react:app ${appName} --bundler=rspack --unit-test-runner=vitest --no-interactive --skipFormat --linter=eslint` | ||
); | ||
runCLI( | ||
`generate @nx/react:lib ${libName} --bundler=none --no-interactive --unit-test-runner=vitest --skipFormat --linter=eslint` | ||
); | ||
|
||
// Library generated with Vite | ||
checkFilesExist(`${libName}/vite.config.ts`); | ||
|
||
const mainPath = `${appName}/src/main.tsx`; | ||
updateFile( | ||
mainPath, | ||
` | ||
import '@${proj}/${libName}'; | ||
${readFile(mainPath)} | ||
` | ||
); | ||
|
||
runCLI(`build ${appName}`, { verbose: true }); | ||
|
||
checkFilesExist(`dist/${appName}/index.html`); | ||
|
||
if (runE2ETests()) { | ||
const e2eResults = runCLI(`e2e ${appName}-e2e`, { | ||
verbose: true, | ||
}); | ||
expect(e2eResults).toContain('Successfully ran target e2e for project'); | ||
expect(await killPorts()).toBeTruthy(); | ||
} | ||
}, 250_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