Giter Club home page Giter Club logo

jekyll-babel's Introduction

Jekyll::Babel

A Babel converter for Jekyll.

Build Status

Based on jekyll-coffeescript by @parkr.

Installation

Add this line to your application's Gemfile:

gem 'jekyll-babel'

Then execute:

$ bundle

You may also skip using a Gemfile and install it yourself as:

$ gem install jekyll-babel

Finally, in you Jekyll's _config.yml file, add:

gems:
  - jekyll-babel

Notes: jekyll-babel requires Ruby 1.9.3 or greater. Additionally, the dependency on execjs means you must also have a valid JavaScript runtime available to your project

Usage

In your Jekyll site, create Babel-aware files that start with the following lines:

---
---

You need those three dashes in order for Jekyll to recognize it as "convertible". They won't be included in the content passed to the Babel compiler.

Options

Files with extensions .js, .es6, .babel and .jsx will be processed. You may customize the list of white-listed extensions in your _config.yml, by providing a string of comma-separated values:

babel_js_extensions: 'es6, babel, jsx' # Do not process .js files

Contributing

  1. Fork it (http://github.com/thejameskyle/jekyll-babel/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am "Add some feature")
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

jekyll-babel's People

Contributors

chikamichi avatar haroenv avatar jamiebuilds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jekyll-babel's Issues

Support custom Babel options

In #6, @primerano offers a patch to support custom babel options via the config.yml file.

Would you consider merging that patch in the gem? It would be neat to use custom options, because there are so many switches to Babel.

6s~10s increase in compile time

After installing jekyll-babel, I noticed a 6s~10s jump in compile time. I was able to isolate the performance regression to jekyll-babel by creating a new project and creating a single JS file, then copying it over and over.

---
---
let foo = "bar";

Even with this simple file, there was a +500ms increase in compile time per JS file (4 files == 2s increase).

Thoughts? Any way to make this faster? Thanks.

Override babel compact option?

Currently this gem runs with the default babel setting of

compact "auto"

The problem with this is when a js file exceeds 100k it logs an error to console

` if (format.compact === "auto") {
format.compact = code.length > 100000; // 100KB

  if (format.compact) {
    console.error("[BABEL] " + messages.get("codeGeneratorDeopt", opts.filename, "100KB"));
  }
}`

but since there is no console, the call to error fails and processing stops. (seems like an info message but since there is no console the point is moot)

If I could set compact to true my processing would complete.

How to transpile to ES5 to support WebComponents?

Hi there!

I'd love to use the jekyll-babel plugin since I'm creating some WebComponents for my theme. Now, from what I've understood is that jekyll-babel takes all JavaScript files and convert them to plain old JS.

Unfortunately, this does not work in case of WebComponents. There we need at least ES5 to make things work. How can I configure your plugin so it transpiles to ES5?

Fails with an unlabelled error on Windows

On my Windows 10 64-bit it fails with:

 Conversion error: Jekyll::Converters::Babel encountered an error while converting 'assets/js/components/PlayButton.es6':

(execjs):1: ExecJS::RuntimeError
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:184:in `exec_runtime'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:39:in `exec'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/external_runtime.rb:14:in `initialize'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/execjs-2.7.0/lib/execjs/runtime.rb:57:in `new'
...

After banging my head against the wall for a couple of hours I figured out this is the cause (and solution): babel/ruby-babel-transpiler#295

So until that's pulled and included in the next release it'll most likely be broken on Windows.

Use with Sprockets

Hey,

I’m relatively new to the React side of things, but I would love to set up a clean pipeline for my code. I’m currently using the latest jekyll-assets gem, and now I’m stuck. Is it just me, or is it perhaps non-trivial to use jekyll-babel inside of the Sprockets workflow?

I have both gems hooked up properly, but {% asset_path cart.jsx %} points to a plain React/JSX file. {% javascript cart %} serves cart.js, with the YAML front matter hack still intact. So, how do I ‘activate’ jekyll-babel?

Thanks from this eager-to-learn hopeful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.