sfc-compiler
raw JSON → 0.7.6 verified Fri May 01 auth: no javascript
A compiler for SFC (Single File Components) that provides rendering capabilities. Version 0.7.6 is the current stable release. Minimal documentation is available; the package is very simple with a single main export. It targets Node.js environments and uses CommonJS. There are no significant differentiators documented.
Common errors
error TypeError: compiler.render is not a function ↓
cause Calling require('sfc-compiler') returns the module object, not a compiler instance.
fix
Use require('sfc-compiler').createCompiler() to get the compiler instance.
error Error: Cannot find module 'sfc-compiler' ↓
cause Package not installed or not in node_modules.
fix
Run npm install sfc-compiler
Warnings
gotcha The package uses CommonJS; ES6 imports may not work directly without conversion. ↓
fix Use require() instead of import.
Install
npm install sfc-compiler yarn add sfc-compiler pnpm add sfc-compiler Imports
- createCompiler wrong
const compiler = require('sfc-compiler');correctconst { createCompiler } = require('sfc-compiler'); - compiler wrong
const compiler = require('sfc-compiler'); compiler.render();correctconst compiler = require('sfc-compiler').createCompiler(); - render wrong
require('sfc-compiler').render();correctconst compiler = require('sfc-compiler').createCompiler(); compiler.render();
Quickstart
const compiler = require('sfc-compiler').createCompiler();
compiler.render();