Closed PaulRBerg closed 1 year ago
@PaulRBerg the nextjs
branch is quite old , the latest NextJS example is under apps/nextjs.
Every example in apps/*
uses path aliases to load dependencies from the monorepo source code, instead of from build artifacts, both when building and when running e.g. dev servers. This doesn't rely on node_modules
symlinks, but on TypeScript's resolution mechanisms, and makes "Go to definition" work as expected.
Examples in packages/*
do use node_modules
symlinks to build artifacts, but only when building. See also https://github.com/NiGhTTraX/ts-monorepo/tree/1ee87c100a3bd65ebae4eb000c76354532f70c09#packages-vs-apps.
I was looking at the
nextjs
branch, specifically at thetsconfig.json
file inpackages/nextjs
:https://github.com/NiGhTTraX/ts-monorepo/blob/0ad8608a368042a7e3b45aece446c667d5087637/packages/nextjs/tsconfig.json#L11-L14
And I'm trying to understand why you have remapped
foo
tofoo/src
, andcomponents
tocomponents/src
. Shouldn't these packages be built and loaded fromdist
? Or did you have to do this because Next.js doesn't support TypeScript project references?I also don't understand how the external dependencies of
foo
andcomponents
are resolved when building the Next.js app. Does this rely uponnode_modules
being hoisted at the root?Side note: would you like to enable GitHub Discussions in this repository? I would have created a discussion instead of a repo.