Baby Tolk

raw JSON →
5.0.2 verified Fri May 01 auth: no javascript

Baby Tolk (v5.0.2) is a promise-based file reader that automatically transpiles non-web assets (e.g., SCSS, Less, CoffeeScript, JSX) into web assets using available transpilers, with optional minification and sourcemaps. Unlike Tolk, it does not inline sourcemaps or autoprefix CSS. It delegates transpiler installation to the consumer, making it lightweight. Supports LiveScript, Babel, CoffeeScript, Less, node-sass, Stylus, and more. Requires manual adapter loading and optional global compiler module path setting. Actively maintained on GitHub.

error Cannot find module 'node-sass'
cause Missing optional transpiler dependency.
fix
Install the module: npm install node-sass
error Cannot read property 'then' of undefined
cause Forgetting to call loadAdapters() before read().
fix
Call babyTolk.loadAdapters() before babyTolk.read().
error TypeError: babyTolk.read is not a function
cause Incorrect import; using default import without require.
fix
Use const babyTolk = require('baby-tolk');
gotcha Transpilers must be installed separately; baby-tolk does not bundle any.
fix Install required transpilers like 'npm install node-sass babel' before using.
gotcha Files starting with underscore (_) are ignored by default.
fix Rename file or override behavior (not configurable via API).
gotcha loadAdapters() must be called before read(); otherwise no transpilers will be detected.
fix Always call babyTolk.loadAdapters() once before any read().
gotcha Library is CommonJS-only; does not support ES module imports.
fix Use require() instead of import.
gotcha sourceMaps option is false by default? Check documentation; setting to true may require sourcemap support in transpilers.
fix Explicitly set { sourceMaps: true } if sourcemaps are needed.
npm install baby-tolk
yarn add baby-tolk
pnpm add baby-tolk

Loads transpilers, reads a SCSS file, outputs transpiled CSS and sourcemap.

const babyTolk = require('baby-tolk');
babyTolk.loadAdapters();
babyTolk.read('style.scss', { minify: false, sourceMaps: true })
  .then(function(result) {
    console.log('Transpiled:', result.result);
    console.log('Sourcemap:', JSON.stringify(result.sourcemap));
  })
  .catch(function(err) {
    console.error('Error:', err);
  });