if i have a nextjs application in a monorepo, located at /packages/web, how do i include…
- User
if i have a nextjs application in a monorepo, located at /packages/web, how do i include a typescript react component from another worspace, /packages/common for example
Assistant
You can import it like this:
import MyComponent from '@common/MyComponent';
- User
when i do that i get the error "Module parse failed: Unexpected token" referring to a type export in my react component file. Is there anything else i need to do to set it up?
Assistant
You’ll need to build the component first. From the /packages/common directory, run npm run build. Then you can import it.
- User
is there a way to do it without a build step in between. I want to be able to change the files in packages/common and have my nextjs app running from packages/web to hot reload
Assistant
Yes, you can use ts-node-dev for development, and it will watch for changes and rebuild on the fly. From the /packages/web directory, run npm install ts-node-dev -D, and then run npm run dev. Then you can make changes to the component and it will be rebuilt automatically. To run the Next.js app in development mode, run respawn next.
- User
what does respawn next do?
Assistant
It will restart the Next.js development server, which will pick up the changes to the component and rebuild it. You can also run npm run build to build the component for production, and then npm run start to run the Next.js app in production mode.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Unspecified NVIDIA model (HelpSteer2)Compare side by side →
Unspecified NVIDIA model (HelpSteer2)Compare side by side →
Unspecified NVIDIA model (HelpSteer2)Compare side by side →
- Unknown modelCompare side by side →
Llama-3.1-Nemotron-70B-InstructCompare side by side →
- Unknown modelCompare side by side →