seajs / seajs-debug

A Sea.js plugin for debugging freely

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

seajs-debug和最新的seajs2.3.0可以结合使用吗?

panxuepeng opened this issue · comments

seajs-debug 很强大的样子,可是没有整出来,汗。

commented

debug是未压缩版。结合是啥意思?

应该可以,请按中文文档进行操作,不知道你遇到了什么问题。

原因找到了,还需有这行,只是在url添加?seajs-debug是不行的。
seajs.use(["seajs-style","seajs-debug"])

即便如此,还是有点问题,就是时好时坏,估计是这两个插件的执行循序不稳定。

经过一番折腾,发现style的代码如果直接融合到debug里面就好了。当然,这并不影响style的单独存在。

插件的浮层出来后,发现各功能都不管用。
查了一下控制台错误信息,发现sea.js有报错。
将sea.js改为sea-debug.js,后看到具体信息是:
748 行 exports[i] = cachedMods[uris[i]].exec()
报错信息:Uncaught TypeError: Cannot read property 'exec' of undefined

莫非,还是少了什么插件?

经过观察之后发现,安装的seajs-style的目录是1.1.0,但是seajs-style.js文件当中的路径信息是seajs/seajs-style/1.0.2/seajs-style-debug,将两个文件内容当中的路径信息都改为1.1.0,和目录保持一致。

还是报同样错误。
再次断点调试,发现

uris: Array[2]
0: "http://localhost/seajs/demo3/dist/seajs/seajs-style/1.1.0/seajs-style-debug.js"
1: "http://localhost/seajs/demo3/dist/seajs/seajs-debug/1.1.1/seajs-debug-debug.js"
length: 2

cachedMods: Object
http://localhost/seajs/demo3/_use_0: Module
http://localhost/seajs/demo3/_use_1: Module
http://localhost/seajs/demo3/dist/jquery/2.1.1/jquery.js: Module
http://localhost/seajs/demo3/dist/seajs/seajs-debug/1.1.1/seajs-debug-debug.js: Module
http://localhost/seajs/demo3/dist/seajs/seajs-debug/1.1.1/seajs-debug.js: Module
http://localhost/seajs/demo3/dist/seajs/seajs-style/1.1.0/seajs-style.js: Module

原因是 cachedMods 对象当中未包含key:

http://localhost/seajs/demo3/dist/seajs/seajs-style/1.1.0/seajs-style-debug.js

这是什么情况?

seajs-debug 依赖 seajs-style ,需要提前引入。

<script src="http://path/to/sea.js"></script>
<script src="http://path/to/seajs-style.js"></script>
<script>
seajs.config({
  base: 'http://path/to',
  alias: {
    "seajs-debug": 'http://path/to/seajs-debug.js'
  }
})
</script>

然后就可以在 url 后面加 ?seajs-debug 来开启插件了。

修改之后,报错信息没有了。
可是发现switch、cache、URI转换、编辑框直接输入配置文件等功能,貌似依旧不起作用。

总结:seajs-debug插件看上去很好很强大,但是对于外人来说坑很多。

我的文件已经上传到 https://github.com/panxuepeng/seajs-helloworld/tree/master/demo3 ,还请@afc163帮看看问题所在。

你发的 demo 里面各种 404,各种错误的绝对路径。我不知道要怎么跑起来。

你参照我给的 demo 来写肯定没问题。

不好意思,耽误你时间了。