I’m developing a library for Babylon.js and currently maintaining two separate repositories:
- Repository #1: Uses scoped packages (
@babylonjs/core
, etc.) for ES6 modules, deployed to NPM. - Repository #2: Uses non-scoped packages (
babylonjs
, etc.) for NPM and also produces a UMD/CDN-hosted version.
This dual repository maintenance is becoming cumbersome. I’d like to know if there’s a recommended approach for developing a library that works with all these distribution methods, ideally from a single codebase.
Questions:
- Is there a recommended pattern for library authors to support both package types and CDN distribution?
- Could I use build-time configuration or conditional imports to target all three versions? (not sure this would work with
peerDependencies
) - Are there any existing libraries that handle this well that I could reference?
- Is it advisable to focus on just one version (ES6) and provide migration instructions for UMD users?
Any guidance would be appreciated
Edit:
Looking through the babylon repo, looks like this may be a part of the puzzle Babylon.js/packages/dev/buildTools/src/packageMapping.ts at master · BabylonJS/Babylon.js · GitHub