Comments (12)
用的是 0.9.0pre 版本吗?我这里未发现此问题,能否给个错误示例?
from seajs.
经过详细测试后,未能重现。请更新到 0.9.0 以上版本,感谢反馈。
from seajs.
再次测试后结果是这样的:
1.拥有module.exports定义的模块可以使用require('filename')调用,没有任何问题。
2.其他的模块如果使用require('filename')会有概率地出现加载失败,改用require('filename.js')后不存在此问题。
3. 0.9.0版同样如此。
from seajs.
能否提供测试页面?我排查了一下代码,未能找出有可能导致你说的问题的代码,很奇怪呢。
from seajs.
上传了一个demo包:
http://cid-2dcd432ec78904dc.office.live.com/self.aspx/pub/seajsdemo.rar
from seajs.
非常感谢 zicjin 提供测试包
仔细看了下,问题出在 require('jq.repurl')(
原因是 seajs 里会认为 jq.repurl 的后缀是 .repurl, 对于已经有后缀的文件,不会再添加 .js, 因此 require('xx.zz') 这种带 . 的filename,需要手动添加 .js
这个问题两种规避办法:
- 当文件名中含有 . 时,记得添加 .js
- 去掉文件名中的 .
因为是浏览器端,无法去提前判断 fileIsExisted(filename), 很难找到两全的约定方式,知道了上面的规律就好。
from seajs.
dzлṩ˵
#33 (comment)
κ⣬ӭϵ
2011/5/21 zicjin <
[email protected]>
ϴһdemo
http://cid-2dcd432ec78904dc.office.live.com/self.aspx/pub/seajsdemo.rarReply to this email directly or view it on GitHub:
#33 (comment)
ƽ /
from seajs.
- 带.的js 文件还很多的, 觉得lifesinger应该判断一下。
- 有一种js 是由程序动态生成的, 它可以没有.js 扩展名, 例如: http://info.wyx.cn/ConfigJs.ashx
from seajs.
嗯,就是考虑到了这种动态生成的 js 文件,所有不能简单粗暴的给所有文件都添加上 .js
对于带 . 的文件名,比如 xx.zz, 理想的处理逻辑是:
如果 .zz 是后缀,则不添加 .js
如果 .zz 只是文件名的一部分,才添加 .js
苦恼的就是在浏览器端,无法提前知道 .zz 是文件名的一部分,还是文件后缀。因此目前只能做如下取舍:
- 不管带不带 ., 都添加 .js, 这与 CommonJS 规范违背,同时也没有遵守 DRY
- 对于带 . 的文件,不添加 .js; 对于不带 . 的文件,才添加 .js
目前 seajs 的处理逻辑是第2种。暂时想不到更好的方式-.-
from seajs.
谢谢~~
from seajs.
我觉得得到一点点性能牺牲这点易用性是值得的,只是最好把这些细节在文档里做好
from seajs.
参考了下 flyscript 的处理逻辑,感觉比 seajs 的好:
对于 require(id)
如果 id 以 .js 结尾,则不再添加 .js
如果 id 以 # 结尾,也不添加 .js
其它情况下,一律添加 .js
这样,在大部分情况下,能按照使用者的预期运作。seajs 修改成了这个逻辑
from seajs.
Related Issues (20)
- 为什么要存在 require.async,和 seajs.use 的差别是?
- dist 目录中几个版本的区别是?(文档中没有找到说明)
- Failing CI
- Why should there be continuity_counter in TS?
- 谈谈这几天使用SeaJS 的感受 HOT 4
- 1
- css样式被覆盖的问题
- seajs不支持es6的语法? HOT 1
- 引入browser-polyfill支持promise不支持async let const? HOT 1
- Fix simple typo: themeselves -> themselves HOT 1
- could you please create 3.0.3 tag
- npm上的3.0.3是不是可用的? HOT 1
- 网络不稳定情况下通过seajs require.async加载的js文件部分请求失败,如何捕获异常并重新发送文件请求直至网络恢复?
- PullToRefresh中endReachedRefresh上拉加载后界面不会自动收回
- 某些安卓机型上通过sea.js引入的js文件里报的错,window.onerror不能捕获 HOT 2
- 将jquery从3.3.1升级到jquery3.5.1后,sea.js定义的模块不可用
- web端如何直接加载vue文件 HOT 3
- deleted
- 首页【乐研生物】点进去是黄网 HOT 2
- 有没有大佬分享下shellcode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seajs.