Giter Site home page Giter Site logo

mmamedel / esbuild-runner Goto Github PK

View Code? Open in Web Editor NEW

This project forked from folke/esbuild-runner

0.0 0.0 0.0 264 KB

⚡️ Super-fast on-the-fly transpilation of modern JS, TypeScript and JSX using esbuild

Home Page: https://www.npmjs.com/package/esbuild-runner

License: Apache License 2.0

JavaScript 32.40% TypeScript 67.06% Shell 0.53%

esbuild-runner's Introduction

⚡ Esbuild Runner (esr)

Super-fast on-the-fly transpilation of modern JS, TypeScript and JSX using esbuild.

esr makes it easy to run arbitrary code or tests without needing to build your whole project. It's a great way to improve your development workflow.

✨ Usage

The easiest way to use esbuild-runner is to install it globally and use the included esr binary.

$ esr hello-world.ts

Alternatively, you can require esbuild-runner within any nodejs process to include realtime transpilation:

$ node -r esbuild-runner/register hello-world.ts

In order to use esbuild-runner with Jest, you need to configure a Jest transform in your jest.config.js

module.exports = {
  transform: {
    "\\.ts$": "esbuild-runner/jest",
  },
}

VSCode Debugging

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug with esbuild-runner",
      "program": "${workspaceFolder}/hello-world.ts",
      "runtimeArgs": [
        "-r",
        "esbuild-runner/register"
      ],
      "request": "launch",
      "sourceMaps": true,
      "skipFiles": [
        "<node_internals>/**"
      ],
      "type": "pwa-node"
    }
  ]
}

⚙️ Configuration

esr provides two different ways to transpile your code:

  • bundling (default): this transpiles the script and all its dependencies in typically one invocation of esbuild. Dependencies defined in package.json or node_modules will never be transpiled. Running esr will always transpile the code. No caching is used.
  • transform (--cache): this method will invoke esbuild for every source file, but will cache the result. This means that the initial run will be slower, but after that, only changed source files will be transpiled.
$ bin/esr.js --help
Usage: esr [options] <source-file> [file-options]

  --cache       Transform on a file per file basis and cache code
  --clearCache  Clear transform cache
  --help|-h     Display this help message

To customize the options passed to esbuild, you can create an esbuild-runner.config.js file in the current directory or one of the ancestor directories.

// example esbuild-runner.config.js
module.exports = {
  type: "bundle", // bundle or transform (see description above)
  esbuild: {
    // Any esbuild build or transform options go here
    target: "esnext",
  },
}

📦 Installation

Simply install the esbuild-runner npm package using your favorite package manager.

  • globally ...
$ npm install -g esbuild-runner
  • ... or locally in your project
$ npm add --dev esbuild-runner

👋 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

⚖ License

Apache 2.0

esbuild-runner's People

Contributors

folke avatar renovate-bot avatar renovate[bot] avatar teintinu avatar

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.