Keep correct paths for build output even when build is invoked outside of repo root
This fixes a (possibly niche) problem that occurs when PlayCanvas is included in a monorepo with a central build system like turborepo or pnpm workspaces.
The problem: build output paths in the build directory are relative to the cwd of the shell executing the npm script.
Example
If you are using a monorepo-wide runner and have a structure like this:
<root>/packages/vendor/playcanvas
Then the expected output of build/playcanvas/src/index.js instead becomes build/playcanvas/packages/vendor/playcanvas/src/index.js. This causes subsequent build steps to fail.
Solution
To fix the issue above, we find the actual repo root of playcanvas and set this as the base path using the rollup option preserveModulesRoot. Now the output paths are correct regardless of where you run npm run build from.
I confirm I have read the contributing guidelines and signed the Contributor License Agreement.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| engine | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 22, 2024 5:58pm |
@liamdon how are you building the engine? Because you can use npm run <cmd> --prefix <dir> to run a script referencing a particular path