babel-plugin-remove-functions

0.3.1 • Public • Published

babel-plugin-remove-functions

Build Status

This is a WIP and experimental implementation of https://github.com/ember-cli/rfcs/pull/50.

Given the following configuration:

{
  removals: [
    {
      module: 'ember',
      methods: [
        'assert',
        'debug',
        'deprecate',
        'info',
        'runInDebug',
        'warn'
      ]
    }
  ]
}

And the following source javascript:

import Ember from 'ember';
 
export default Ember.Component.extend({
  didInsertElement() {
    console.log('didInsertElement');
 
    Ember.isEqual('this will not be removed', 'ok?');
 
    Ember.assert('this will be removed');
    Ember.assert('this will also be removed', true);
 
    Ember.debug('this will be removed');
 
    Ember.deprecate(
      'this will be removed',
      false,
      {
        id: 'test-deprecation',
        until: '3.0.0',
        url: 'http://foo.com'
      }
    );
 
    Ember.info('this will be removed');
 
    Ember.runInDebug(() => {
      Ember.Component.reopen({
        didInsertElement() {
          console.log('this will all be removed');
        }
      });
    });
 
    Ember.warn('this will be removed');
  }
});

The output will be:

import Ember from 'ember';
 
export default Ember.Component.extend({
  didInsertElement() {
    console.log('didInsertElement');
 
    Ember.isEqual('this will not be removed', 'ok?');
  }
});

Development

Use astexplorer.net for exploring and experimenting with the Babel AST.


This is based on babel-plugin-filter-imports by mmum.

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-remove-functions

Weekly Downloads

166

Version

0.3.1

License

MIT

Last publish

Collaborators

  • gavinjoyce