ef4 / ember-browserify

ember-cli addon for easily loading CommonJS packages from npm via browserify.
MIT License
172 stars 28 forks source link

Does browserify still read from package.json? #11

Closed knownasilya closed 9 years ago

knownasilya commented 9 years ago

Want to setup browserify-shim, do I define the transform in config/environment.js and then just setup the browser and browserify-shim properties in the package.json?

knownasilya commented 9 years ago

Seems to be working fine, although using shimmed libs for their side-effect is (e.g. where require('./bootstrap') changes jQuery) probably not worth it, just use app.import in that case.

danny-andrews commented 8 years ago

@knownasilya How were you able to define the browserify-shim transform in config/environment.js?

knownasilya commented 8 years ago

I used this format: https://github.com/thlorenz/browserify-shim#packagejson-1

The browserify option goes into the config/environment.js but the browserify-shim stays as is in the package.json.

danny-andrews commented 8 years ago

Where in config/environment would the browserify option go? Is there an env variable you set? Why won't putting it in package.json work?

knownasilya commented 8 years ago

See the readme of this project.

knownasilya commented 8 years ago

ENV.browserify = {}; You can put it at the top level most likely.

danny-andrews commented 8 years ago

Sorry, just found it. Thanks! https://github.com/ef4/ember-browserify/blob/master/lib/index.js#L30

danny-andrews commented 8 years ago

Ugh, still can't get this to work. package.json:

"browserify-shim": {
  "jquery": "global:Ember.$"
}

config/environment.js:

browserify: { transform: ['browserify-shim'] }

Error: Cannot find module 'jquery'

danny-andrews commented 8 years ago

Just needed a good 'ole {global: true}. Leaving this here in the hopes it helps someone down the line. Corrected config/environment.js:

browserify: {
  transform: [
    ['browserify-shim', {global: true}]
  ]
}

(like in the example shown in the README.)