How to create a babel plugin for internal use - babeljs

How do we use a babel plugin that is not already accepted in a babel repository? I had trouble finding this answer reading through the babel plugin documentation.
We are interested in writing a babel plugin for for...in loops to address a bug in ios9 (ios9 Safari miscalculating sum). Although we would be happy to contribute it to the babel community, I was also wondering if it doesn't get accepted or isn't ready for general consumption, how to start using and testing it locally.

It's possible to make use of custom babel plugins that you can host on git.
You can refer to https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md for learning how you can develop and test your babel plugin locally.
Once you have developed the plugin, you can add a dependency for it in your project's package.json file.
Note that if you plan to make the plugin repository private, you'd have to create a personal access token (for Github) to allow npm to fetch repository contents. In that case, the example entry in your package.json file would be as follows:
"babel-plugin-transform-for-of-loop": "git+https://{token}:x-oauth-basic#github.com/username/babel-plugin-transform-for-of-loop"
Whatever package name that you pick for your plugin, you will need to add a reference for it in the .babelrc file. For this example, it would be as follows:
{
...
"plugins": [
"babel-plugin-transform-for-of-loop"
]
}
With that done, you should simply run npm install and your plugin would become active for your project.

Related

Customize babel configuration in project created using create-react-app

I want to use a babel plugin (babel-plugin-module-resolver) in a project created using create-react-app.
I know how to change babel configuration using npm run eject, but I would like to avoid it.
I was going to use react-app-rewired but I heard that there is the possibility to configure babel without ejecting and without additional libraries.
(if possible), how can I do it?

Foundation 5 Production Environment Files

I've created a new foundation project using the foundation new myproject --libsass method.
Its just a simple static index.html (for the purpose of this question).
I've deployed it to a live server now, and I am wondering about the best way to structure this. I have omitted the node_modules & scss directories, and i'm left with the following:
bower_components/
css/
js/
index.html
bowerrc
bower.json
Gruntfile.js
humans.txt
package.json
README.md
bower_components is needed in its current form, unless I shuffle some files around, which is what I intend to do, but I'm checking if there is a better way of doing this, and that I haven't missed some magic terminal command to deploy to production.
As msturdy suggested in the comments, grunt is the way to go here. There are a lot of plugins out there, see a list on the official page.
If you want to have grunt "compile" your project into one specific folder which you can then for example push to a deployment server, you should do several things in grunt:
compile your scss
minify your javascript, that is making the files smaller, see jscompress for a demo of what it is. All your js-files from /bower_components which you include in your project should be in a vendor.js which is loaded first, and then a second js-file should contain your custom js from /js
save everything into a deployment folder.
(optional) automatically deploy to a server.
Take a look at these grunt tutorials for setting up your gruntfile.js, you'll want to have two tasks, one for just quickly compiling your scss, one for the whole deployment process:
grunt is not weird and hard
official tutorial
sitepoint tutorial
They show you how to do certain things and definitely how to write the gruntfile. Plugins you might want to use apart from your current libsass plugin are uglify and any plugin that lets you deploy your code via git, ftp or anything else. You can download all these plugins via npm by adding them to your package.json and doing npm install, refer to their websites for exact usage instruction.

Project on Google go, imports of libraries

everyone.
I am new to Go language and currently I am trying to understand the basics of building Go applications. I met the following problem.
For example, I am using other libraries in my project. I have them locally, on my computer, so my project works fine.
I am loading my code on github and another programmer download it. As I understand, my code won't work, because this programmer doesn't have the libraries I used.
So the question is: What is the best way to share my project with all libraries it has? Should I upload these libraries in the separate repositories? Then to use my project, people need to look inside the code to detect which libraries I am using to download them one by one?
For example, in Java there is such thing like Maven or Ant, which downloads all required dependencies. Is there any tools like this for Go?
Let's call the main file of my project main.go
And I am using my own library: mathutil.go
what is the best way to make this project run on other computers?
Go's dependencies work very much like using Maven or IVY transitive dependencies. When someone does "go get" of your package, anything you depend on will automatically download.
For example, in your source:
import "github.com/foo/bar"
go will automatically download that to your $GOPATH/src/github.com/foo/bar along with your code.
Assuming the third party libs you use are hosted in a public repo (ie: github) then people don't need to do anything.
If the libraries you used are not available on a public repo, you will need to post them somewhere assuming their licensing allows.
Take a look at golang.org/doc/code.html for more details

Clj-sentiment dependency

What dependency should be used for clj-sentiment? I have neither found it on the github https://github.com/AndreasKostler/clj-sentiment nor have I been able to locate it within clojars.
The reason I am using this library is to implement the algorithm within https://groups.google.com/forum/#!msg/clojure/7GMuLVvToCE/WmT04KY0_yYJ where the create-cluster function calls to the library for the function get-feature-vec. I searched through all of the branches of this github library for the function get-feature-vec to exclude the need for the dependency. However the search returned empty.
do a git checkout of github project, lein install inside project dir and use library name and version from project.clj
[clj-sentiment "1.0.0-SNAPSHOT"]

Installing a Griffon plugin in zip format from private remote url

Somehow I cannot find and answer to this in griffon documentation nor googling...
I have created a griffon plugin. It gets packaged as usual with:
griffon package-plugin
Then I can install it locally in my application specifying path to the zip file resulting from packaging:
griffon install-plugin /path-to-plugin/plugin-name.zip
I can even upload it to a remote url and install it from there:
griffon install-plugin address-of-my-site/plugin-name.zip
How can I make installing of this plugin from my url an automatic step during building/running of a griffon application, which uses it?
I work on the application with another developer and don't want to force him to install the plugin manually every time when something changes. It should be downloaded from my site automatically. But I don't want to release the plugin to the griffon official repository either - it's pretty experimental stuff still.
There is a line in application.properties, which tells griffon, that the plugin is needed:
plugins.plugin-name=0.3
But it cannot be installed from griffon central repository, like all the other plugins, because it's not there, obviously.
I looked into documentation of "griffon.project.dependency.resolution" section in BuildConfig.groovy, but I can't find anything useful for my purposes there.
Do I miss something?
The answer you seek is found in sections 12.1 and 12.2 of the guide. The first section describes an example of a plugin being pushed to a local repository. The second section describes the types of repositories supported by Griffon.
Plugins that are available from a plugin repository that can be queried by the build system (i.e, the repository is configured) are instantly available to be installed using the short notation you want.
There's always a local repository configured by Griffon: griffon-local. Pushing releases to it will make them instantly available to install-plugin, list-plugins, plugin-info, etc.