mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-18 14:53:14 +00:00
ensure we still throw on multiple anonymous defines (#1116)
This commit is contained in:
parent
bd8b0d0618
commit
9bcd118d8f
@ -193,9 +193,11 @@ hookConstructor(function(constructor) {
|
||||
if (!entry.name) {
|
||||
if (!curMeta)
|
||||
throw new TypeError('Unexpected anonymous AMD define.');
|
||||
|
||||
if (curMeta.entry && !curMeta.entry.name)
|
||||
throw new Error('Multiple anonymous defines in module ' + load.name);
|
||||
|
||||
if (!curMeta.entry || curMeta.entry.name)
|
||||
curMeta.entry = entry;
|
||||
curMeta.entry = entry;
|
||||
}
|
||||
// named define
|
||||
else {
|
||||
|
||||
10
test/test.js
10
test/test.js
@ -301,6 +301,16 @@ asyncTest('Loading an AMD bundle with an anonymous define', function() {
|
||||
}, err);
|
||||
});
|
||||
|
||||
asyncTest('Loading an AMD bundle with multiple anonymous defines', function() {
|
||||
System['import']('tests/multiple-anonymous.js').then(function(m) {
|
||||
ok(false);
|
||||
start();
|
||||
}, function(e) {
|
||||
ok(e.toString().indexOf('Multiple anonymous') != -1)
|
||||
start();
|
||||
});
|
||||
})
|
||||
|
||||
asyncTest('Loading AMD CommonJS form', function() {
|
||||
System['import']('tests/amd-cjs-module.js').then(function(m) {
|
||||
ok(m.test == 'hi', 'Not defined');
|
||||
|
||||
14
test/tests/multiple-anonymous.js
Normal file
14
test/tests/multiple-anonymous.js
Normal file
@ -0,0 +1,14 @@
|
||||
define('named-in-anon', function() {
|
||||
return 'named';
|
||||
});
|
||||
|
||||
define(['named-in-anon'], function(named) {
|
||||
return {
|
||||
anon: true,
|
||||
named: named
|
||||
};
|
||||
});
|
||||
|
||||
define([], function() {
|
||||
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user