Wildhoney / EmberDroplet

Ember.js HTML5 file uploading with drag & drop and image/file preview.
http://ember-droplet.herokuapp.com/
MIT License
197 stars 31 forks source link

how to import in ember cli #110

Closed patroqueeet closed 8 years ago

patroqueeet commented 8 years ago

I installed it with bower and created a component:

import Ember from 'ember';

export default Ember.Component.extend(Droplet, {
    url: location.origin + '/upload'
});

I'm now getting the error that Droplet was not imported. I tried `import Droplet from 'ember-droplet/components/' but that failed. how can I fix that?

patroqueeet commented 8 years ago

by some reason it started working with the imports you documented. thx anyway

dant00ine commented 8 years ago

What was the solution here? Having the same problem. Do we not need an import statement to use the Droplet mixin?

patroqueeet commented 8 years ago

I believe restarting my ember watch as well as my grunt processess did the trick as they did not seem to be able to use newly imported imports automatically.

if that does not the trick, here is my grep for the code

templates in django

templates/_upload2.html:<script type="text/x-handlebars" data-template-name="components/image-droplet">
templates/_upload2.html:  {{#image-droplet-area}}
templates/_upload2.html:          {{image-droplet-preview image=file}}
templates/_upload2.html:      {{!--- {{image-droplet-input}} ---}}
templates/_upload2.html:  {{/image-droplet-area}}
templates/index.html:  <script src="{{ STATIC_URL }}javascripts/contrib/ember-droplet-mixin.js"></script>
templates/index.html:  <script src="{{ STATIC_URL }}javascripts/contrib/ember-droplet-view.js"></script>

js ember code:

(.ve)jirsch@codingmachine:/srv/www/vbnet/site$ grep -Ir Droplet ../sitejs/app
../sitejs/app/components/image-droplet.js:export default Ember.Component.extend(Droplet, {
../sitejs/app/components/image-droplet.js:    requestMethod:  Droplet.METHOD.POST,
../sitejs/app/components/image-droplet-preview.js:export default Ember.Component.extend(Droplet.Preview, {
../sitejs/app/components/image-droplet-area.js:export default Ember.Component.extend(Droplet.Area, {
../sitejs/app/components/image-droplet-input.js:export default Ember.Component.extend(Droplet.MultipleInput, {

additionally my ember-cli-build.js

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

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

  // Use `app.import` to add additional libraries to the generated
  // output files.
  //
  // If you need to use different assets in different
  // environments, specify an object as the first parameter. That
  // object's keys should be the environment name and the values
  // should be the asset to use in that environment.
  //
  // If the library that you are including contains AMD or ES6
  // modules that you would like to import into your application
  // please specify an object with the list of modules as keys
  // along with the exports of each module as its value.
  app.import('bower_components/ember/ember-template-compiler.js');
  app.import('bower_components/ember-droplet/dist/ember-droplet.js');
  return app.toTree();
};
dant00ine commented 8 years ago

Super helpful, thank you friend. A little tl;dr for anyone else stuck here -- you don't need import statements in your components; the Droplet mixin is available from the app level.