rollup-plugin-class-fields-to-getters

1.0.1 • Public • Published

Compile class fields to get methods

Uses Babel to transpile public class fields to get methods for compilation by Closure Compiler, which currently does not support them.

rollup.config.js

import classFieldsToGetters from 'rollup-plugin-class-fields-to-getters';
export default {
  ...
  plugins: [
    ...
    classFieldsToGetters(),
    ...
  ],
  ...
}

Input

class MyTestClass {
  static myStaticProp1 = 'staticProp';
  static myStaticProp2 = 'staticProp';
  static myStaticProp3 = 'staticProp';
  myProp1 = 'instanceProp';
  myProp2 = 'instanceProp';
  myProp3 = 'instanceProp';
}

Output

class MyTestClass {
  static get myStaticProp1() {
    return 'staticProp';
  }
 
  static get myStaticProp2() {
    return 'staticProp';
  }
 
  static get myStaticProp3() {
    return 'staticProp';
  }
 
  get myProp1() {
    return 'instanceProp';
  }
 
  get myProp2() {
    return 'instanceProp';
  }
 
  get myProp3() {
    return 'instanceProp';
  }
 
}

Readme

Keywords

none

Package Sidebar

Install

npm i rollup-plugin-class-fields-to-getters

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

5.84 kB

Total Files

12

Last publish

Collaborators

  • ctjlewis