Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pathmodify

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pathmodify - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

pathmodify.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

# 0.5.0
## Changed
* This now exports the plugin function instead of a factory, better conforming to the browserify plugin API. So usage is changed from `b.plugin(require("pathmodify")())` to `b.plugin(require("pathmodify"))`.
## Fixed
* Calls to pathmodify previously mutated the passed in options object, leaking internal data and causing bugs in some situations. See [jmm/pathmodify#5](https://github.com/jmm/pathmodify/issues/5). Thanks to @englercj for reporting and debugging the problem!
Furthermore, it was previously possible to mutate `opts.mods` after instantiating the plugin. `opts.mods` is now copied on instantiation.
# 0.4.0

@@ -2,0 +12,0 @@ Enable returning `true` from `expose()` to expose the module with its ID. For example: `pathmodify.mod.id('a', 'b', function () { return true; })` will expose the module as `a`.

16

package.json
{
"name": "pathmodify",
"version": "0.4.0",
"main": "index.js",
"version": "0.5.0",
"main": "pathmodify.js",
"license": "MIT",
"author": "Jesse McCarthy (http://software.jessemccarthy.net/)",
"files": [
"index.js",
"pathmodify.js",
"package.json",

@@ -33,3 +33,3 @@ "README.md",

"scripts": {
"test": "mocha test/*.js"
"test": "istanbul cover _mocha test/index.js"
},

@@ -40,5 +40,9 @@ "dependencies": {

"devDependencies": {
"browserify": ">=5.1.0",
"istanbul": "0.4.0",
"mocha": "2.x",
"browserify": ">=5.1.0",
"readable-stream": "1.x"
"object-assign": "^4.0.0",
"proxyquire": "^1.7.0",
"readable-stream": "1.x",
"sinon": "^1.17.0"
},

@@ -45,0 +49,0 @@ "peerDependencies": {

@@ -9,6 +9,8 @@ This is a [browserify](https://github.com/substack/node-browserify) plugin that's meant to do the same kind of thing as [aliasify](https://github.com/benbria/aliasify) and [remapify](https://github.com/joeybaker/remapify), but in a more elegant, powerful way. This hasn't been tested extensively yet, so consider it experimental. But some of the other alternatives already in common use don't really even work, so....

// Make bundled code like:
// `require('app/something')`
// act like:
// `require('/somedir/src/something')`
browserify()
.plugin(pathmodify(), {mods: [
// Make code like `require('app/something')` act like
// `require('/somedir/src/something')`
.plugin(pathmodify, {mods: [
pathmodify.mod.dir('app', '/somedir/src')

@@ -22,4 +24,8 @@ ]})

This plugin allows you to rewrite (AKA alias, map) `require()` IDs / paths to different values. For example, rewrite `require('app/model/something')` to a relative path like `./model/something`. This can be used to alias entire directories or any specific modules / ID string passed to `require()`, and the rewriting can be dependent on the path of the requiring file as well.
This plugin allows you to:
* Rewrite (AKA alias, map) `require()` IDs / paths to different values. For example, rewrite `require('app/model/something')` to an absolute path like `/somedir/model/something`. This can be used to alias entire directories or any specific module ID or path passed to `require()`, and the rewriting can be dependent on the path of the requiring file as well.
* And / or expose modules via the `require` function exported by the bundle, like `b.require("something", {expose: "whatever"})`.
Say you have a directory structure like...

@@ -38,3 +44,3 @@

pathmodify allows you to `require()` files like `somedir/src/model/whatever.js` from anywhere in the dependency graph without using `./` or `../` relative paths, enabing a `something.js` like this for example:
pathmodify allows you to `require()` files like `somedir/src/model/whatever.js` from anywhere in the dependency graph without using `./` or `../` relative paths, enabling a `something.js` like this for example:

@@ -86,3 +92,3 @@ ```es6

browserify('./src/entry')
.plugin(pathmodify(), opts)
.plugin(pathmodify, opts)
```

@@ -134,5 +140,5 @@

browserify('./src/entry')
.plugin(pathmodify(), {mods: [
.plugin(pathmodify, {mods: [
pathmodify.mod.dir('app', path.join(__dirname, 'src'))
]})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc