8000 seajs 插件开发的一些规则 · Issue #2 · seajs/seatools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

seajs 插件开发的一些规则 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
popomore opened this issue Sep 2, 2013 · 0 comments
Closed

seajs 插件开发的一些规则 #2

popomore opened this issue Sep 2, 2013 · 0 comments

Comments

@popomore
Copy link
Member
popomore commented Sep 2, 2013

插件构建

插件的构建和 seajs 本身是不同的,因为插件本身是 cmd 模块。

加载插件一共有三种方式,可以总结为嵌入 script 和 preload。

  • 对于嵌入 script 需要立即执行插件,所以在模块定义后需要直接执行他。
  • preload 本身就会立即执行
define('seajs-text', [], function() {});
seajs.require('seajs-text');

在标准 cmd 构建后还需要添加 require 的代码 (seajs 2.2.0 才支持) ,使用 seatools build 已处理。

seajs 官方测试用例

s�eajs 的插件已独立成库,但仍需要在官网统一测试,因为官网的测试页会由外部用户在不同的浏览器上进行测试,还是比较可靠的。

在 seajs 的 package 中添加 seajs-plugin 字段,publish 站点的时候会把这些插件的用例添加到 seajs 中。

https://github.com/seajs/seajs/blob/470fc43de7084f0ee7c93b09ed3f264e7983efb8/package.json#L27

插件测试用例 必须存在 ./tests/spec/test.html 这个页面 ,作为用例页面。可供插件的 runner 调用,也可供 seajs 的 runner 调用。

依赖

在开发或写用例的时候,如果依赖到本模块以外的代码需要指定路径,如 seajs-flush 使用到了 seajs-combo,需要指定 seajs-combo 路径。

http://assets.spmjs.org/seajs/seajs-combo/1.0.0/seajs-combo.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0