Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
This package allows you to easily create a new Browserify transform for a compiler, where "compiler" means any tool that takes in a file and transforms it somehow. Compilify will wrap your compiler, passing it the raw file and then packing the compiled result into a Browserify module to be require()'d. This allows you to bypass all the streaming boilerplate when you are using a framework that only operates synchronously on a whole file.
The compiler can take in an options object, and a set of default options can be specified when making the compilify transform. Compilify will handle two options for you, extensions
and excludeExtensions
, to restrict or allow the types of files your compiler will act on.
var compilify = require( 'compilify' )
compilify( compilerFunction [, defaultOptions ] )
compilerFunction
should be a function of this form:
function compilerFunction( file [, options ] ) {
// Perform transformation
return transformedFile
}
options
will be an object containing options that are passed in when the Browserify transform is invoked. If an option is not set via Browserify, it will be populated from the defaultOptions
object. If there are no options or default options, options
will be an empty object.
{
extensions: [ Array of strings ],
excludeExtensions: [ Array of strings ]
}
If neither of these options are set, your transform will operate on all files. If set, these options will also be passed through to your compiler function.
Setting this option to an array of file extensions will restrict your transform to operating on files that end with one of those extensions.
Setting this option to an array of file extensions will exclude files ending with one of those extensions from being operated on by your transform. If a file extension is set in both extensions and excludeExtensions, excludeExtensions will override.
var compilify = require( 'compilify' )
compilify( myCompiler, { extensions: [ '.html', '.tmpl' ] } )
// package 'foobarify'
var compilify = require( 'compilify' )
function foobarCompiler( file ) {
return file.replace( 'foo', 'bar' )
}
module.exports = compilify( foobarCompiler )
// package 'foobarify'
var compilify = require( 'compilify' )
function foobarCompiler( file, options ) {
return file.replace( 'foo', options.replacement )
}
// Setting default to be 'bar'
module.exports = compilify( foobarCompiler, { replacement: 'bar' } )
$ browserify -t foobarify main.js
var foobarify = require( 'foobarify' )
var b = browserify( )
b.add( 'main.js' )
b.transform( foobarify )
b.bundle( ).pipe( process.stdout )
$ browserify -t [ foobarify --replacement "baz" ] main.js
var foobarify = require( 'foobarify' )
var b = browserify( )
b.add( 'main.js' )
b.transform( { replacement: 'baz' }, foobarify )
b.bundle( ).pipe( process.stdout )
FAQs
A tool to make a simple compiler transform for Browserify
We found that compilify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.