# @fratercula/falco

> JavaScript Runner

Latest version **1.5.12** (published 2020-03-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @fratercula/falco
pnpm add @fratercula/falco
yarn add @fratercula/falco
bun add @fratercula/falco
```

Provides the command `falco`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.12 |
| Published | 2020-03-21 |
| First published | 2019-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.10.1 |
| Dependencies | 30 |
| Unpacked size | 34.5 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 9 |
| Author | LoeiFy |
| Maintainers | loeify |
| Keywords | webpack, babel, transcoder |

## Links

- npm: https://www.npmjs.com/package/@fratercula/falco
- Repository: https://github.com/fratercula/falco
- Homepage: https://github.com/fratercula/falco#readme
- Issues: https://github.com/fratercula/falco/issues
- npm.io page: https://npm.io/package/@fratercula/falco

## Dependencies (30)

- [less](https://npm.io/package/less.md) ^3.11.1
- [eslint](https://npm.io/package/eslint.md) ^5.16.0
- [core-js](https://npm.io/package/core-js.md) ^3.6.4
- [webpack](https://npm.io/package/webpack.md) ^4.42.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^7.0.1
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [css-loader](https://npm.io/package/css-loader.md) ^2.1.1
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.9.0
- [less-loader](https://npm.io/package/less-loader.md) ^5.0.0
- [babel-eslint](https://npm.io/package/babel-eslint.md) ^10.1.0
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.1.0
- [style-loader](https://npm.io/package/style-loader.md) ^0.23.1
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.9.0
- [svg-inline-loader](https://npm.io/package/svg-inline-loader.md) ^0.8.2
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^3.10.3
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.9.1
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.18.3
- [eslint-config-airbnb](https://npm.io/package/eslint-config-airbnb.md) ^18.1.0
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) ^2.20.1
- [terser-webpack-plugin](https://npm.io/package/terser-webpack-plugin.md) ^1.4.3
- [@babel/runtime-corejs3](https://npm.io/package/@babel/runtime-corejs3.md) ^7.9.0
- [eslint-plugin-jsx-a11y](https://npm.io/package/eslint-plugin-jsx-a11y.md) ^6.2.3
- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) ^3.6.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.9.0
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) ^1.7.0
- [@babel/plugin-transform-runtime](https://npm.io/package/@babel/plugin-transform-runtime.md) ^7.9.0
- [@babel/plugin-proposal-decorators](https://npm.io/package/@babel/plugin-proposal-decorators.md) ^7.8.3
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.8.3
- [@babel/plugin-transform-modules-commonjs](https://npm.io/package/@babel/plugin-transform-modules-commonjs.md) ^7.9.0
- [@babel/plugin-proposal-export-default-from](https://npm.io/package/@babel/plugin-proposal-export-default-from.md) ^7.8.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.5.12 (latest) — 2020-03-21
- 1.5.3 (next) — 2019-12-16
- 1.5.11 — 2020-03-20
- 1.5.10 — 2020-03-18
- 1.5.9 — 2020-03-15
- 1.5.8 — 2020-03-13
- 1.5.7 — 2020-03-05
- 1.5.6 — 2020-03-05
- 1.5.5 — 2019-12-23
- 1.5.4 — 2019-12-16
- 1.5.2 — 2019-12-15
- 1.5.1 — 2019-12-04
- 1.5.0 — 2019-12-03
- 1.4.1 — 2019-10-08
- 1.4.0 — 2019-09-14
- … 27 more at https://npm.io/package/@fratercula/falco/versions

## README

# Falco

[![Build Status](https://travis-ci.org/fratercula/falco.svg?branch=master)](https://travis-ci.org/fratercula/falco)
[![codecov](https://codecov.io/gh/fratercula/falco/branch/master/graph/badge.svg)](https://codecov.io/gh/fratercula/falco)

JavaScript Runner. run and build codes with `zero` configuration

![falco](https://user-images.githubusercontent.com/2193211/55216793-afa54180-5238-11e9-9cda-f1c702dcd97b.gif)

## Install

```bash
$ npm i @fratercula/falco

# CLI
$ npm i @fratercula/falco -g
```

## Usage

```js
const falco = require('@fratercula/falco')

const options = {
  entry: 'path/to/build/index.js',
  npm: {
    registry: 'https://registry.npm.taobao.org',
  },
  externals: {
    // ...
  },
  template: path.join(process.cwd(), 'index.html'),
  port: 8000,
  mode: 'development',
}

;(async () => {
  try {
    const {
      codes,
      dependencies,
      template,
      mode,
      server,
    } = await falco(options)
  } catch (e) {
    console.log(e)
  }
})()
```

**Callback Parameters**

- codes: webpack build codes, sourceMaps
- dependencies: build codes dependencies modules
- template: output html
- mode: `development` or `production`
- server: webpack dev server, only in `development` mode

**Files Trees**

```js
const { trees } = require('@fratercula/falco')

trees('path/to/entry/index.js')
/*
[
  {
    path: 'index.js',
    content: 'import React from \'react\'\nimport \'reset-css/less/reset.less\'\nimport \'./index.less\'\n\nexport default function () {\n  return (\n    <div>component</div>\n  )\n}\n',
  },
  {
    path: 'components/index.js',
    content: '...',
  }
  ...
]
*/
```

## CLI

```bash
$ falco -p 2222 -d -c -m main.js -t template.html -o lib
```

Arguments

- `-v`: show version
- `-d`: set `development` mode
- `-p`: webpack dev server port, for `development` only, default is `2222`
- `-m`: webpack entry path, default is `index.js`
- `-c`: use config `falco.config.js`
- `-t`: use template, default is `index.html`
- `-o`: set output path, default is `dist`
- `--eslint`: for `vscode` only, export vscode `eslint.nodePath` config. built in `eslint-config-airbnb`, `babel-eslint`

`falco.config.js` example:

```js
module.exports = {
  mode: 'development',
  output: {
    filename: 'index.[hash:8].js',
    library: 'Yy',
    libraryTarget: 'umd',
    libraryExport: 'default',
  },
  report: true,
  debug: true,
  targets: {
    ie: '8',
  },
}
```

## Options

| Property | description | Type | Default |
| ---- | ---- | --- | --- |
| entry | webpack entry, required  | `string` \| `array` \| `object` | - |
| externals | webpack externals | `array` | `[]` |
| packages | set packages version | `object` | `{}` |
| template | html template | `string` | - |
| tmpDir | temp files directory | `string` | `os.tmpDir()` |
| npm | npm options | `object` | `{}` |
| output | webpack output option | `object` | `{}` |
| debug | `babel loader` debug option | `boolean` | `false` |
| loaders | add webpack loaders, you should install the `loader` plugin locally | `array` | `[]` |
| sourceMap | enable `sourceMap` | `boolean` | `true` |
| targets | `browserlist` targets | `object` \| `array` \| `string`  | `{}` |
| report | enable `webpack-bundle-analyzer` | `boolean` | `false` |
| injectScript | inject scripts into template | `boolean` | `true` |
| env | set `NODE_ENV` | `string` | - |
| contentBase | webpack `contentBase` option | `string` | `os.tmpDir()` |
| context | webpack `context` option | `string` | - |

## Options Example

**entry**

```js
// path
{
  entry: '/path/to/your/codes/directory/index.js',
}

// array
{
  entry: ['path/to/js0', 'path/to/js1'],
}

// object
{
  entry: {
    index: 'path/to/index',
    home: ['path/to/home'],
  }
}
```

**externals**

```js
{
  // note the order in sequence
  externals: [
    {
      name: 'react', // package name
      root: 'React', // window.React
      commonjs2: 'react',
      commonjs: 'react',
      amd: 'react',
      urls: 'https://unpkg.com/react@16.7.0/umd/react.production.min.js', // umd url
    },
    {
      name: 'react-dom',
      root: 'ReactDOM',
      urls: 'https://unpkg.com/react-dom@16.7.0/umd/react-dom.production.min.js',
    },
    {
      // use `https://unpkg.com/axios`
      name: 'axios',
      root: 'axios',
    },
    {
      name: 'antd',
      root: 'antd',
      // `moment` is `antd` dependency
      urls: ['https://unpkg.com/moment@2.24.0/min/moment.min.js', 'https://unpkg.com/antd@3.13.0/dist/antd-with-locales.min.js'],
    },
  ],
}
```

**packages**

packages list here will be installed, ignore `externals`

```js
{
  packages: {
    react: '^13.5.9',
  },
}
```

**template**

```js
{
  template: 'path/to/html',
}
```

**tmpDir**

```js
{
  tmpDir: path.join(__dirname, 'temp'),
}
```

**npm**

cannot set `no-package-lock` and `prefix`

```js
// default
{
  npm: {
    'no-audit': true,
    production: true,
  },
}

// example
{
  npm: {
    registry: 'https://registry.npm.taobao.org',
    'prefer-offline': true,
    disturl: 'https://npm.taobao.org/dist',
    // ...
  },
}
```

**output**

cannot set `path`

```js
{
  output: {
    filename: 'index.[hash:8].js',
    library: 'someLibName',
    libraryTarget: 'umd',
  }
}
```

**debug**

only for `production` mode

```js
{
  debug: true,
}
```

**loaders**

```js
{
  loaders: [
    {
      test: /\.(png|jpg|gif)$/i,
      use: [
        {
          loader: 'url-loader',
          options: {
            limit: 8192,
          },
        },
      ],
    },
  ],
}
```

**sourceMap**

```js
{
  sourceMap: false, // always `true` in `development` mode
}
```

**targets**

only for `production` mode

```js
{
  targets: { ios: 10 },
}
```

**report**

only for `production` mode

```js
{
  report: true,
}
```

**injectScript**

```js
{
  injectScript: false,
}
```

**env**

```js
{
  env: 'development',
}
```

## Default Config

- Loaders
  - babel-loader
  - style-loader
  - css-loader
  - less-loader
  - svg-inline-loader
- Template DOM: `<div id="root"></div>`
- Output directory: `dist`
- Output files
  - index.js
  - index.js.map
  - index.html
- Externals umd url: `https://unpkg.com/${packageName}`
- CSS modules: `[name].module.css`

## License

MIT

## Relevance

Falco peregrinus

---
_Source: https://npm.io/package/@fratercula/falco · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
