
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
redirectify
Advanced tools
A require() plugin for Browserify for overriding a required file based on directory.
A transformer for Browserify to override the returned file from require().
Browserify bundles together files referenced using the require() function.
When a call to require() is made Redirectify will step in and return a file matching a specified format where available.
If the file to override with does not exist then the deault is used instead.
Redirectify can redirect the require call based on a file prefix, suffix or directory. For examples of these in action see the examples in this repo.
Using npm:
npm install redirectify browserify --save
browserify -t [ redirectify <options> ] source.js -o output.js
prefix - text to prepend to the filename
browserify -t [ redirectify --prefix="foo" ] source.js -o output.js
require("./bar.js"); will be return content of "./foobar.js" where available
suffix - text to append to the filename
browserify -t [ redirectify --suffix="foo" ] source.js -o output.js
require("./bar.js"); will be return content of "./barfoo.js" where available
dir - relative path to the directory containing the overriding file
browserify -t [ redirectify --dir="foo" ] source.js -o output.js
require("./bar.js"); will be return content of "./foo/bar.js" where available
base - used for specifying the common root for overriding sub directories
browserify -t [ redirectify --base="foo" --dir="../baz" ] source.js -o output.js
require("./foo/bar.js"); will be return content of "./baz/other/bar.js" where available
When executing browserify you can specify redirectify as a transformer in your package.json:
{
"name": "foo",
...
"browserify": {
"transform: ["redirectify"]
}
}
Also withing your package.json you should provide the overrideDir as config for redirectify:
{
"browserify": ...
"redirectify": {
"dir": "dir/to/nest/to"
}
}
For example for the above directory structure your package.json should look like this:
{
"name": "foo",
...
"browserify": {
transform: ["redirectify"]
},
"redirectify": {
"dir": "overridingDir"
}
}
For this example Browserify will now include ./overridingDir/file instead of ./file.
If the specified directory or override file with the same name do not exist then the original will acts as a default.
Alternatively you can specify the transform option on the command line:
browserify input.js -t [ redirectify --dir="overridingDir" ] -o output.js
You can also overwrite the config by using an environment variable:
This will be deprecated in a future release
REDIRECT_DIR=overridingDir browserify input.js -t redirectify -o output.js
For instance, with the following directory structure:
.
├ project
│ ├ src
│ │ └ subDir
│ │ ├ nestedSubDir
│ │ │ └ otherFile.txt
│ │ └ file.txt
│ └ override
│ └ subDir
│ ├ nestedSubDir
│ │ └ otherFile.txt
│ └ file.txt
And the following config:
{
"name": "foo",
...
"browserify": {
transform: ["redirectify"]
},
"redirectify": {
"dir": "../override",
"base": "/path/to/project"
}
}
Requiring project/src/subDir/file.txt will load project/override/subDir/file.txt. This works in a nested fashion so
requiring project/src/subDir/nestedSubDir/otherFile.txt will load project/override/subDir/nestedSubDir/otherFile.txt.
run the tests with
npm test
--dir.FAQs
A require() plugin for Browserify for overriding a required file based on directory.
The npm package redirectify receives a total of 51 weekly downloads. As such, redirectify popularity was classified as not popular.
We found that redirectify 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.