Loader to run falafel AST transforms.
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
index.js
package.json

README.md

falafel-loader

Loader to run falafel AST transforms.

Installation

npm i -D falafel-loader

Usage

This example fixes an IE angular bug.

Add it into the pipeline for a js file & add falafel config:

modules: {
  falafel: function (node) {
    if (node.type === 'FunctionExpression' && node.id && node.id.name === 'interpolateFnWatchAction') {
      var expr = node && node.body && node.body.body && node.body.body[0];

      if (expr && expr.source() === 'node[0].nodeValue = value;') {
        expr.update('if (!node[0].nodeValue) { return; } ' + expr.source());
      }
    }
  },
  ...
  loaders: [
    ...
      {
        test: /angular\.js$/,
        loader: 'falafel-loader'
      }
    ...
  ]
  ...
}

This will rewrite the interpolateFnWatchAction with the necessary null check. You can implement any falafel function that you want, however.

TODO

  • Allow multiple falafel pipelines.