Registry / web-framework / resource-compiler

resource-compiler

JSON →
library0.2.8jsnpmunverified

Resource compiler and cacher for Express. Current stable version: 0.2.8. This package allows you to compile and cache resources (e.g., CSS, JavaScript templates) in an Express application. It is designed to be generic and integrate with Express's middleware pattern. The package has seen no recent updates and is in early stages, with limited documentation and community adoption. Differentiators include its focus on resource compilation and caching for Express, as opposed to more general-purpose build tools or asset pipelines. It supports a plugin-like system for custom compilers.

npm install resource-compiler
INSTALL
IMPORT
SIG · RESOURCE-COMPILER
R
resource-compiler
web-frameworkjavascriptv0.2.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ResourceCompiler
✓ import ResourceCompiler from 'resource-compiler'
✗ const ResourceCompiler = require('resource-compiler').default
Default export; CommonJS require gives the constructor directly (no .default).
compile
✓ import { compile } from 'resource-compiler'
✗ const compile = require('resource-compiler').compile
Named export available; CommonJS require works but beware of .compile property.
ResourceCompiler (type)
✓ import type ResourceCompiler from 'resource-compiler'
✗ import ResourceCompiler from 'resource-compiler'
TypeScript: use `import type` for type-only imports to avoid runtime impact.

Basic setup of express-resource-compiler with custom compiler for .jst files and caching enabled.

const express = require('express'); const ResourceCompiler = require('resource-compiler'); const app = express(); const compiler = new ResourceCompiler({ cache: true, cacheDir: './cache', compilers: { '.jst': (content, filename) => `module.exports = ${JSON.stringify(content)};` } }); app.use(compiler.middleware()); app.get('/', (req, res) => { res.send('Resource compiler active'); }); app.listen(3000);
Debug
Known issues
gotchaConstructor requires `compilers` object; missing it causes silent failure.
fix
Always provide a `compilers` configuration with at least one extension handler.
affects: all
gotchaCache directory is created synchronously on instantiation; ensure write permissions.
fix
Set `cacheDir` to a writable path or disable caching (`cache: false`).
affects: all
deprecatedVersion 0.2.x is outdated; no updates since 2018.
fix
Consider migrating to a more maintained alternative like webpack or gulp.
affects: 0.x
Errors
Common errors & fixes
Cannot find module 'resource-compiler'
Package not installed or not in node_modules.
fix
Run `npm install resource-compiler` and ensure it's in dependencies.
compiler.middleware is not a function
Using import incorrectly or object is not a ResourceCompiler instance.
fix
Ensure you instantiate with `new ResourceCompiler(options)` and call `middleware()` method.
TypeError: Cannot read property 'prototype' of undefined (in ResourceCompiler)
Likely using `require` with a named export instead of default.
fix
Use `const ResourceCompiler = require('resource-compiler');` (no `.default`).
Upgrade
Version history
0.2.8latest on npm
Audit
Dependencies
expressrequiredPeer dependency for Express integration
Agent activity
2 hits · last 30 days
node
2
Resources
resource-compiler — npm install resource-compiler · libregistry