https://github.com/valentinh/poc-next-workspace
POC of a workspace with multiple Next.js app and shared code
https://github.com/valentinh/poc-next-workspace
Last synced: over 1 year ago
JSON representation
POC of a workspace with multiple Next.js app and shared code
- Host: GitHub
- URL: https://github.com/valentinh/poc-next-workspace
- Owner: ValentinH
- Created: 2021-11-29T12:37:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-29T18:46:14.000Z (over 4 years ago)
- Last Synced: 2025-01-30T09:27:39.573Z (over 1 year ago)
- Language: TypeScript
- Size: 67.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# POC of Yarn workspaces with multiple Next.js apps
This POC shows a repository with 2 Next.js applications and one shared "common" module.
This is done using a Yarn workspace.
## Solved issues
### Intellisense / Auto-imports in VSCode
One issue I faced was having auto-import working in VSCode for items in the `common` folder that were not already used
in the `admin` or `worker` apps.
The key for this was to have the tsconfig files inside the Next.js projects not being called "tsconfig.json" so that
they were not loaded by VSCode. By adding the ".app" suffix and telling Next.js to load it via the `next.config.json`,
it's working as I was expecting at first.
### JSX in "common" lib
By default, Next.js does not transpile libraries in the `node_modules`. However, when using a Yarn workspace,
the shared packages are actually imported from `node_modules`. Therefore, JSX or any non ES syntax is not transpiled.
To solve this, we have to use the `next-transpile-modules` plugin to explicitly transpile the "common" lib.