Skip to content

Adds export conditions #7810

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

Merged
merged 2 commits into from
Jul 1, 2025
Merged

Adds export conditions #7810

merged 2 commits into from
Jul 1, 2025

Conversation

marklundin
Copy link
Member

@marklundin marklundin commented Jul 1, 2025

This PR adds development and profiler export conditions to the package.json.

Libraries the implement the engine cannot easily provide a way for end users to select different engine builds. Given the following use case its not possible to select the dev build:

  1. User imports @playcanvas/react.
  2. User makes a WGSL shader.
  3. User needs better debug information from playcanvas about shader compilation.

This is not a new problem. Node has introduced export conditions (already used for import/require). This allows users to select versions of a lib globally

node --conditions=development index.js 

In addition Modern dev environments (Webpack, Vite, Rollup, Parcel) feed those conditions automatically, meaning that by default in local dev mode you get the development version, and running npm run build will automatically export the production version.

I have kept the original ./debug export paths etc, but unless needed by examples or other tooling these could be removed.

@mvaligursky
Copy link
Contributor

This feels good!

Copy link
Contributor

@kpal81xd kpal81xd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice yea just check it works in other tools like svelte etc I remember us having some import issues there. Keep the old paths in for now I feel like they may be used in the examples not sure tho

@marklundin
Copy link
Member Author

Yep, let's leave them in for now. It's optional step for bundlers, so I expect it won't work in all, but for those that do, it's a better dev experience.

@marklundin marklundin merged commit 4d73613 into main Jul 1, 2025
7 checks passed
@marklundin marklundin deleted the feat-node-conditions branch July 1, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants