Skip to content

wombleton/falafel-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Loader to run falafel AST transforms.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published