Registry / devops / esbuild-stylus-loader

esbuild-stylus-loader

JSON →
library0.4.6jsnpmunverified

An esbuild plugin for compiling Stylus (.styl) files, currently at v0.4.6. It integrates Stylus preprocessing into esbuild bundling, supporting Stylus options like define, import, include, use, and includeCss. Released under active development with fixes for watch mode and ReDoS vulnerability. Ships TypeScript definitions. Requires esbuild >=0.10.0 and stylus >=0.52.4 as peer dependencies. Differentiated from alternatives (e.g., esbuild-sass-plugin) by its focus on Stylus and compatibility with esbuild's plugin system.

npm install esbuild-stylus-loader
INSTALL
IMPORT
SIG · ESBUILD-STYLUS-LOA
E
esbuild-stylus-loader
devopsjavascriptv0.4.6
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.

stylusLoader
✓ import { stylusLoader } from 'esbuild-stylus-loader'
✗ const stylusLoader = require('esbuild-stylus-loader')
Package is ESM/CJS dual; named export 'stylusLoader' is the plugin function.
StylusLoaderOptions
✓ import type { StylusLoaderOptions } from 'esbuild-stylus-loader'
✗ import StylusLoaderOptions from 'esbuild-stylus-loader'
TypeScript type import; not a runtime value.
stylusLoader
✓ const { stylusLoader } = require('esbuild-stylus-loader')
✗ const stylusLoader = require('esbuild-stylus-loader').default
CJS require destructuring; default export is not available.

Sets up esbuild build with Stylus plugin, showing define and include options.

const { build } = require('esbuild'); const { stylusLoader } = require('esbuild-stylus-loader'); build({ entryPoints: ['src/index.js'], bundle: true, outdir: 'dist', plugins: [ stylusLoader({ stylusOptions: { define: [['BG_IMAGE', 'https://example.com/bg.jpg']], include: ['./styles'], includeCss: false, }, }), ], }).catch(() => process.exit(1));
Debug
Known issues
breakingIn v0.4.0, stylus was moved from dependencies to peerDependencies. You must install stylus manually.
fix
Run 'npm install stylus' or add stylus to your project's dependencies.
affects: >=0.4.0
breakingIn v0.3.0, plugin options were moved into a stylusOptions object. Previously flat options are now nested.
fix
Wrap Stylus-specific options in stylusLoader({ stylusOptions: { ... } }).
affects: >=0.3.0
gotchaThe plugin does not automatically include CSS files; you must enable includeCss option.
fix
Set includeCss: true in stylusOptions if you want Stylus to process @import './file.css'.
affects: >=0.0.0
gotchaWatch mode for imported Stylus files requires v0.4.5 or later. Earlier versions only watch the entry file.
fix
Upgrade to v0.4.5+ to ensure imported Stylus files trigger rebuilds.
affects: <0.4.5
deprecatedMinimum esbuild version raised to 0.10.0 in v0.4.6 due to watchFiles option dependency.
fix
Ensure esbuild >=0.10.0 is installed.
affects: >=0.4.6
Errors
Common errors & fixes
Cannot find module 'stylus'
Stylus peer dependency is not installed.
fix
Run 'npm install stylus' or 'yarn add stylus'.
TypeError: stylusLoader is not a function
Incorrect import: using default import instead of named import.
fix
Use import { stylusLoader } from 'esbuild-stylus-loader'.
Plugin must be an object with a name property
Did not call stylusLoader() as a function; passed the function reference instead.
fix
Call stylusLoader() in the plugins array: plugins: [stylusLoader()].
Options.stylusOptions.define[0] is not an array
define items must be arrays of [name, value, raw?].
fix
Ensure define is an array of arrays, e.g., define: [['BG_IMAGE', 'url']].
Upgrade
Version history
0.4.6latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency; plugin requires esbuild's plugin API.
stylusrequiredPeer dependency; Stylus compiler is not bundled.
Agent activity
4 hits · last 30 days
node
4
Resources
esbuild-stylus-loader — npm install esbuild-stylus-loader · libregistry