Git Product home page Git Product logo

nodely's Introduction

nodely NPM Coverage

Write Node code using whatever syntax you want.

Table of Contents

Installation

npm

npm install nodely

yarn

yarn add nodely

Documentation

The most basic usage is achieved with the following command, replacing the source path with the path to your source code to transform and the output path with the path to where you want the transformed code to be written.

nodely -s ./path/to/source -o ./path/to/output

NOTE: If you have a .babelrc.js or .babelrc.json configuration file for Babel, nodely will use that instead of it's own built-in configuration. It's built-in configuration supports ES6, Flow types, and React.

Options

Include

By default Nodely will copy/transform all files from the source directory into the output directory. However if you want to limit which files are copied/transformed you can provide a regular expression to match included files against.

nodely -s ./path/to/source -o ./path/to/output -i "\.js$"

Note: In the above example only Javascript files will be transformed into the output directory.

Target

By default Nodely outputs code in ES5 which should work for both Node and browsers (as long as you aren't using target specific API's such as fs). If you'd like your build to target a specific Node version you can set the target like so:

nodely -s ./path/to/source -o ./path/to/output -t 8

Note: This option will have no effect if you have your own Babel configuration defined, this only applies when you are relying on nodely's built-in configuration.

Verbose

By default nodely will inform you when files fail to transform but won't provide much detail. If you want entire stack-traces when the failures occur you can use the -v flag like so:

nodely -s ./path/to/source -o ./path/to/output -v

Watcher

If you want to leave the nodely server running and have it transform modified files on the fly then you simply need to add the -w flag like so:

nodely -s ./path/to/source -o ./path/to/output -w

Workers

By default the server will spawn a worker process for all but one CPU, reserving the last CPU for the master process. If you want to spawn less workers you can use the -n flag like so:

nodely -s ./path/to/source -o ./path/to/output -n 3 # This will spawn 3 workers

Code of Conduct

Please see the code of conduct.

Contributing

Please see the contributing guide.

License

MIT

nodely's People

Contributors

dogma-io-bot avatar sandersky avatar

Watchers

 avatar  avatar

Forkers

sandersky job13er

nodely's Issues

Generated flow types breaking flow checking in downstream repo

Now that this project is generating Flow type files at lib/*.flow, they are breaking Flow type checking in downstream repos with the following error:

Error: node_modules/nodely/lib/master.js.flow:21
 21: declare export default function(argv: $Exact<{output: string, source: string, target: string, verbose: boolean, watch: boolean, workerCount: number}>): {erred: boolean, isWatching: boolean, queue: Array<$Exact<{filePath: string, type: any | any}>>, workers: Array<$Exact<{idle: boolean, worker: Class0}>>};
                                    ^ Unexpected token (

Error: node_modules/nodely/lib/worker.js.flow:9
  9: declare export default function(argv: $Exact<{output: string, source: string, target: string, verbose: boolean, watch: boolean, workerCount: number}>): void;
                                    ^ Unexpected token (

See: facebook/flow#2830

Add code coverage

Enable Jest's code coverage features so we can ensure we are fully covering our source code with tests.

Handle memory better

In some CircleCI builds the build VM has a lot of CPU's but running a worker on every CPU can cause the VM to run out of memory, due to Babel doing a lot of processing (one Babel instance per worker process). See if we can evaluate heap usage and not process files on every worker when heap usage is high. This way we can spawn all of the workers but can auto-adjust our processing in real-time to avoid running out of memory.

Better handling of file permissions

When using nodely on a Node project, it'd be nice to maintain the same file permissions on the output files that are found on the source files. For example when writing a Node script where src/index.js is actually going to be run via something like node ./lib/index.js, we'd typically do something like chmod +x ./lib/index.js to make it executable. However seeing as the lib directory isn't being checked into repos using this project, every dev that wants to do a build has to manually run the chmod command. Instead the chmod command should be done on the source file, which is checked into the repo. Nodely should then respect these file permissions when writing the output files, making it so devs never have to run chmod after the initial source file has been chmod'd and checked in.

Use fb-watchman

Consider using fb-watchman as a replacement for glob and node-watch. Benchmark change to make sure it is as performant if not better. Even if the performance is the same the amount of code required in the master process should become less.

Wire up to CI

Get continuous integration setup to automatically bump version and append to changelog on pull requests merges. Also need to run tests before allowing pull requests to be merged and verify coverage doesn't drop.

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.