# @growflow/babel-preset

> Babel preset for GrowFlow web apps.

Latest version **7.0.0** (published 2021-09-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @growflow/babel-preset
pnpm add @growflow/babel-preset
yarn add @growflow/babel-preset
bun add @growflow/babel-preset
```

## 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 | 7.0.0 |
| Published | 2021-09-15 |
| First published | 2021-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | GrowFlow |
| Maintainers | zachgrowflow.com, snolton, tomgrowflow, sperrye, jaygrowflow, chadly, ryanmorrow, jpboodhoo_growflow, roberto.hernandez, ericjohannsen, greglarrenaga, dwheale_growflow, joeyorlando, wgoss123 |
| Keywords | babel, babel-preset, growflow |

## Links

- npm: https://www.npmjs.com/package/@growflow/babel-preset
- Repository: https://github.com/GrowflowTeam/javascript
- Homepage: https://github.com/GrowflowTeam/javascript#readme
- Issues: https://github.com/GrowflowTeam/javascript/issues
- npm.io page: https://npm.io/package/@growflow/babel-preset

## Dependencies (10)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [optional-require](https://npm.io/package/optional-require.md) ^1.1.7
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.6
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.14.5
- [babel-plugin-import](https://npm.io/package/babel-plugin-import.md) ^1.13.3
- [babel-plugin-macros](https://npm.io/package/babel-plugin-macros.md) ^3.1.0
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.15.0
- [babel-plugin-module-resolver](https://npm.io/package/babel-plugin-module-resolver.md) ^4.1.0
- [babel-plugin-inline-react-svg](https://npm.io/package/babel-plugin-inline-react-svg.md) ^2.0.1
- [@babel/plugin-proposal-class-properties](https://npm.io/package/@babel/plugin-proposal-class-properties.md) ^7.14.5

## 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

- 7.0.0 (latest) — 2021-09-15
- 5.11.0-chad.4 (chad) — 2021-02-09
- 6.0.0 — 2021-07-23
- 5.14.1 — 2021-03-05
- 5.13.1 — 2021-02-09
- 5.13.0 — 2021-02-09
- 5.11.0-chad.3 — 2021-02-09
- 5.11.0-chad.2 — 2021-02-09
- 5.11.0-chad.1 — 2021-02-09
- 5.10.0 — 2021-01-19
- 5.9.1 — 2021-01-14
- 5.8.2 — 2021-01-12
- 5.8.1 — 2021-01-12
- 5.8.0 — 2021-01-12
- 5.7.1 — 2021-01-12
- … 1 more at https://npm.io/package/@growflow/babel-preset/versions

## README

# GrowFlow Babel Preset

> Babel preset that allows you to use the latest TypeScript features across GrowFlow projects.

## Usage

```
yarn add --dev @growflow/babel-preset
```

You can then create a `babel.config.json` file in the root of your project:

```json
{
  "presets": ["@growflow/babel-preset"]
}
```

The preset will compile for both the web and for node. It will **compile for the web by default** (specifically for use in webpack). It will leave `import`s and `export`s intact so that webpack can [tree shake](https://webpack.js.org/guides/tree-shaking/).

To compile for node v12, you will need to set the `BABEL_ENV` or `NODE_ENV` environment variable  to `node` or `test` when compiling. If you are using Jest, it will automatically set the `NODE_ENV` variable to `test` for you.

### Running an App

If you want to run your app or server via babel, you can make use of [`@babel/node`](https://babeljs.io/docs/en/babel-node).

```
npx install-peerdeps @babel/node --dev
```

Assuming the entry point of your app lives at `src/index.ts`:

```
BABEL_ENV=node babel-node --extensions ".ts,.tsx,.js,.jsx" src/index.ts
```

### Compiling Libraries

Here is a sample `package.json` that will compile a TypeScript project with source files in the `src` folder into three "distribution" folders:

- `es`: This is where the "webpackable" version of the compiled code is output. This code will still have `import` and `export` module syntax untouched. The `package.json`'s `module` key points to this entry which Webpack will find and use. We can also signal to Webpack that our library is [tree-shakable](https://webpack.js.org/guides/tree-shaking/) via the `sideEffects` key.

- `lib`: This is where the node version of the compiled code is output. The module syntax will be compiled to CommonJS so that it can be used within a node app. This output corresponds to the `package.json`'s `main` entry.

- `dist`: The TypeScript type declarations are output here so that consuming apps that use TypeScript will get intellisense and type-checking. The `package.json`'s `types` key points here.

```json
{
  "main": "lib/index.js",
  "module": "es/index.js",
  "types": "dist/index.d.ts",

  "sideEffects": false,

  "files": ["es", "lib", "dist", "README.md"],

  "scripts": {
    "build": "rimraf dist es lib && tsc -p tsconfig.output.json && babel src -d es --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward --copy-files && cross-env BABEL_ENV=node babel src -d lib --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward --copy-files"
  },

  "devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.9.6",
    "@growflow/babel-preset": "^5.7.1",
    "cross-env": "^7.0.2",
    "rimraf": "^3.0.2"
  }
}
```

where `tsconfig.output.json` is a TypeScript configuration file which is only used to output type definitions:

```json
{
  "extends": "./tsconfig.json",
  "include": ["src"],
  "compilerOptions": {
    "noEmit": false,
    "emitDeclarationOnly": true,
    "rootDir": "src",
    "outDir": "dist"
  }
}
```

> We make use of [`cross-env`](https://www.npmjs.com/package/cross-env) to set the `BABEL_ENV` variable to that poor Windows users can play along. Remember, Windows users are people too and they deserve to compile code just like you. 😁

### Usage within a Monorepo

If you have multiple packages within a monorepo, you can make use of this preset with a single `babel.config.json` file at the root of the project. In order for babel to find the configuration file, you will need to [set the root mode to `upward`](https://babeljs.io/docs/en/config-files#root-babelconfigjson-file). The sample `build` command above already does this.

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