babel-plugin-transform-strip-amd-declarations

0.0.1 • Public • Published

babel-plugin-deamdify

Strips AMD declarations to "export" inner declarations with jsdocs

— hey, google closure compiler, we have written jsdocs for our AMD-based code, maybe you can validate it?

define('math', [], function () {
  /** @constructor */
  function Math () {}
 
  /**
   * @param {number} a 
   * @param {number} b 
   * @return {number} 
   */
  Module.prototype.pow = function (a, b) {
    var m = 1;
    while (b--) m *= a;
    return m;
  };
 
  return Math;
});
define('module', ['math'], function (Math) {
  var math = new Math();
 
  /** @constructor */
  function Module () {}
 
  /**
   * @param {number} a 
   * @param {number} b 
   * @return {number} 
   */
  Module.prototype.method = function (a, b) {
    return math.pow(a, b);
  };
 
  return Module;
});

— sorry, I can't validate math in the second module, because it's declared inside another scope
— Okay, I'll transform them with babel plugin for you

See discussion on stackoverflow for some more details and tests for examples of transformations

Package Sidebar

Install

npm i babel-plugin-transform-strip-amd-declarations

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • kirilloid