ember-cli: Trying to import a JS lib - can't reference from a module

Hi there,

I’m fairly certain this is not a problem with ember-cli, but @stefanpenner suggested I post anyway in case others have troubles also 😃

I am trying to get Alertify working in my ember app that is built with ember-cli. The file that I’m trying to load up via Bower can be found here.

I’ve tried the standard app.import('vendor/alertify.js/lib/alertify.js');, but then am not having any luck using it inside modules (my app files). For example, I’ve tried:

/* global alertify */
alertify.doSomething(); // Doesn't work

and

import alertify from  'alertify';
alertify.doSomething(); // Doesn't work

Then I wondered if it had something to do with how the file was being loaded, and tried the AMD version of import (don’t forget I have no clue what I’m doing!):

app.import('vendor/alertify.js/lib/alertify.js', {
  'alertify': ['alertify']
}

And still no luck.

Then I went all the way to left field and tried to load it into the tree myself:

var alertifyJS = pickFiles('vendor/alertify.js/lib', {
  srcDir: '/',
  files: ['alertify.js'],
  destDir: '/assets'
});

module.exports = mergeTrees([
  alertifyJS,
  app.toTree()
]);

// ......

<script src="assets/alertify.js"></script>

This works insofar as I can reference alertify from the JS console in my browser, but I can’t sort out how to reference it from inside of a module.

Any help would be appreciated 😃

image

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 20 (8 by maintainers)

Most upvoted comments

I know this is a super old thread but hopefully my comment will help others. Change

import alertify from 'alertify'; to… import alertify from 'alertifyjs';