• Stars
    star
    112
  • Rank 312,240 (Top 7 %)
  • Language
    JavaScript
  • License
    BSD 3-Clause "New...
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📦 ES.next in a box

DEPRECATED – try RunJS for a better, modern alternative


📦 ESBox

NPM version Linux Build Status Windows Build Status Dependency Status

ES.next in a box™

Zero-config REPL for experimenting with next-generation JavaScript.

It automatically compiles and re-runs your script every time you save. Think of it as a JSBin-like setup for your local editor and terminal – with full access to Node APIs and modules.

demo-gif

As well as for experimenting, ESBox may be useful in situations like workshops and screencasts – it makes it easy to do live code demos in ES2016 and beyond, without getting bogged down in build systems.

Install

> npm install -g esbox

Usage

To run script.js in a box:

> esbox script.js

Every time you save the file, ESBox clears the terminal display and runs your script again. Any uncaught errors get pretty-printed for easy debugging.

For more options, see esbox --help.

Automatic Babel compilation

You can use any proposed ECMAScript features that Babel supports (stage-0 and above), including async/await, destructuring, rest/spread, etc.

Magic imports

You can import a number of popular npm packages without needing to install them first.

This includes lodash, bluebird, chalk, chai, express, request – and anything else listed under dependencies in ESBox's own package.json.

This is made possible by rewiring require() to use ESBox's own node_modules folder as an extra possible module source. (Locally installed modules relative to your script still take precedence if found.)

For example, a script like this just works in ESBox:

import cheerio from 'cheerio';
import fetch from 'isomorphic-fetch';
import { cyan } from 'chalk';

(async () => {
  const result = await fetch('https://www.nytimes.com');
  console.assert(result.ok);

  const $ = cheerio.load(await result.text());

  console.log('The New York Times headlines:');

  $('.story-heading').each((i, element) => {
    console.log(' ', cyan($(element).text().trim()));
  });
})();

Advanced: custom Babel config

By default, ESBox will use a Babel config that makes all stage-0+ features work. But ideally you could also bring your own config. Currently, Babel has a bug that means it won't respect .babelrc files. Until that's fixed, you can instruct ESBox to use a .babelrc file located next to your script, like this:

> esbox script.js --babelrc

Or you can specify a directory to look for a .babelrc file in, like this:

> esbox script.js --babelrc /path/to/dir

This feature is a stopgap to work around a Babel issue. It might only affect your entry file. It will probably be removed in future and .babelrc files will just work.


License

MIT © Callum Locke

More Repositories

1

json-formatter

Makes JSON easy to read.
TypeScript
3,473
star
2

grunt-cdnify

Grunt plugin for finding and modifying static resource URLs
JavaScript
60
star
3

startfrom

🎬 Use any Github repo as a template for a new project
JavaScript
27
star
4

plain-jsx

Alternative JSX renderer. Creates plain DOM nodes instead of React objects.
JavaScript
20
star
5

input

Prompt for user input through the terminal
JavaScript
10
star
6

multiform

Write NPM modules in ES6/7 with multiple builds optimised for different V8 versions
JavaScript
6
star
7

grunt-embed

Inlines external small scripts and stylesheets
CoffeeScript
5
star
8

css-url-rewriter

Runs your callback for every URL found in a string of CSS
JavaScript
5
star
9

in-place

Fast, low-garbage, mutative functions for manipulating arrays.
JavaScript
4
star
10

soup

Query and manipulate raw markup via CSS selectors, without losing original formatting
CoffeeScript
3
star
11

resource-embedder

Embeds the contents of external scripts and stylesheets into HTML.
CoffeeScript
3
star
12

riot-observable

Just the 'observable' function from Riot.js, as a CommonJS module
JavaScript
2
star
13

radixer

Node module for converting big numbers into shorter, URL-friendly strings
JavaScript
1
star
14

join-table

♊️ Class for a fast collection of pairs of values with a Set-like API
JavaScript
1
star
15

is-it-bst

JavaScript function that tells you if a given date falls within British Summer Time
JavaScript
1
star
16

parse-ft-spreadsheet-key

Helper function for FT IG projects
JavaScript
1
star
17

reorient-css

Updates relative asset URLs within a string of CSS to reflect a relocation of the CSS file.
JavaScript
1
star
18

node-ruby-sass

JavaScript
1
star
19

origami-product-boilerplate

JavaScript
1
star
20

igv

JavaScript
1
star
21

h5bp-console-polyfill

Just the console.* polyfill from HTML5 Boilerplate
JavaScript
1
star
22

virtual-folder

JavaScript
1
star
23

wire

Functional build toolkit
TypeScript
1
star
24

yeoman-browserify-example

JavaScript
1
star