Giter Site home page Giter Site logo

krasimir / hopa Goto Github PK

View Code? Open in Web Editor NEW
138.0 4.0 9.0 1.93 MB

Zero config CLI for running JavaScript/TypeScript files

Home Page: https://krasimirtsonev.com/blog/article/hopa-javascript-typescript-runner

License: MIT License

JavaScript 94.98% TypeScript 5.02%

hopa's Introduction

Хопа-тропа

Zero config JavaScript/TypeScript runner
right in your terminal

Features

  • Zero configuration 🚀
  • Transpiles and runs JavaScript and TypeScript ⚙️
  • Single-folder file browser 📁

What and Why

Hopa is a command line tool that does the following:

  1. Reads the current directory and lets you choose a file.
  2. Transpiles the file and produces a valid JavaScript bundle. It uses Rollup so it does resolve your imports.
  3. Runs the generated bundle via node and shows you the result.
  4. It also runs a watcher so changing the files will trigger new compilation.

I did this little tool because I'm tired of creating dummy repos, copying webpack files, switching between terminal and browser just so I can run some "modern" JavaScript. I know about solution like CodeSandbox and CodePen but I want specifically to exercise my code in the terminal. And I want to do it quick, without configuring stuff like Babel and Webpack.

More about the story here https://krasimirtsonev.com/blog/article/hopa-javascript-typescript-runner.

Installation

npm i hopa -g

Usage

Go to the folder that contains your files and run hopa.

> hopa

This will display a menu and you have to pick a file. You'll get transpilation, bundling, running and watching.

> hopa -i script.js -o bundle.js -m

Gets script.js, transpiles it and bundle it to a new file called bundle.js which is also minified. No watching in this case. It's a single-shot operation. -m and -o are optional. If the output is not specified Hopa creates a file with name bundle.<your file>. Have in mind that this feature is experimental. I find that in some cases Hopa can't resolve properly modules and errors out.

Demo

Hopa demo

hopa's People

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  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  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

hopa's Issues

Specify filename in cmd

I would love it if I could do something like hopa index.js to just go straight to running file.

Uncaught ReferenceError: exports is not defined

So I am using this to convert browser libraries, to a single bundle, but I have noticed that the following shows up:

Uncaught ReferenceError: exports is not defined

I have seen this on EVERY other program that compiles to browser, is there anything I can do to fix this? I am using TypeScript to write the modules, then creating a single bundle that I can then load into the browser?

Thanks,

CMD line dies on use

  • Windows 10 command line
  • in a folder containing "go.js"
  • which contains console.log("hello");

I run

c:\myfolder>hopa

I select go.js

The command line window closes (I assume the process dies).

Terminal doesn't reset after exiting hopa

When you run hopa, and then exit hopa, either through the menu or via ctrl+c, the terminal does not reset properly.

I have tested this on both windows and macos and have experienced different effects, most notably duplicated keystrokes on windows and being unable to scroll through the terminal on macos.

Running reset on macos fixes the issue

2020-01-16 02-22-24 2020-01-16 02_24_40

Can't scroll through log

If you print out a lot onto the log (in my case, I wanted to console.log a large object), you can't scroll up to see the entire contents of the log.

Missing line break after error

If a file I select throws an error, then you break (Ctrl+C), your terminal continues on the same line as the end of the error. There should be a line break after the error.

Screenshot from 2020-01-16 10-54-49

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.