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

Allow configuration of bower_components path from require config #305

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/aura.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ define(['./base', './logger'], function(base, Logger) {
ext = getVal(ext, context);
if (ext && ext.require && ext.require.paths) {
var deps = Object.keys(ext.require.paths) || [];
var bowerPath = context.config.bowerPath || require.s.contexts._.config.paths.bower_components || 'bower_components';
_.map(ext.require.paths, function(v,k) {
// support legacy path prefixed with bower_components...
// TODO: remove this in 0.10.x
var path = v.replace(/^bower_components\//, '');
var p = [bowerPath, path].join("/");
ext.require.paths[k] = p;
});
require.config(ext.require);
require(deps, function() {
dfd.resolve(ext);
Expand Down
12 changes: 8 additions & 4 deletions lib/base.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
(function() {

var requireConfig = require.s.contexts._.config || {};
var bowerPath = requireConfig.paths.bower_components || 'bower_components';

if (window.jQuery) {
define('jquery', [], function () {
return window.jQuery;
});
} else {
} else if (!requireConfig.paths.jquery) {
require.config({
paths: {
jquery: 'bower_components/jquery/jquery'
jquery: bowerPath + '/jquery/jquery'
},
shim: {
jquery: { exports: '$' }
Expand All @@ -18,10 +22,10 @@
define('underscore', [], function () {
return window._;
});
} else {
} else if (!requireConfig.paths.underscore) {
require.config({
paths: {
underscore: 'bower_components/underscore/underscore'
underscore: bowerPath + '/underscore/underscore'
},
shim: {
underscore: { exports: '_' }
Expand Down
4 changes: 2 additions & 2 deletions lib/ext/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ define('aura/ext/components', function() {
return {
name: 'components',

require: { paths: { text: 'bower_components/requirejs-text/text' } },
require: { paths: { text: 'requirejs-text/text' } },

initialize: function(app) {

Expand Down Expand Up @@ -503,7 +503,7 @@ define('aura/ext/components', function() {
},

/**
* When all of an application's extensions are finally loaded, the 'extensions'
* When all of an application's extensions are finally loaded, the 'extensions'
* afterAppStart methods are then called.
*
* @method components.afterAppStart
Expand Down
4 changes: 2 additions & 2 deletions lib/ext/mediator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ define('aura/ext/mediator', function () {

require: {
paths: {
eventemitter: 'bower_components/eventemitter2/lib/eventemitter2',
underscore: 'bower_components/underscore/underscore'
eventemitter: 'eventemitter2/lib/eventemitter2',
underscore: 'underscore/underscore'
},
shim: {
underscore: {
Expand Down