Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

A plugin which transforms public class fields to static getters for Closure Compiler interop.

License

Notifications You must be signed in to change notification settings

trytelework/rollup-plugin-class-fields-to-getters

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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';
  }

}

About

A plugin which transforms public class fields to static getters for Closure Compiler interop.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published