# @glimmer/application-pipeline

> Tooling for developing Glimmer standalone apps with ember-cli

Latest version **0.15.0** (published 2019-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @glimmer/application-pipeline
pnpm add @glimmer/application-pipeline
yarn add @glimmer/application-pipeline
bun add @glimmer/application-pipeline
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.15.0 |
| Published | 2019-02-25 |
| First published | 2017-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 35 |
| Unpacked size | 157.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 21 |
| Maintainers | chadhietala, chancancode, dgeb, krisselden, locks, mixonic, mmun, rwjblue, stefanpenner, tomdale, wycats |
| Keywords | glimmer, ember-addon |

## Links

- npm: https://www.npmjs.com/package/@glimmer/application-pipeline
- Repository: https://github.com/glimmerjs/glimmer-application-pipeline
- npm.io page: https://npm.io/package/@glimmer/application-pipeline

## Dependencies (35)

- [glob](https://npm.io/package/glob.md) ^7.1.2
- [rollup](https://npm.io/package/rollup.md) ^0.57.0
- [walk-sync](https://npm.io/package/walk-sync.md) ^0.3.1
- [babel-core](https://npm.io/package/babel-core.md) ^6.26.0
- [common-tags](https://npm.io/package/common-tags.md) ^1.4.0
- [exists-sync](https://npm.io/package/exists-sync.md) ^0.0.4
- [silent-error](https://npm.io/package/silent-error.md) ^1.1.0
- [broccoli-debug](https://npm.io/package/broccoli-debug.md) ^0.6.2
- [broccoli-concat](https://npm.io/package/broccoli-concat.md) ^3.2.2
- [broccoli-rollup](https://npm.io/package/broccoli-rollup.md) ^2.0.0
- [broccoli-source](https://npm.io/package/broccoli-source.md) ^1.1.0
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) ^1.5.1
- [heimdalljs-logger](https://npm.io/package/heimdalljs-logger.md) ^0.1.9
- [lodash.defaultsdeep](https://npm.io/package/lodash.defaultsdeep.md) ^4.6.0
- [rollup-plugin-babel](https://npm.io/package/rollup-plugin-babel.md) ^3.0.3
- [broccoli-merge-trees](https://npm.io/package/broccoli-merge-trees.md) ^2.0.0
- [@glimmer/app-compiler](https://npm.io/package/@glimmer/app-compiler.md) ^0.9.0
- [broccoli-file-creator](https://npm.io/package/broccoli-file-creator.md) ^1.1.1
- [ember-build-utilities](https://npm.io/package/ember-build-utilities.md) ^0.4.0
- [broccoli-config-loader](https://npm.io/package/broccoli-config-loader.md) ^1.0.0
- [ember-cli-string-utils](https://npm.io/package/ember-cli-string-utils.md) ^1.1.0
- [broccoli-caching-writer](https://npm.io/package/broccoli-caching-writer.md) ^3.0.3
- [broccoli-config-replace](https://npm.io/package/broccoli-config-replace.md) ^1.1.2
- [broccoli-string-replace](https://npm.io/package/broccoli-string-replace.md) ^0.1.1
- [babel-plugin-debug-macros](https://npm.io/package/babel-plugin-debug-macros.md) ^0.1.7
- [broccoli-babel-transpiler](https://npm.io/package/broccoli-babel-transpiler.md) ^6.0.0
- [broccoli-persistent-filter](https://npm.io/package/broccoli-persistent-filter.md) ^1.3.1
- [rollup-plugin-node-resolve](https://npm.io/package/rollup-plugin-node-resolve.md) ^3.0.3
- [broccoli-typescript-compiler](https://npm.io/package/broccoli-typescript-compiler.md) ^4.1.0
- [ember-cli-inject-live-reload](https://npm.io/package/ember-cli-inject-live-reload.md) ^1.4.1
- [babel-plugin-external-helpers](https://npm.io/package/babel-plugin-external-helpers.md) ^6.22.0
- [ember-cli-preprocess-registry](https://npm.io/package/ember-cli-preprocess-registry.md) 4.0.0-beta.1
- [@glimmer/resolution-map-builder](https://npm.io/package/@glimmer/resolution-map-builder.md) ^0.5.1
- [ember-cli-normalize-entity-name](https://npm.io/package/ember-cli-normalize-entity-name.md) ^1.0.0
- [@glimmer/resolver-configuration-builder](https://npm.io/package/@glimmer/resolver-configuration-builder.md) ^0.1.2

## Recent versions

- 0.15.0 (latest) — 2019-02-25
- 0.8.0-beta.1 (beta) — 2017-07-03
- 0.14.0 — 2018-11-06
- 0.13.0 — 2018-11-05
- 0.12.0 — 2018-10-30
- 0.11.2 — 2018-10-18
- 0.11.1 — 2018-04-23
- 0.11.0 — 2018-02-16
- 0.10.0 — 2017-11-24
- 0.9.1 — 2017-10-26
- 0.9.0 — 2017-10-12
- 0.8.3 — 2017-07-08
- 0.8.2 — 2017-07-07
- 0.8.1 — 2017-07-06
- 0.8.0 — 2017-07-04
- … 37 more at https://npm.io/package/@glimmer/application-pipeline/versions

## README

# glimmer-application-pipeline

[![npm version](https://badge.fury.io/js/%40glimmer%2Fapplication-pipeline.svg)](https://badge.fury.io/js/%40glimmer%2Fapplication-pipeline)
[![Build Status](https://secure.travis-ci.org/glimmerjs/glimmer-application-pipeline.svg?branch=master)](http://travis-ci.org/glimmerjs/glimmer-application-pipeline)

## Installation

Add this package to your project with Yarn:

```bash
yarn add @glimmer/application-pipeline
```

Or alternatively with npm:

```bash
npm install --save-dev @glimmer/application-pipeline
```

## Usage

This package exports a `GlimmerApp` class.
Using this class enables you to run your application code and assets through a broccoli pipeline, and calling `toTree()` will return a broccoli node with the processed files:

```javascript
const { GlimmerApp } = require('@glimmer/application-pipeline');

module.exports = function(defaults) {
  var app = new GlimmerApp(defaults, {
    // Add options here
  });

  return app.toTree();
};
```

### Importing CommonJS modules

The application pipeline only supports ES modules out of the box, but consumers can opt-in to using CommonJS modules themselves.
Here is an example of what this looks like:

```javascript
// ember-cli-build.js
const GlimmerApp = require('@glimmer/application-pipeline').GlimmerApp;
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');

module.exports = function(defaults) {
  let app = new GlimmerApp(defaults, {
    rollup: {
      plugins: [
        resolve({ jsnext: true, module: true, main: true }),
        commonjs()
      ]
    }
  });

  return app.toTree();
};
```

Note that Rollup must be [configured](https://github.com/rollup/rollup/wiki/JavaScript-API) when an NPM module rely on global variables. For example, if [`crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Window/crypto) is being used by one of the modules that is `import`ed into the the app, the additional options to the above for the Rollup config is the following:

```js
rollup: {
  // ...
  external: ['crypto'],
  globals: {
    crypto: 'crypto'
  }
}
```

### Styles and SASS
When an application is generated with ember-cli's blueprint - `ember new my-app -b @glimmer/blueprint`, it installs ember-cli addon [ember-cli-sass](https://www.npmjs.com/package/ember-cli-sass) which also is used in EmberJS applications. So you can tune it via options for GlimmerApp in the same way as in EmberApp (see [details](https://ember-cli.com/user-guide/#scsssass)).

One of common requirements is to support imports (`@import`) from node_modules.
For example, we need to import 3rd-party SASS overriding its variable (that's because we can't just use compiled css).

```sass
$mdc-theme-accent: #00e871;

@import "../../../node_modules/material-components-web/material-components-web.scss";
```

By default we'll get an error on building:
```
Build failed.
The Broccoli Plugin: [BroccoliMergeTrees] failed with:
Error: File to import not found or unreadable: ../../../node_modules/material-components-web/material-components-web.scss.
```
To fix it we need to tell SASS compiler to look up in node_modules folder:
```js
module.exports = function(defaults) {
  let app = new GlimmerApp(defaults, {
    sassOptions: {
      includePaths: [
        'node_modules'
      ]
    }
});
```

### Customizing production and debug builds

This enables any dependencies that are being built to do the following:

```js
import { DEBUG } from '@glimmer/env';

if (DEBUG) {
  // do things that are supposed to be done in debug builds only
}
```

A good example of this, is to only install "mandatory setters" for `@tracked` when running in debug builds. In production we do not want to `Object.defineProperty(instance, propertyName, ...)` for **every** property that is used in a template, but we do want this in debug builds so that we can provide nice helpful messaging to the user about what they have potentially done wrong.

This PR also enables automatic `warn` / `assert` stripping via:

```js
import { assert } from '@glimmer/debug';

assert(somePredicateGoesHere, 'helpful message when the predicate is not true');
```

In debug build this is transpiled to something like:

```js
somePredicateGoesHere && console.assert(somePredicateGoesHere, 'helpful message when the predicate is not true');
```

But in production builds, the entire statement is removed.

## Enabling use of async-await in components

First, install `regenerator-runtime` in your app:

```bash
yarn add --dev regenerator-runtime
```

Then import `regenerator-runtime/runtime` at the top of `src/index.ts`:

```javascript
// src/index.ts
import 'regenerator-runtime/runtime';
```

## Development

For the development of this project, Yarn is preferred over npm. However, any Yarn command can be replaced by the npm equivalent.
See [Migration from npm](https://yarnpkg.com/lang/en/docs/migrating-from-npm/) in the Yarn documentation for a list of the equivalent commands.

* Clone repository locally: `git clone https://github.com/glimmerjs/glimmer-application-pipeline.git`
* Install dependencies: `yarn`, or `yarn install`
* Open project in your editor of choice and make your changes
* Run tests: `yarn run test`

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/glimmerjs/glimmer-application-pipeline.

## Acknowledgements

Thanks to [Monegraph](http://monegraph.com) for funding the initial development
of this library.

## License

MIT License.

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