Including content of js files that aren't modules/libraries

Hi all, i'm trying to convert my project to 2.7, but having a bit of difficulty in some steps. Still getting to grips with things you might say.

One thing that has confused me, I have a js file that contains a lot of simple support functions that I use throughout. They're not kinds at all, just very simple javascript functions.

What's the best way to ensure they get included & are available everywhere? The rest of my project is pretty much broken down with individual files for individual kinds.

Many thanks in advance..


  • I'd recommend placing them in a utils.js file that exports the shared functions and then requiring that module as you need them. You can see a model of this in enyo's utils module:
  • Thanks! I'll go check it out
  • This is somewhat inline with the questions I had, how to include 3rd party libs.
  • edited April 2016
    Thanks guys, I think both of those are helpful for me.

    @theryanjduffy, that's just what I was looking for for the simple functions, makes life much easier.

    @semanticfire, that helps too! I've written a lot of extra kinds, etc. & this looks helpful to me making them available for use. Might take a bit longer to implement (one step at a time), but helpful.
  • If you're developing regular Enyo kinds, you don't want to use either of those approaches. The simplest thing is to convert the kinds over to modules and put them into an empty library (You can create one with enyo init --template default-library my-library). You can then link it into your lib directory or actually make it a linkable library with enyo link. You'll have to add it to your .enyoconfig file, as well.
  • Hi @RoySutton, just wanted to say thanks!

    Finally got around to converting some of my kinds into a library, and after a bit of confusion where one wouldn't load (user error, i'd mistyped the actual source file name), it's working well.

    The steps to add it to .enyoconfig could do with detailing a bit more I think, I had to guess there but managed to get it to work.

    I'm also using @theryanjduffy 's suggestion for some other functions that aren't kind related too.

    Thanks again all!
Sign In or Register to comment.