@niocn/plugin-transform-class
v0.1.6
Published
The Babel plug-in for transforming classes in ES2015
Downloads
4
Maintainers
Readme
@niocn/plugin-transform-class
The Babel plug-in for transforming classes in ES2015
Installation
$ npm install @niocn/plugin-transform-class -D
# or yarn
$ yarn add @niocn/plugin-transform-class -D
Getting started
const pluginTransformClass = require('@niocn/plugin-transform-class');
const babelCore = require('@babel/core');
const babelTypes = require('@babel/types');
const source = `
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
play() {
console.log('playing')
}
number = '100'
static range = 'unit'
}
`;
const result = babelCore.transform(source, {
plugins: [pluginTransformClass],
});
console.log(result.code);