Package inheritance not exposing jQuery and FlowRouter to the browser


#1

I have been trying the all packages approach for my latest project after looking at the Telescope code base. I have a lib package which contains all the meteor/community packages I want to use in the project. Other packages like layout and core use the lib package. The issue is that I cannot access jquery($) and FlowRouter from browser console. I am able to access these in client side javascript files and they get printed in the console if I do a console.log($). It seems they are somehow not getting exposed when the app is rendered in the browser. In the browser console both FlowRouter and $ are undefined. I am also getting a “Exception in template helper: ReferenceError: FlowRouter is not defined” when I try to use the “pathFor” command from the arillo:flow-router-helpers library. My package.js files are as follows:

Lib/package.js

  Package.describe({
    name: 'admitaz:lib',
    version: '0.1.0',
    // Brief, one-line summary of the package.
    summary: 'Root lib for the project',
    // URL to the Git repository containing the source code for this package.
    git: '',
    // By default, Meteor will default to using README.md for documentation.
    // To avoid submitting documentation, set this field to null.
    documentation: 'README.md'
});

Package.onUse(function (api) {
    api.versionsFrom('1.2.0.2');

    var meteorPackages = [
        'meteor-base',             // Packages every Meteor app needs to have
        'mobile-experience',       // Packages for a great mobile UX
        'mongo',                   // The database Meteor supports right now
        'blaze-html-templates',    // Compile .html files into Meteor Blaze views
        'session',                 // Client-side reactive dictionary for your app
        'jquery',                  // Helpful client-side library
        'tracker',                 // Meteor's client-side reactive programming library
        'standard-minifiers',      // JS/CSS minifiers run for production mode
        'es5-shim',                // ECMAScript 5 compatibility for older browsers.
        'ecmascript',               // Enable ECMAScript2015+ syntax in app code
        'less',
        'spacebars'

    ];

    api.use(meteorPackages);
    api.imply(meteorPackages);

    var communityPackages = [
        'aldeed:collection2@2.5.0',  //https://atmospherejs.com/aldeed/collection2
        'kadira:dochead@1.2.2',
        'kadira:flow-router@2.6.2',
        'kadira:blaze-layout@2.1.0',
        'arillo:flow-router-helpers@0.4.4',
        'meteorhacks:picker@1.0.3'
    ];
    api.use(communityPackages);
    api.imply(communityPackages);

    var libFiles = [
        'lib/core.js',
        'lib/config.js'
    ];
    api.addFiles(libFiles);

    api.export(['Admitaz']);
});

Layout/package.js

Package.describe({
    name: 'admitaz:layout',
    version: '0.1.0',
    // Brief, one-line summary of the package.
    summary: '',
    // URL to the Git repository containing the source code for this package.
    git: '',
    // By default, Meteor will default to using README.md for documentation.
    // To avoid submitting documentation, set this field to null.
    documentation: 'README.md'
});

Package.onUse(function (api) {
    api.versionsFrom('1.2.0.2');
    api.use([
            'admitaz:lib@0.1.0',
            'admitaz:settings@0.1.0'
        ]);

    var clientFiles = [
        //'client/web/views/navigation.html',
        'client/web/views/top-navbar.html',
        'client/web/views/footer.html',
        'client/web/views/footer.js',
        'client/web/views/layout.html',
        //'client/web/main.html'
    ];
    api.addFiles(clientFiles, 'client');

    var libFiles = [
        'lib/subscriptions.js',
        'lib/router.js'
    ];
    api.addFiles(libFiles);

});

router.js

FlowRouter.route('/', {
    subscriptions: function (params, queryParams) {
        //this.register('posts', Meteor.subscribe('allPosts'));
    },
    action: function (params, queryParams) {
        BlazeLayout.render('layout', {navigation: 'navigation', topNavbar: 'topNavbar', footer: 'footer'});
    },
    name: 'home'
});

According to my understanding all the packages in the api.imply() for the lib package should be available everywhere for any other package using the lib package, layout in my case. Can someone point me what I am doing wrong here?


#3

I think I found the problem. I was not including the child packages to the app correctly.

Cheers!