Coder Social home page Coder Social logo

babel-study's Introduction

Steps history

Tasks you can try

$ yarn clean
$ yarn start
$ yarn error

Basic

$ yarn init
$ yarn add @babel/core @babel/cli @babel/preset-env @babel/plugin-transform-async-to-generator
$ vim package.json
$ cat package.json
  {
    "name": "babel-study",
    "version": "1.0.0",
    "main": "index.js",
    "license": "MIT",
    "dependencies": {
      "@babel/cli": "^7.10.5",
      "@babel/core": "^7.11.4",
      "@babel/preset-env": "^7.11.0"
    },
    "babel": {
      "presets": ["@babel/preset-env"]
    }
  }
$ yarn babel src -d dist
$ yarn add core-js regenerator-runtime
# If you dont have entrypoint config of webpack, you can just import them in your entrypoint file ex: "index.js"
import "core-js/stable";
import "regenerator-runtime/runtime";

Add 3rd party library

  • Its also not able to be transpiled by babel but rather only convert import to require
$ yarn add node-fetch

Other CLI example

# skip to handle ignore files
$ yarn babel src -d dist --ignore ./src/node_modules && node dist/index.js

# skip to handle ignore files but copy them to distribution
$ yarn babel src -d dist --ignore ./src/node_modules --copy-files && node dist/index.js
# Caveat!! Set up ignore option in config file, but it will not work well.
# Ref: https://github.com/chase-moskal/babel-broken/commit/872d4921fd4d42f576e105c45610465aeb5be02d

$ cp -R ./node_modules ./src/node_modules
$ yarn babel src -d dist && node dist/index.js  # This will cause error.
git rebase -i --root HEAD

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.