Tolk
raw JSON → 2.0.0 verified Fri May 01 auth: no javascript maintenance
Tolk is a file reader that automatically transpiles files with available transpilers, inlines sourcemaps, and autoprefixes CSS. It uses a zero-dependency approach for transpilers, requiring users to install them separately (e.g., node-sass, babel). The current stable version is 2.0.0. It supports multiple precompilers including LiveScript, Babel, CoffeeScript, Less, Stylus, and more. Key differentiator: no bundled transpiler dependencies, allowing users to choose and install only what they need.
Common errors
error TypeError: tolk.read(...).done is not a function ↓
cause Tolk returns a promise-like object with `.done()` method; if you try to use `.then()`, it may fail if not chained correctly.
fix
Use
.done() instead of .then(), or call .then() on the returned object. error Error: Cannot find module 'tolk' ↓
cause Tolk is not installed, or installed globally instead of locally.
fix
Run
npm install tolk in your project directory. error Error: No transpiler found for file extension '.jsx' ↓
cause Required transpiler (e.g., babel) is not installed.
fix
Install the transpiler:
npm install babel. Warnings
gotcha No built-in transpilers: you must install them separately. ↓
fix Install required transpilers, e.g., `npm install babel` for ES6/JSX support.
breaking Promise interface: uses `.done()` instead of standard `.then()` and `.catch()`. ↓
fix Use `.done(success, fail)` or replace with `.then(success, fail)` after wrapping.
deprecated Package has not been updated since 2016; no support for modern tooling. ↓
fix Consider alternatives like gulp-sass or webpack loaders.
Install
npm install tolk yarn add tolk pnpm add tolk Imports
- default wrong
import tolk from 'tolk';correctconst tolk = require('tolk'); - read wrong
tolk.readFile('file.scss')correcttolk.read('file.scss').then(...) - read wrong
tolk.read('file.jsx', callback)correcttolk.read('file.jsx').done(...)
Quickstart
const tolk = require('tolk');
const path = require('path');
// Ensure you have a transpiler installed, e.g., node-sass
// npm install node-sass --save-dev
tolk.read(path.join(__dirname, 'styles.scss')).then(compiled => {
console.log(compiled.result); // Compiled CSS
}).catch(err => {
console.error('Transpilation failed:', err.message);
});