Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requires Option #64

Closed
blond opened this issue May 16, 2015 · 0 comments · Fixed by #84
Closed

Requires Option #64

blond opened this issue May 16, 2015 · 0 comments · Fixed by #84
Assignees
Milestone

Comments

@blond
Copy link
Member

blond commented May 16, 2015

Now we can use dependencies option:

{ 
    dependencies: {
        dependName: 'bhLibName'
    } 
}

Using dependName will be found dependence from global scope or from YModules and this dependence will be add to bh.lib.

In bundle file will be as follows:

// For global scope
bh.lib.bhLibName = dependName;

// For YModules
modules.define('bh', ['dependName'], function (provide, bhLibName) {
    bh.lib.bhLibName = bhLibName;
});

Shortcomings

  • Is impossible specify a name for global scope and the other for the modular system.
  • Is impossible get the module using CommonJS.

Problem Solution

{ 
    requires: {
        bhLibName: {
            globals: 'dependName',      // var name from global scope
            ym: 'depend-name',          // module name from YModules
            commonJS: 'path/to/module', // relative path to CommonJS module from target
        }
    } 
}

In bundle file will be as follows:

// For global scope
bh.lib.bhLibName = dependName;

// For YModules
modules.define('bh', ['depend-name'], function (provide, bhLibName) {
    bh.lib.bhLibName = bhLibName;
});

// For CommonJS
bh.lib.bhLibName = require('path/to/module');

If you want to get the dependency from the global scope for all modular systems:

{ 
    requires: {
        bhLibName: {
            globals: 'dependName' // var name from global scope
        }
    } 
}

In bundle file will be as follows:

// For global scope
bh.lib.bhLibName = dependName;

// For YModules
modules.define('bh', function (provide) {
    bh.lib.bhLibName = dependName;
});

// For CommonJS
bh.lib.bhLibName = dependName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants