Skip to content

Commit

Permalink
Merge branch 'gh-pages' of github.com:seajs/seajs into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
leoner committed Oct 29, 2012
2 parents 5d99b88 + 8154a1b commit 6b06d50
Show file tree
Hide file tree
Showing 23 changed files with 230 additions and 40 deletions.
17 changes: 17 additions & 0 deletions dist/plugin-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Display warning messages in console according to your rules.
*/
define('seajs/plugin-warning', [], function() {

var pluginSDK = seajs.pluginSDK
var util = pluginSDK.util
var config = pluginSDK.config




})

// Runs it immediately
seajs.use('seajs/plugin-warning');

16 changes: 10 additions & 6 deletions dist/sea-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ seajs._config = {
return util.filter(module.dependencies, function(dep) {
circularCheckStack = [uri]

var isCircular = isCircularWaiting(cachedModules[dep], uri)
var isCircular = isCircularWaiting(cachedModules[dep])
if (isCircular) {
circularCheckStack.push(uri)
printCircularLog(circularCheckStack)
Expand All @@ -1163,7 +1163,7 @@ seajs._config = {
})
}

function isCircularWaiting(module, uri) {
function isCircularWaiting(module) {
if (!module || module.status !== STATUS.SAVED) {
return false
}
Expand All @@ -1172,26 +1172,30 @@ seajs._config = {
var deps = module.dependencies

if (deps.length) {
if (util.indexOf(deps, uri) > -1) {
if (isOverlap(deps, circularCheckStack)) {
return true
}

for (var i = 0; i < deps.length; i++) {
if (isCircularWaiting(cachedModules[deps[i]], uri)) {
if (isCircularWaiting(cachedModules[deps[i]])) {
return true
}
}

return false
}

circularCheckStack.pop()
return false
}

function printCircularLog(stack, type) {
util.log('Found circular dependencies:', stack.join(' --> '), type)
}

function isOverlap(arrA, arrB) {
var arrC = arrA.concat(arrB)
return arrC.length > util.unique(arrC).length
}

function preload(callback) {
var preloadMods = config.preload.slice()
config.preload = []
Expand Down
48 changes: 24 additions & 24 deletions dist/sea.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ <h3>打包部署</h3>
$ cd hello-seajs/assets
$ spm build
...
BUILD SUCCESSFULLY!
BUILD SUCCESS!
$
</pre>

Expand Down
16 changes: 10 additions & 6 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
return util.filter(module.dependencies, function(dep) {
circularCheckStack = [uri]

var isCircular = isCircularWaiting(cachedModules[dep], uri)
var isCircular = isCircularWaiting(cachedModules[dep])
if (isCircular) {
circularCheckStack.push(uri)
printCircularLog(circularCheckStack)
Expand All @@ -440,7 +440,7 @@
})
}

function isCircularWaiting(module, uri) {
function isCircularWaiting(module) {
if (!module || module.status !== STATUS.SAVED) {
return false
}
Expand All @@ -449,26 +449,30 @@
var deps = module.dependencies

if (deps.length) {
if (util.indexOf(deps, uri) > -1) {
if (isOverlap(deps, circularCheckStack)) {
return true
}

for (var i = 0; i < deps.length; i++) {
if (isCircularWaiting(cachedModules[deps[i]], uri)) {
if (isCircularWaiting(cachedModules[deps[i]])) {
return true
}
}

return false
}

circularCheckStack.pop()
return false
}

function printCircularLog(stack, type) {
util.log('Found circular dependencies:', stack.join(' --> '), type)
}

function isOverlap(arrA, arrB) {
var arrC = arrA.concat(arrB)
return arrC.length > util.unique(arrC).length
}

function preload(callback) {
var preloadMods = config.preload.slice()
config.preload = []
Expand Down
17 changes: 17 additions & 0 deletions src/plugins/plugin-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Display warning messages in console according to your rules.
*/
define('seajs/plugin-warning', [], function() {

var pluginSDK = seajs.pluginSDK
var util = pluginSDK.util
var config = pluginSDK.config




})

// Runs it immediately
seajs.use('seajs/plugin-warning');

2 changes: 2 additions & 0 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
,'issues/anywhere'
,'issues/auto-transport'
,'issues/charset'
,'issues/circular-deps'
,'issues/circular-detect'
,'issues/circular-in-package'
,'issues/circular-log'
Expand Down Expand Up @@ -88,6 +89,7 @@
,'issues/plugin-json'
,'issues/plugin-less'
,'issues/plugin-text'
,'issues/plugin-warning'
,'issues/preload'
,'issues/preload-as-deps'
,'issues/preload-use'
Expand Down
27 changes: 27 additions & 0 deletions test/issues/circular-deps/dist/main-debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
define("circular-deps/a-debug", ["./b-debug", "./c-debug"], function(require, exports) {
require('./b-debug')

exports.name = 'a'
})

define("circular-deps/b-debug", ["./c-debug"], function(require, exports) {
require('./c-debug')

exports.name = 'b'
})

define("circular-deps/c-debug", ["./b-debug"], function(require, exports) {
require('./b-debug')

exports.name = 'c'
})

define("circular-deps/main-debug", ["./a-debug", "./b-debug", "./c-debug", "test-debug"], function(require) {

var test = require('test-debug')
var a = require('./a-debug')

test.assert(a.name === 'a', a.name)
test.done()

})
1 change: 1 addition & 0 deletions test/issues/circular-deps/dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/issues/circular-deps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "circular-deps",
"root": "",
"output": {
"main": "."
}
}
5 changes: 5 additions & 0 deletions test/issues/circular-deps/src/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(function(require, exports) {
require('./b.js')

exports.name = 'a'
})
5 changes: 5 additions & 0 deletions test/issues/circular-deps/src/b.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(function(require, exports) {
require('./c.js')

exports.name = 'b'
})
5 changes: 5 additions & 0 deletions test/issues/circular-deps/src/c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
define(function(require, exports) {
require('./b.js')

exports.name = 'c'
})
9 changes: 9 additions & 0 deletions test/issues/circular-deps/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
define(function(require) {

var test = require('test')
var a = require('./a.js')

test.assert(a.name === 'a', a.name)
test.done()

})
35 changes: 35 additions & 0 deletions test/issues/circular-deps/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Issue Test</title>
</head>
<body>
<p><a href="https://github.com/seajs/seajs/issues/402">#402</a></p>
<div id="out"></div>

<script src="../../../dist/sea.js"></script>
<script>

seajs.config({
debug: true,
alias: {
'circular-deps': './dist',
test: '../../../test'
}
})

seajs.use('./dist/main')


function printResults(txt, style) {
var d = document.createElement('div');
d.innerHTML = txt;
d.className = style;
document.getElementById('out').appendChild(d);
}

</script>
</body>
</html>
4 changes: 2 additions & 2 deletions test/issues/circular-in-package/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<p><a href="https://github.com/seajs/seajs/issues/393">#393</a></p>
<div id="out"></div>

<script src="../../../dist/sea-debug.js"></script>
<script src="../../../dist/sea.js"></script>
<script>

seajs.config({ base: '.' }).use('main')
seajs.config({ base: '.', debug: true }).use('main')


function printResults(txt, style) {
Expand Down
2 changes: 2 additions & 0 deletions test/issues/circular-log/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ define(function(require) {

test.assert(require('./a').name === 'a', 'should print out circular log info')
test.assert(require('./x').name === 'x', 'should print out circular log info')
test.assert(require('./s').name === 's', 'should print out circular log info')

test.done()

})
4 changes: 4 additions & 0 deletions test/issues/circular-log/s.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
define('s', ['ss'], { name: 's' })
define('ss', ['s1', 's2'], { name: 'ss' })
define('s1', [], { name: 's1' })
define('s2', ['ss'], { name: 's2' })
6 changes: 5 additions & 1 deletion test/issues/circular-log/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
<p><a href="https://github.com/seajs/seajs/issues/385">#385</a></p>
<div id="out"></div>

<script src="../../../dist/sea-debug.js"></script>
<script src="../../../dist/sea.js"></script>
<script>

seajs.config({
debug: true
})

seajs.use('./main')


Expand Down
13 changes: 13 additions & 0 deletions test/issues/plugin-warning/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define(function(require) {

var test = require('../../test')
var xx100 = require('./xx/1.0.0/xx.js')
var xx120 = require('./xx/1.2.0/xx.js')

test.assert(xx100.name === 'xx', xx100.name)
test.assert(xx120.name === 'xx', xx120.name)
test.assert(xx100.version === '1.0.0', xx100.name)
test.assert(xx120.version === '1.2.0', xx120.name)

test.done()
})
27 changes: 27 additions & 0 deletions test/issues/plugin-warning/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Issue Test</title>
</head>
<body>
<p><a href="https://github.com/seajs/seajs/issues/352">#352</a></p>
<div id="out"></div>

<script src="../../../dist/sea.js"></script>
<script>

seajs.use('./main')


function printResults(txt, style) {
var d = document.createElement('div');
d.innerHTML = txt;
d.className = style;
document.getElementById('out').appendChild(d);
}

</script>
</body>
</html>
1 change: 1 addition & 0 deletions test/issues/plugin-warning/xx/1.0.0/xx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
define({ name: 'xx', version: '1.0.0' })
1 change: 1 addition & 0 deletions test/issues/plugin-warning/xx/1.2.0/xx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
define({ name: 'xx', version: '1.2.0' })

0 comments on commit 6b06d50

Please sign in to comment.