Registry / devops / rework-visit

rework-visit

JSON →
library1.0.0jsnpmunverified

rework-visit is a utility package providing a declaration visitor for the Rework CSS preprocessor's Abstract Syntax Tree (AST). Released as version 1.0.0 in June 2013, it has not seen active development or new releases since. The package enables Rework plugins to traverse and manipulate CSS declarations programmatically within the AST. It is specifically designed for the `rework` ecosystem, which has largely been superseded by more modern and actively maintained CSS tooling like PostCSS. Therefore, rework-visit is considered abandoned, with no ongoing release cadence or new feature development. Its core differentiator is its tight integration with the now-legacy Rework AST, making it unsuitable for contemporary CSS processing pipelines.

npm install rework-visit
INSTALL
IMPORT
SIG · REWORK-VISIT
R
rework-visit
devopsjavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

visit
const visit = require('rework-visit');
import visit from 'rework-visit';
rework-visit is a CommonJS module and only supports `require()` syntax. It exports the visitor function as the default.

This example demonstrates how to use `rework-visit` within a `rework` plugin to iterate over and modify CSS declarations in an AST. It changes 'font-size' and adds 'align-items' to flex containers.

const rework = require('rework'); const visit = require('rework-visit'); const cssInput = ` .container { color: blue; font-size: 16px; display: flex; } .item { margin: 10px; padding: 5px; } `; function myReworkPlugin(stylesheet) { visit.declarations(stylesheet, function (declarations, node) { declarations.forEach(function (declaration) { // Example: Convert all font-size values to '1.2em' (for demonstration) if (declaration.property === 'font-size') { declaration.value = '1.2em'; } // Example: Add a new declaration if (declaration.property === 'display' && declaration.value === 'flex') { declarations.push({ type: 'declaration', property: 'align-items', value: 'center' }); } }); }); } // Apply the plugin const outputCss = rework(cssInput) .use(myReworkPlugin) .toString(); console.log(outputCss); /* Expected Output: .container { color: blue; font-size: 1.2em; display: flex; align-items: center; } .item { margin: 10px; padding: 5px; } */
Debug
Known issues
breakingThe `rework-visit` package, along with the entire `rework` ecosystem, is unmaintained and considered abandoned. The last release was in 2013. Users should migrate to actively maintained CSS processing tools like PostCSS.
fix
Migrate your CSS processing pipeline to PostCSS or a modern alternative. Existing `rework` plugins using `rework-visit` will likely need to be rewritten for the new tooling.
affects: 1.0.0
gotcharework-visit is a CommonJS module and does not support ES Modules (ESM) `import` syntax. Attempting to `import` it in an ESM context will result in a runtime error.
fix
Ensure your project uses CommonJS `require()` statements for `rework-visit`. If your project is ESM-first, you might need to use dynamic `import()` or stick to CommonJS for the parts interacting with `rework-visit`.
affects: 1.0.0
breakingDue to its age and lack of maintenance, `rework-visit` and the `rework` parser it relies on do not support modern CSS features (e.g., CSS Nesting, Container Queries, `color-mix()`, `:has()`). Parsing modern CSS with `rework` will likely lead to errors or incorrect AST generation.
fix
Avoid using `rework-visit` for projects requiring modern CSS syntax. Use tools that actively support the latest CSS specifications.
affects: 1.0.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to use `require()` in an ES Module (ESM) file context.
fix
This package is CommonJS. If you are in an ESM module, you cannot directly use `require()`. You must either convert your file to CommonJS (`.cjs` or `"type": "commonjs"` in `package.json`) or use a dynamic import, e.g., `const visit = await import('rework-visit');` (note: this will still return a module object, not the direct function, so you might need `(await import('rework-visit')).default`).
Error: Parse error on line X, column Y: Unexpected token
The `rework` parser, which `rework-visit` relies on, encounters modern CSS syntax it does not understand.
fix
This error indicates that the CSS input contains syntax (e.g., nesting, custom properties advanced usage, new selectors) that the outdated `rework` parser cannot handle. `rework-visit` is not compatible with modern CSS. Consider using PostCSS with appropriate plugins for contemporary CSS processing.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
reworkrequiredThis package is a utility that operates on the Abstract Syntax Tree generated by the 'rework' CSS preprocessor. It provides no standalone functionality.
Agent activity
2 hits · last 30 days
node
2
Resources
rework-visit — npm install rework-visit · libregistry