npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@glimmer/application-pipeline

v0.15.0

Published

Tooling for developing Glimmer standalone apps with ember-cli

Downloads

322

Readme

glimmer-application-pipeline

npm version Build Status

Installation

Add this package to your project with Yarn:

yarn add @glimmer/application-pipeline

Or alternatively with npm:

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:

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:

// 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 when an NPM module rely on global variables. For example, if crypto is being used by one of the modules that is imported into the the app, the additional options to the above for the Rollup config is the following:

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 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).

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).

$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:

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:

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:

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

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

In debug build this is transpiled to something like:

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:

yarn add --dev regenerator-runtime

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

// 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 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 for funding the initial development of this library.

License

MIT License.