babel-plugin-gjs
Version:
babel plugin for gjs
124 lines (85 loc) • 2.75 kB
Markdown
[](https://github.com/codejamninja/babel-plugin-gjs)
> babel plugin for gjs
For best results, run transpiled code with [CGJS](https://github.com/cgjs/cgjs)
Please ★ this repo if you found it useful ★ ★ ★
```js
class MyWindow extends Gtk.Window {
constructor() {
super({ title: 'Hello World' });
this.button = new Gtk.Button({ label: 'Click here' });
this.button.connect('clicked', this.handleClicked);
this.add(this.button);
}
handleClicked() {
console.log('Button clicked');
}
}
```
```js
const GObject = imports.gi.GObject;
const MyWindow = GObject.registerClass(
class MyWindow extends Gtk.Window {
_init() {
super._init({ title: 'Hello World' });
this.button = new Gtk.Button({ label: 'Click here' });
this.button.connect('clicked', this.handleClicked);
this.add(this.button);
}
handleClicked() {
console.log('Button clicked');
}
}
);
```
```sh
npm install --save-dev babel-plugin-gjs
```
_.babelrc_
```json
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "4"
}
}
]
],
"plugins": ["gjs"]
}
```
- [CGJS](https://github.com/cgjs/cgjs)
- [GJS](https://wiki.gnome.org/Projects/Gjs)
- [NodeJS](https://nodejs.org)
```sh
babel src -d lib
cgjs lib
```
Submit an [issue](https://github.com/codejamninja/babel-plugin-gjs/issues/new)
[](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CONTRIBUTING.md) a screenshot
Review the [guidelines for contributing](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CONTRIBUTING.md)
[](https://github.com/codejamninja/babel-plugin-gjs/blob/master/LICENSE)
[](https://codejam.ninja) © 2018
Review the [changelog](https://github.com/codejamninja/babel-plugin-gjs/blob/master/CHANGELOG.md)
- [Jam Risser](https://codejam.ninja) - Author
A ridiculous amount of coffee ☕ ☕ ☕ was consumed in the process of building this project.
[](https://liberapay.com/codejamninja/donate) if you'd like to keep me going!
[](https://liberapay.com/codejamninja/donate)
[](https://liberapay.com/codejamninja/donate)