CodePlay Common
raw JSON → 3.2.19 verified Fri May 01 auth: no javascript
CodePlay Common is a set of build scripts and shared configuration files for Capacitor-based mobile apps. Version 3.2.19 simplifies common tasks like splash screen animation, automatic AdMob ID extraction from capacitor.config.json, and generating build variants for multiple app stores. It installs In-App Purchase plugins conditionally based on the target store. The package is intended to reduce boilerplate and manual setup by 40% for multi-app projects. It integrates with Ionic and Capacitor workflows, targeting developers who maintain multiple apps with shared build logic. The package is actively maintained on GitHub by merbin2012, though full source requires donation.
Common errors
error Error: Cannot find module 'codeplay-common' ↓
cause Package not installed or ESM import used in CommonJS project
fix
Run 'npm install codeplay-common' and ensure project is configured for ESM (type: module in package.json or use .mjs extension)
error TypeError: codeplayCommon is not a function ↓
cause Incorrect import — default import used when named import was expected
fix
Use 'import codeplayBuild from 'codeplay-common'' for default, or 'import { CodePlayBuild } from 'codeplay-common'' if using named export
error SyntaxError: Unexpected token 'export' ↓
cause ESM syntax used without proper configuration or transpilation
fix
Add 'type': 'module' to package.json or transpile with Babel/TypeScript
error Error: Could not find capacitor.config.json ↓
cause Missing configuration file in project root
fix
Create capacitor.config.json with at least {} in the project root directory
Warnings
gotcha Do not import from subpaths; only main entry point is supported. ↓
fix Use 'import codeplayCommon from 'codeplay-common'' instead of 'import ... from 'codeplay-common/dist/...'
deprecated The 'cordova-plugin-iap' dependency is deprecated; migrate to @capacitor/inapppurchases. ↓
fix Replace IAP plugin with @capacitor/inapppurchases and update build config.
breaking Version 3.0 changed the configuration structure — old 'googlePlay' and 'appleStore' keys are now merged into 'stores' array. ↓
fix Use 'stores: ['google', 'apple']' instead of 'googlePlay: true, appleStore: true'
gotcha The package requires capacitor.config.json to exist in the project root; missing file causes silent failure. ↓
fix Ensure capacitor.config.json is present and contains valid JSON.
Install
npm install codeplay-common yarn add codeplay-common pnpm add codeplay-common Imports
- default wrong
const codeplayCommon = require('codeplay-common')correctimport codeplayCommon from 'codeplay-common' - CodePlayBuild wrong
import CodePlayBuild from 'codeplay-common'correctimport { CodePlayBuild } from 'codeplay-common' - SplashConfig wrong
import { SplashConfig } from 'codeplay-common'correctimport type { SplashConfig } from 'codeplay-common'
Quickstart
import codeplayBuild from 'codeplay-common';
const config = {
appName: 'MyApp',
version: '1.0.0',
stores: ['google', 'apple'],
splash: {
backgroundColor: '#ffffff',
animation: 'fade'
}
};
codeplayBuild(config)
.then(() => console.log('Build completed'))
.catch(err => console.error(err));