Giter Club home page Giter Club logo

esmc's Introduction

esmc npm version github release License

🔥 Modern JavaScript, today. ✨ Blazingly fast zero-config compiler, built on @Babel and @ESLint (and @FlowType).


Code style CircleCI linux build CodeCov coverage status DavidDM dependency status Renovate App Status Make A Pull Request Semantically Released

If you have any how-to kind of questions, please read the Contributing Guide and Code of Conduct documents.
For bugs reports and feature requests, please create an issue or ping @tunnckoCore at Twitter.

Conventional Commits Become a Patron Share Love Tweet NPM Downloads Weekly NPM Downloads Monthly NPM Downloads Total

Project is semantically & automatically released on CircleCI with new-release and its New Release GitHub App.

Table of Contents

Install

This project requires Node.js ^8.9.0 || ^10.6.0. Install it using yarn or npm.
We highly recommend to use Yarn when you think to contribute to this project.

$ yarn add esmc

# or globally
$ yarn global add esmc

Usage

  1. Put your files in src/
  2. Run it easily with esmc
  3. Done.

Basically it creates:

  • dist/nodejs folder for Node.js 8.9
    • or any passed version to ESMC_NODE_VERSION environment variable
    • pass dist/nodejs/index.js to your pkg.module field, if you are not using --no-esm flag
  • dist/browsers folder for >= 1%, not dead, not IE <= 11, last 1 Opera versions browsers
    • or anything passed to ESMC_BROWSERSLIST environment variable
    • pass dist/browsers/index.js to your favorite bundler
  • dist/nodejs/__index.js using esm, so you can just use it in CJS
    • pass it to your pkg.main field if you are not using --no-esm flag,
    • otherwise just pass dist/nodejs/index.js there
  • generates .js.flow files only on dist/nodejs folder, if --flow is passed

Notes

By default does not compiles to CommonJS. That's intentional, because bundlers handles ES Modules great. If you want pure CommonJS pass --no-esm flag.

  • It's mostly instantaneous, because it compiles only files that are changed
  • Babel config is basically externalized as babel-preset-esmc
    • pass --no-build to disable Babel transpilation
    • note that you cannot use --no-build and --no-esm together
  • Linting is done, based on eslint-config-esmc
  • If you love static typing, just pass --flow flag and it will run type checking before any compilation phase
    • note that you may want to further configure .flowconfig file
  • All errors, of any phase, are styled similar to ESLint's codeframe reporter, so everything is just freaking awesome
  • It does not compiles common tests file patterns (if they are in your source directory)
  • To run your files using the same config, you can pass esmc/register as --require hook
  • You can use esmc lint to only lint your files, using ESLint
  • You can use esmc build to only compile your source files, using Babel
  • Use --force flag to start fresh (it deletes dist and cleans up the caches)

To try it out, clone the repo, yarn install and run yarn cli - this will compile everything from example-src/ folder as was described above.

  • Make some lint error and run it yarn cli
  • Make some type error there and run yarn cli --flow
  • Make some build error and run yarn cli

You will see that style of all errors are similar to ESLint's codeframe reporter.

back to top

See Also

Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your existance!

back to top

Contributing

Please read the Contributing Guide and Code of Conduct documents for advices.
For bugs reports and feature requests, please create an issue or ping @tunnckoCore at Twitter.

Contributors

Thanks to the hard work of these wonderful people this project is alive and it also follows the all-contributors specification.
Pull requests, stars and all kind of contributions are always welcome. 🌠

Users

You can see who uses esmc in the USERS.md file. Please feel free adding this file if it not exists.
If you or your organization are using this project, consider adding yourself to the list of users.
Thank You! ❤️

License

Copyright (c) 2018-present, Charlike Mike Reagent <[email protected]>.
Released under the Apache-2.0 License.


This file was generated by verb-generate-readme, v0.7.0, on August 07, 2018.

esmc's People

Contributors

imgbot[bot] avatar renovate-bot avatar tunnckocore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esmc's Issues

allow only esm (with no build step)

Like, no build step, bu just copy src to dist/nodejs/ and provide bridge.

Something like

esmc --no-build --flow

Will create dist/nodejs only.

With dist/nodejs/index.js and dist/nodejs/__index.js and respective .js.flow files for each source file.

roadmap

Built on Hela v3.

  • also look on nve (version manager working cross-platform)

Commands

# defaults to src/index.ts or src/index.js
esmc run

# run file (use node bin + `esm` loader if JS file, and `deno` if TS)
esmc run entry.js
esmc run entry.ts

# build production files to dist
esmc build
esmc build [file or glob]
esmc build --format esm,cjs
esmc build [file or glob] --format esm,cjs

# lint and typecheck if typescript
esmc check 
esmc check [file or glob]

externalize `src/flowtype/flow-strip.js` to flow-strip-types

So... We can simplify and test there. Also, it's useful thing, since flow-remove-types does not support removing from given files as input. Plus smallprint CLI.

how it would look like

src/bar.js

export const bar = (x: string) => x;

foo.js

export default (z: number) => z;

usage

const flowStripTypes = require('flow-strip-types');

// Map as { [filePath: string]: fileContentString }
const map = await flowStripTypes(['foo.js', 'src/bar.js'], options)

console.log([...map])
// => [
//  ['src/bar.js', 'export const bar = (x) => x'],
//  ['foo.js', 'export default (z) => z']
// ]

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (t)

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.