Trucks Compiler

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

Web component compiler and package manager that compiles HTML-declared web components into separate JavaScript, CSS, and HTML files. Version 0.3.6 is the latest stable release, with infrequent updates. It uses a plugin architecture with multiple plugin types (core, protocol, transform, generator) and runs on Node.js >=4.0. Differentiators include full component tree transformation, custom plugin support, and multiple resolver protocols.

error Cannot find module 'trucks-compiler'
cause Package not installed.
fix
Run 'npm install trucks-compiler'.
error TypeError: trucks is not a function
cause Incorrect import (ES import on CommonJS package).
fix
Use 'const trucks = require("trucks-compiler");'.
gotcha CommonJS only: package does not provide ESM exports; using ES import syntax will fail.
fix Use require() instead of import.
gotcha Callback-based API: no Promise or async/await support; errors must be handled in callback.
fix Wrap with Promise if async/await needed.
gotcha Node.js engine restriction: requires Node >=4.0; may not work on older versions.
fix Ensure Node.js version >=4.0.
npm install trucks-compiler
yarn add trucks-compiler
pnpm add trucks-compiler

Demonstrates basic usage: compile a component HTML file with transforms and output directory.

const trucks = require('trucks-compiler');

trucks({
  files: ['components.html'],
  transforms: ['skate'],
  out: 'build',
  force: true
}, (err, state) => {
  if (err) {
    throw err;
  }
  console.log(state);
});