Skip to content

dmitry-nizovsky/ff-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Feature Flag Loader

Feature Flag loader for webpack

Example Use

https://github.com/dmitry-nizovsky/example-use

Description

This way for feature flag good work with reactjs. You can override any file to other work for images and sass and etc. But ff-loader working only build stage and this has plus and minus Plus:

  • you have bundle always antual deps (if you switch one implementation to other, fisrt implementation don't be added to bundle)
  • if ff needs remove you need just rename file and remove old version it help you avoid problem after refactoring removing ff from app

Minus:

  • If you want dynamically enable of disable feature flag state it possible only in runtime and you need use ff-plugin for it
  • If teammate don't know about this loader on project they are don't understand why change code don't work it possible if you create 2 implementation for ff A and state of ff A in true and teammate try changes file with first implementation.

Goal

escape from "condition" in code (but if you need if statment I create plugin for it).

Example use this loader

var ffConfig    = require("./conf/config.json");
var FeatureFlag = require('ff-plugin');

module.exports = {
  entry: "./index.js",
  output: {
    path: __dirname,
    filename: "bundle.js"
  },
  module: {
    loaders: [
      {
        test: /.js/,
        loader: "ff-loader",
        include: /cont|conf/,
      },
      {
        test: /\.json$/,
        loaders: [
          'ff-loader',
          'json-loader',
        ]
      },
    ]
  },
  plugins: [
    new FeatureFlag(ffConfig)
  ]
};
  • add feature use ff in your modules
var ff = require('ff-module');

if (ff.enabled('ff-section-name')) { // login-form
  // if feature enabled do this
}
else {
  // if feature disabled do this
}

Config feature flag

  • add feature merged config file(json or js) one path to many paths
[
  {
    "name": "login-form",
    "state": true,
    "modules": {
      "./cont/abs.js": "./cont/bs.js",
      "./conf/app_conf.json": [
        "./conf/ff.json",
        "./conf/ff-second.json"
      ]
    }
  }
]

About

Feature Flag loader for webpack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published