chokibasic
raw JSON → 1.1.11 verified Fri May 01 auth: no javascript
A minimal build-and-watch utility wrapping chokidar, esbuild, sass, csso, and pxpros for simple static websites. Version 1.1.11 (2025) provides debounced file watchers, SCSS compilation + minification, JS bundling + minification, PHP template rendering via pxpros, sitemap generation, and dist export with .gitignore support. Unlike full-featured bundlers (Vite, Webpack), chokibasic is intentionally low-config and suited for small projects. ESM-only, ships TypeScript definitions, and has no runtime dependencies on the framework level (deps are bundled).
Common errors
error ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/chokibasic/index.mjs not supported. ↓
cause The package uses ES modules (exports .mjs or type: module) and cannot be require()'d in CommonJS.
fix
Use dynamic import: const { createWatchers } = await import('chokibasic'); or convert your project to ESM.
error TypeError: chokibasic.createWatchers is not a function ↓
cause Default import returns undefined because the package only exports named exports.
fix
Use named import: import { createWatchers } from 'chokibasic';
error Error: Cannot find module 'pxpros' ↓
cause pxpros is an optional peer dependency; it must be installed separately for buildPHP and buildSitemap to work.
fix
Run: npm install pxpros
error SyntaxError: Unexpected token 'export' ↓
cause The package is ESM-only, but the consuming environment (e.g., Node.js without type: module) expects CommonJS.
fix
Add "type": "module" to your package.json, or use .mjs extension for your entry file.
Warnings
gotcha createWatchers only watches 'change' events; 'add' and 'unlink' listeners are commented out in source. ↓
fix If you need 'add' or 'unlink' events, you must extend the watcher manually or fork the package.
gotcha Default options for buildCSS include `style: 'compressed'` and no sourcemaps, which may hide debugging information. ↓
fix Pass { sourceMap: true, style: 'expanded' } in options to get sourcemaps and expanded output.
gotcha buildJS defaults to `platform: 'browser'` and `target: ['es2020']` — not suitable for Node.js or older browsers. ↓
fix Override platform and target in options, e.g., { platform: 'node', target: ['node14'] }.
deprecated The `require()` usage shown in older documentation is incompatible with the current ESM-only distribution. ↓
fix Use ESM imports (import { ... } from 'chokibasic') or switch to dynamic import() inside CommonJS.
gotcha buildPHP and buildSitemap require pxpros to be installed and configured separately; no default configuration is provided. ↓
fix Ensure pxpros is installed and configured (e.g., via a pxpros.config.js) before calling these functions.
gotcha exportDist reads .gitignore from project root, but only respects basic patterns; complex negation rules may not work. ↓
fix Test with your .gitignore; consider using a dedicated tool like 'fdir' for more robust copying.
breaking v1.1.0 switched from CommonJS to ESM, breaking all require() usage. ↓
fix Use import statements or set type: module in package.json and use import syntax.
Install
npm install chokibasic yarn add chokibasic pnpm add chokibasic Imports
- createWatchers wrong
const createWatchers = require('chokibasic').createWatcherscorrectimport { createWatchers } from 'chokibasic' - buildCSS wrong
const chokibasic = require('chokibasic'); chokibasic.buildCSS(...)correctimport { buildCSS } from 'chokibasic' - buildJS wrong
import buildJS from 'chokibasic'correctimport { buildJS } from 'chokibasic'
Quickstart
import { createWatchers, buildCSS, buildJS } from 'chokibasic';
const watcher = createWatchers([
{
name: 'css',
patterns: ['src/styles/**/*.scss'],
callback: async (events) => {
console.log('CSS changed:', events);
await buildCSS('src/styles/main.scss', 'dist/app.min.css');
}
},
{
name: 'js',
patterns: ['src/scripts/**/*.js'],
ignored: ['**/*.min.js'],
callback: async (events) => {
console.log('JS changed:', events);
await buildJS('src/scripts/main.js', 'dist/app.min.js');
}
}
], { debug: true });
process.on('SIGINT', async () => {
await watcher.close();
process.exit(0);
});