Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : README.md
# browserify-optional

It is a common pattern in Node to support optional dependencies via requires in try..catch blocks.
Browserify doesn't support this by default and throws a compile time error when it cannot find a 
module. You can solve the problem by using browserify's exclude option, but this works globally
instead of at a per-module level. This transform fixes the problem by moving the compile time 
error to a runtime error for requires of missing modules inside try..catch blocks.

## Example

The transform would transform the following code such that requiring `missing-module` would throw
a runtime error instead of a compile time error, making the code work as expected.

```javascript
try {
  var x = require('missing-module');
} catch (e) {
  var x = require('replacement-module');
}
```

To set it up in browserify, add this to your package.json:

```json
"browserify": {
  "transform": ["browserify-optional"]
}
```

## License

MIT
© 2026 GrazzMean