1. browserify-swap
A transform that swaps out modules according to a config in your package.json selected via an environment variable.
browserify-swap
Package: browserify-swap
Created by: thlorenz
Last modified: Mon, 13 Jun 2022 05:11:10 GMT
Version: 0.2.2
License: MIT
Downloads: 922
Repository: https://github.com/thlorenz/browserify-swap

Install

npm install browserify-swap
yarn add browserify-swap

browserify-swap build status

swap/swäp/ - an act of exchanging one thing for another

A transform that swaps out modules according to a config in your package.json selected via an environment variable.

package.json

 {
  "browserify": {
    "transform": [ "browserify-swap" ]
  },
  "browserify-swap": {
    "@packages": [ "hyperwatch" ],
    "dev": {
      ".*node_modules\/hyperwatch\/\\S+\\.js$": "./swap/some-hyperwatch-swap.js",
      "util.js$": "myutil"
    },
    "test": {
      "util.js$": "test-util"
    }
  }
}
  • each file matcher (i.e. 'util.js$') is a regular expression
  • in order to swap files of dependencies the browserify-swap transform needs to be injected into its package,
    therefore indicate those packages via the @packages array
 BROWSERIFYSWAP_ENV='dev' browserify . -o bundle.js

Installation

npm install browserify-swap

API

browserifySwap(file) → {TransformStream}

Looks up browserify_swap configuratios specified for the given file in the environment specified via BROWSERIFYSWAP_ENV.

If found the file content is replaced with a require statement to the file to swap in for the original. Otherwise the file's content is just piped through.

Parameters:
Name Type Description
file String

full path to file being transformed

Source:
Returns:

transform stream into which browserify will pipe the original content of the file

Type
TransformStream

generated with docme

License

MIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin