Sharing enyo & libs between apps.

Hey, reading through some of the docs, I came across a brief section on setting up enyo to be shared between apps.

http://enyojs.com/docs/latest/developer-guide/getting-started/planning-and-structuring-your-app.html

(its at the bottom).

I was just wondering how this would affect running deploy?
Would some paths need to be updated in places?
Will the $lib key work still work?

Comments

  • Has anyone tried this out yet?

    I've been super busy over the holidays and other work, i havn't had a chance to code for a couple weeks.

    I have a large project for a client that is going to be split up into some sub-apps, and i want to be able to share common libs and enyo (which has a couple custom hacks in the core for this app).

    I'd rather not just jump in and test it, rather have a bit more details on how it is set up and how depoy, etc will work.
  • edited February 2015
    I wish the enyo team would respond to this.

    I know i could figure it out on my own by making test projects, but i figured since you included it in you docs, you had some examples available.

    As much as i love to use and play with the framework, i just don't always have time to "figure it out myself" when it is a documented feature that is said to be possible to be done.
  • edited March 2015
    I hadn't tried this before but here are the steps I took to make it work. I modeled my directory structure after the docs like this. All the repos were cloned from master today (3/4/15).
    root/
    shared-root/
    enyo/
    lib/
    onyx/
    layout/
    apps-root/
    bootplate/
    To get everything to work, I had to update the paths to enyo and the libs in a couple places within bootplate: deploy.json, debug.html, and tools/deploy.sh.

    deploy.json holds references to the location of the libs and assumes they'll be in ./lib so that must be updated to point to shared-root/.

    debug.html must load enyo so that path must be changed. Note that index.html doesn't need to be changed because it's expecting a minified version of enyo in its build director.

    tools/deploy.sh assumes a local copy of enyo as well so that must be updated. In addition, enyo's deploy.js assumes it is in the usual spot but can be overridden by passing the -e option with the desired path. That must be provided as well.

    I've bundled up these changes into a git patch which can be applied to your bootplate-based apps. You'd have to update the paths for your environment but hopefully that helps you get closer. If you have any problems, let me know!

    Download https://paste.ee/p/51xpD into a file and apply using git apply. Or, in a single line:
    curl https://paste.ee/r/51xpD | git apply -
  • Very sweet, I will be trying this out soon.

    This should be added to the docs as well.
  • Forgot to note that LESS script doesn't work (hence why it was commented out in my patch) because it is assuming local pathing as well. I've built a fix for which I'll submit a PR but you can drop it in enyo/tools/less.js now if you need that feature.
    // Client-side less.js configurator / loader
    (function() {
    var less = window.less || {};
    if (less.relativeUrls === undefined) {
    less.relativeUrls = true;
    }
    if (less.environment === undefined) {
    less.environment = 'production';
    }
    window.less = less;

    var thisScript = document.querySelector('script[src $= \'enyo/tools/less.js\']'),
    src = thisScript ? thisScript.getAttribute('src') : null,
    basePath = src ? src.substring(0, src.length - 7) : 'enyo/tools/',
    script = document.createElement('script');

    script.src = basePath + 'minifier/node_modules/less/dist/less-1.7.0.min.js';
    script.charset = 'utf-8';
    document.getElementsByTagName('head')[0].appendChild(script);
    })();
  • Hello. Just a note that we've updated the documentation (http://enyojs.com/docs/latest/developer-guide/getting-started/planning-and-structuring-your-app.html) to reflect the useful information in this discussion.
  • Great to see the docs updated so quickly :smiley:
  • Hey, just wanted to say i finally had time to migrate all the apps to this new format, and everything it working great!

    Thanks again for getting this all figured out.
  • edited April 2015
    @theryanjduffy :
    So Chrome canary updated on me, and my apps wouldn't load anymore. It was giving an error on querySelector in less.js, saying invalid argument.

    Turn out, it just didn't like the space after src in 'script[src $= \'enyo/tools/less.js\']'

    So, just changed to 'script[src$= \'enyo/tools/less.js\']', and am back up and running.
  • Looks like it may be a canary bug as the space is allowed by the grammar in the spec. Good catch! I'll follow up on this.
  • Cool.
    It took me 10-15 mins to figure it cause when i was looking at the specs for it everything seemed valid.
Sign In or Register to comment.