Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep correct paths for build output even when build is invoked outside of repo root #6589

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

liamdon
Copy link
Contributor

@liamdon liamdon commented May 22, 2024

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.

Copy link

vercel bot commented May 22, 2024

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

@kpal81xd
Copy link
Contributor

@liamdon how are you building the engine? Because you can use npm run <cmd> --prefix <dir> to run a script referencing a particular path

@kpal81xd kpal81xd merged commit 1111e1f into playcanvas:main Jul 17, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants