Skip to content

Commit

Permalink
merge of pull #331
Browse files Browse the repository at this point in the history
  • Loading branch information
jrburke committed Jan 9, 2013
2 parents 8207871 + a609335 commit 60eb8aa
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/jslib/build.js
Expand Up @@ -1513,7 +1513,7 @@ define(function (require) {
//after the module is processed.
//If we have a name, but no defined module, then add in the placeholder.
if (moduleName && falseProp(layer.modulesWithNames, moduleName) && !config.skipModuleInsertion) {
shim = config.shim && getOwn(config.shim, moduleName);
shim = config.shim && (getOwn(config.shim, moduleName) || (packageConfig && getOwn(config.shim, nonPackageName)));
if (shim) {
fileContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
(shim.deps && shim.deps.length ?
Expand Down
8 changes: 8 additions & 0 deletions build/tests/lib/configPackageShim/bar/bar.js
@@ -0,0 +1,8 @@
define('bar', ['foo'], function (foo) {
return {
bar: function () {
console.log('barrrr');
foo.foo();
}
}
});
30 changes: 30 additions & 0 deletions build/tests/lib/configPackageShim/build.js
@@ -0,0 +1,30 @@
({
appDir: '.',
baseUrl: '.',
dir: 'built',
optimize: 'none',
modules: [{
name: 'main'
}],
packages: [
{
'name': 'foo',
'location': 'foo',
'main': 'foo.js'
},
{
'name': 'bar',
'location': 'bar',
'main': 'bar.js'
}
],
shim: {
'foo': {
'exports': 'Foo'
},
'bar': {
'deps': ['foo']
}

}
})
58 changes: 58 additions & 0 deletions build/tests/lib/configPackageShim/expected.js
@@ -0,0 +1,58 @@

var Foo = {
foo: function () {
console.log('foooo');
}
}
;
define('foo', ['foo/foo'], function (main) { return main; });

define("foo/foo", (function (global) {
return function () {
var ret, fn;
return ret || global.Foo;
};
}(this)));

define('bar', ['foo'], function (foo) {
return {
bar: function () {
console.log('barrrr');
foo.foo();
}
}
});

define("bar/bar", ["foo"], function(){});

require.config({
packages: [
{
'name': 'foo',
'location': 'foo',
'main': 'foo.js'
},
{
'name': 'bar',
'location': 'bar',
'main': 'bar.js'
}
],
shim: {
'foo': {
'exports': 'Foo'
},
'bar': {
'deps': ['foo']
}

}
});
require(
['bar'],
function (bar) {
console.log('main');
bar.bar();
});

define("main", function(){});
5 changes: 5 additions & 0 deletions build/tests/lib/configPackageShim/foo/foo.js
@@ -0,0 +1,5 @@
var Foo = {
foo: function () {
console.log('foooo');
}
}
9 changes: 9 additions & 0 deletions build/tests/lib/configPackageShim/index.html
@@ -0,0 +1,9 @@
<html lang="en">
<head>
<title>Package config and shim config do not mix</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script data-main="main" src="require.js"></script>
</head>
<body></body>
</html>
29 changes: 29 additions & 0 deletions build/tests/lib/configPackageShim/main.js
@@ -0,0 +1,29 @@
require.config({
packages: [
{
'name': 'foo',
'location': 'foo',
'main': 'foo.js'
},
{
'name': 'bar',
'location': 'bar',
'main': 'bar.js'
}
],
shim: {
'foo': {
'exports': 'Foo'
},
'bar': {
'deps': ['foo']
}

}
});
require(
['bar'],
function (bar) {
console.log('main');
bar.bar();
});
1 change: 1 addition & 0 deletions build/tests/lib/configPackageShim/require.js
6 changes: 3 additions & 3 deletions dist/r.js
@@ -1,5 +1,5 @@
/**
* @license r.js 2.1.2+ Wed, 09 Jan 2013 22:12:54 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* @license r.js 2.1.2+ Wed, 09 Jan 2013 22:18:58 GMT Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
Expand All @@ -21,7 +21,7 @@ var requirejs, require, define;

var fileName, env, fs, vm, path, exec, rhinoContext, dir, nodeRequire,
nodeDefine, exists, reqMain, loadedOptimizedLib, existsForNode,
version = '2.1.2+ Wed, 09 Jan 2013 22:12:54 GMT',
version = '2.1.2+ Wed, 09 Jan 2013 22:18:58 GMT',
jsSuffixRegExp = /\.js$/,
commandOption = '',
useLibLoaded = {},
Expand Down Expand Up @@ -23442,7 +23442,7 @@ define('build', function (require) {
//after the module is processed.
//If we have a name, but no defined module, then add in the placeholder.
if (moduleName && falseProp(layer.modulesWithNames, moduleName) && !config.skipModuleInsertion) {
shim = config.shim && getOwn(config.shim, moduleName);
shim = config.shim && (getOwn(config.shim, moduleName) || (packageConfig && getOwn(config.shim, nonPackageName)));
if (shim) {
fileContents += '\n' + namespaceWithDot + 'define("' + moduleName + '", ' +
(shim.deps && shim.deps.length ?
Expand Down

0 comments on commit 60eb8aa

Please sign in to comment.