dasari4kntr Posted February 27, 2023 Report Share Posted February 27, 2023 nx monorepo setup vundi... i am using vscode...and installed jest, jestrunner plugins...(normally these plugins setup is pretty straight forward..in normal react applications..) but how do you setup for monorepos..? most importantly...how do you setup debug for monorepo...is it same old launch.json or NX give any special command for that.... Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 @ramudu did you try this before..? Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 @sri_india @Spartan @csrcsr @LadiesTailor...? Quote Link to comment Share on other sites More sharing options...
Anta Assamey Posted February 27, 2023 Report Share Posted February 27, 2023 Ante ento kuda naaku teliyadu... so someone Quote Link to comment Share on other sites More sharing options...
Anta Assamey Posted February 27, 2023 Report Share Posted February 27, 2023 Setting up a monorepo can vary depending on the tools and frameworks you are using. However, some general steps can help you set up a monorepo: Choose a package manager: Select a package manager like npm, Yarn, or pnpm, that can manage dependencies across multiple packages. Define the structure of your monorepo: Decide on the directory structure and naming conventions for packages in your monorepo. Some popular structures include Lerna, Yarn Workspaces, and Nx. Create packages: Create packages within your monorepo that contain code for different parts of your application. You can create packages for libraries, services, and UI components. Set up cross-dependencies: Configure dependencies between packages in your monorepo so that they can communicate with each other. For example, a library package may be used by a service package. Configure build and test scripts: Configure build and test scripts to compile and test all packages in your monorepo. As for debugging in a monorepo, it depends on the tool you are using. If you are using VS Code and the Nx workspace, you can use the same old launch.json to debug your applications. However, you will need to specify the name of the project you want to debug in the "program" field of the launch configuration. For example, if you have an Angular application called "my-app" in your Nx workspace, you can set up a launch configuration like this: { "version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Debug my-app", "url": "http://localhost:4200", "webRoot": "${workspaceFolder}/apps/my-app", "sourceMaps": true, "sourceMapPathOverrides": { "webpack:///*": "${webRoot}/*" } } ] } If you have multiple applications in your monorepo, you can create separate launch configurations for each of them. You can also use the Nx CLI to run and debug your applications using the nx run command. For example, to run the "my-app" application in debug mode, you can use the following command: nx run my-app:serve --configuration=debug This will start the application in debug mode, and you can attach the VS Code debugger to it using the launch configuration. 1 Quote Link to comment Share on other sites More sharing options...
Spartan Posted February 27, 2023 Report Share Posted February 27, 2023 @dasari4kntr same root repo package.json lo ne set chesam script using Lerna Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 24 minutes ago, Spartan said: @dasari4kntr same root repo package.json lo ne set chesam script using Lerna yea..that basic setup is there.. but nx has its own commands...just checking..is there any additional configuration needed with NX... Quote Link to comment Share on other sites More sharing options...
Spartan Posted February 27, 2023 Report Share Posted February 27, 2023 20 minutes ago, dasari4kntr said: yea..that basic setup is there.. but nx has its own commands...just checking..is there any additional configuration needed with NX... i dont think so..it should be same basic setup. Quote Link to comment Share on other sites More sharing options...
LadiesTailor Posted February 27, 2023 Report Share Posted February 27, 2023 1 hour ago, dasari4kntr said: @sri_india @Spartan @csrcsr @LadiesTailor...? Sorry baaa never used it Quote Link to comment Share on other sites More sharing options...
Spartan Posted February 27, 2023 Report Share Posted February 27, 2023 @dasari4kntr if you havent already seen this. https://github.com/nrwl/nx-examples Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 3 minutes ago, Spartan said: @dasari4kntr if you havent already seen this. https://github.com/nrwl/nx-examples yes..i seen this...these commands are good to run in console...and also its very difficult to run the single unit test or debug..we have to run all the unit tests... instead i am trying to configure those commands to run in vscode plugins... see the below screenshot... (this setup is working somehow in my personal MAC...but same setup is giving trouble in office work..) left side gives you list of unit tests... and every unit test will have run and debug...option to run the individual test.. Quote Link to comment Share on other sites More sharing options...
Spartan Posted February 27, 2023 Report Share Posted February 27, 2023 2 minutes ago, dasari4kntr said: yes..i seen this...these commands are good to run in console...and also its very difficult to run the single unit test or debug..we have to run all the unit tests... instead i am trying to configure those commands to run in vscode plugins... see the below screenshot... (this setup is working somehow in my personal MAC...but same setup is giving trouble in office work..) left side gives you list of unit tests... and every unit test will have run and debug...option to run the individual test.. individual ga particular unittest teliyadu kaani.. you can try to run the unit-test related to one particular component of that monorepo. something like `jest comp1` or `jest comp2` and define them in package.json Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 7 minutes ago, Spartan said: individual ga particular unittest teliyadu kaani.. you can try to run the unit-test related to one particular component of that monorepo. something like `jest comp1` or `jest comp2` and define them in package.json yes.."nx test comp1" "nx test comp2"..etc vunnayi...options..thats how we are doing it... but the problem with that is...once your testcases grow...like houndreds...once you write a new test case...you need to waiting all tests to finish...to test your new unit test... generally this can be handled easily in normal react projects... but for monorepo with nx...its bit tricky... anduke checking...if anyone already done this or not ani... Quote Link to comment Share on other sites More sharing options...
Spartan Posted February 27, 2023 Report Share Posted February 27, 2023 19 minutes ago, dasari4kntr said: yes.."nx test comp1" "nx test comp2"..etc vunnayi...options..thats how we are doing it... but the problem with that is...once your testcases grow...like houndreds...once you write a new test case...you need to waiting all tests to finish...to test your new unit test... generally this can be handled easily in normal react projects... but for monorepo with nx...its bit tricky... anduke checking...if anyone already done this or not ani... I dont think it will be specific to NX, it would be jest feature. did u explore `jest -t` flag.? Quote Link to comment Share on other sites More sharing options...
dasari4kntr Posted February 27, 2023 Author Report Share Posted February 27, 2023 12 hours ago, Spartan said: I dont think it will be specific to NX, it would be jest feature. did u explore `jest -t` flag.? nx test configurations are like this... "test": { "executor": "@nrwl/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { "jestConfig": "packages/frontend/jest.config.ts", "passWithNoTests": true }, "configurations": { "ci": { "ci": true, "codeCoverage": true } } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.