• Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ember-cli addon for easily loading CommonJS packages from npm via browserify.

DEPRECATION WARNING

ember-browserify is deprecated in favor of https://github.com/ef4/ember-auto-import or https://github.com/rwjblue/ember-cli-cjs-transform

If you still depend on it and want to fix a bug, I will happily merge PRs.

Ember-browserify Build Status Build status

This is an ember-cli addon for easily loading CommonJS modules from npm via browserify.

It works with ember-cli >= 0.1.3.

Synopsis

Add to your ember app:

npm install --save-dev ember-browserify

Then npm install any modules you want to load into your Ember app:

npm install --save-dev my-cool-module

Then within your app, you can import the module:

import MyCoolModule from "npm:my-cool-module";

Rebuilds & Caching

We're careful to only re-invoke browserify when necessary. If your set of imported modules remains stable and you aren't editing them, everything is served out of cache.

If you import a new npm module or edit an already-imported one, you get automatic rebuilds.

Configuring Browserify

You can put a browserify key in your app's config/environment.js to customize the behavior:

browserify: {
  extensions: ['.coffee'],
  transform: [
    ['caching-coffeeify', { global: true }]
  ]
}

Known Caveats

Ember-browserify cannot be used with named imports e.g. import { foo } from 'bar'; as we have no way of knowing at the time of browserifying what portions of the import are being used.

Using ember-browserify in addons

Wrapping generic npm libraries is a pretty common use case for ember addons. Unfortunately, ember-browserify installed on an addon cannot simply consume an npm dependency for the host app. This is a limitation of ember-cli. More info in this issue and this issue. Try it, and you'll probably get this error:

Path or pattern "browserify/browserify.js" did not match any files
Error: Path or pattern "browserify/browserify.js" did not match any files

Or you might get an error like:

Could not find module `npm:my-module` imported from `my-project/my-file`

The workaround

To have the host app consume the npm dependency, ember-browserify and the npm dependency must be installed in the host app as well AND the module must be imported from within the app/ directory of the addon. So in your app, simply npm install ember-browserify and whatever npm dependencies you need consumed by ember-browserify. Then in your addon, make sure that you're importing the modules from a file in the app/ folder. You can also import from the addon/ directory IF you've also imported the same module in the app/ directory. This is because ember-browserify running under the host application can't detect imports in the addon/ directory, since the app/ directory is the only directory merged with the application tree at build.

Eventually, ember-cli will be able to directly pull in npm depedencies to an ember app without the need for ember-browserify. Progress on this ember-cli feature can be tracked in this issue ticket.

More Repositories

1

prember

Prerender Ember apps with Fastboot at build time.
JavaScript
193
star
2

ember-elsewhere

Render elsewhere in the DOM, with nice composition, animation, etc. Based on 100% public API.
JavaScript
184
star
3

ember-animation-demo

A presentation at EmberConf 2014
CSS
129
star
4

ember-code-snippet

An Ember component for rendering pretty code snippets.
JavaScript
84
star
5

mho

Experimental service-worker based build system
TypeScript
76
star
6

memory-scroll

An Ember component that remembers its scroll position
JavaScript
57
star
7

ember-sidebars

A sidebar manager for Ember apps.
JavaScript
45
star
8

ember-handoff

Ember Engine for mounting and enhancing server-rendered web pages.
JavaScript
44
star
9

cardstack-editor

CSS
42
star
10

living-animation

Interactive EmberConf 2018 Slides
JavaScript
42
star
11

ember-set-body-class

Fastboot-compatible, template-driven helper for setting classes on the body
JavaScript
38
star
12

ember-giftwrap

A tool for packaging Ember addons
JavaScript
34
star
13

ember-cli-deploy-git

ember-cli-deploy plugin for uploading your built app to Git.
JavaScript
30
star
14

physical-design-demo

A demo app showing motion design in an Ember app. EmberConf 2015.
CSS
29
star
15

tracked-params

TypeScript
22
star
16

ember-cli-deploy-appshell

applicationCache-based shell for loading Ember apps
JavaScript
22
star
17

relativity

Interval tree clocks for Javascript
JavaScript
19
star
18

ember-resource-metadata

Per-resource metadata for ember-data
JavaScript
15
star
19

fast-sourcemap-concat

Fast sourcemap generation & concatenation.
JavaScript
13
star
20

ember-sass-bootstrap

Use the parts of bootstrap-sass that you want, and none that you don't.
JavaScript
13
star
21

ember-overlays

Annotated overlays for Ember apps.
JavaScript
12
star
22

ember-ignore-children-helper

Helps you ignore events that didn't directly target your own element.
JavaScript
11
star
23

ember-root-url

A template helper to keep your URLs relative to the app's rootURL.
JavaScript
10
star
24

ember-react-example

Example of invoking React components from an Ember app.
JavaScript
10
star
25

ember-data-relationship-tracker

JavaScript
9
star
26

pdfkit-www

In-browser PDF generation
Ruby
9
star
27

better-mocha-html-reporter

JavaScript
7
star
28

broccoli-sourcemap-concat

Fast, caching broccoli filter that generates & propagates source maps.
JavaScript
7
star
29

drupal-ember-dev

Drupal module that supports Ember development
PHP
7
star
30

xrouter

Home for Ember Polaris Routing experimentation.
JavaScript
6
star
31

emberconf-2017-demo

JavaScript
6
star
32

ember-head

Fastboot-compatible component for rendering content into <head>
JavaScript
6
star
33

are-my-node-modules-messed-up

It's a question worth asking.
JavaScript
6
star
34

ember-computed-cleanup

Ember computed properties with cleanup.
JavaScript
5
star
35

lazy-load-highcharts-demo

Code that accompanies a screencast.
JavaScript
4
star
36

prember-crawler

A web crawler for discovering URLs you want to pre-render with prember
JavaScript
4
star
37

ember-strict-warnings

Make warnings into errors during dev and test.
JavaScript
4
star
38

linkedin-demo

A demo I gave at LinkedIn.
HTML
4
star
39

initial-render-perf

A test scenario for Ember initial rendering performance
JavaScript
4
star
40

babel-import-util

Utility for manipulating imports within babel plugins
TypeScript
3
star
41

demonstrate-pdfjs

How to use pdfjs in an Ember app
JavaScript
3
star
42

ember-css-url

A helper for safely embedding URLs in style properties
JavaScript
3
star
43

ember-cli-proxy

JavaScript
3
star
44

build-if.macro

TypeScript
3
star
45

debugify

Exposes all browserify modules for console debugging (like requireify but different).
CoffeeScript
2
star
46

learning-demo

Demo to accompany a talk at EmberNYC, March 2018
JavaScript
2
star
47

flip-demo

Animation demos to accompany a presentation.
JavaScript
2
star
48

jan2020-meetup-example

Example code for a presentation at Boston Ember, January 2020.
JavaScript
2
star
49

optimist

An alternative model layer for Sproutcore.
1
star
50

distributed-ember-presentation

A presentation at WickedGoodEmber 2014.
CSS
1
star
51

tailwind-demo

How to integrate TailwindCSS into an Ember App
JavaScript
1
star
52

embroider-resolver-demo

Quick demo of how the Embroider resolver API works
JavaScript
1
star
53

koa-better-route

Like koa-route, except it works with koa-compose
JavaScript
1
star