Skip to content
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

关于打包模块 自定义 #38

Open
bluemsn opened this issue Jun 30, 2014 · 2 comments
Open

关于打包模块 自定义 #38

bluemsn opened this issue Jun 30, 2014 · 2 comments

Comments

@bluemsn
Copy link

bluemsn commented Jun 30, 2014

有这样一个场景,目前tmodjs的打包规则是 接照amd ,cmd 类似seajs,requirejs的 define形式进行打包的,
如下: https://github.com/aui/artTemplate/blob/master/src/outro.js

// RequireJS && SeaJS
if (typeof define === 'function') {
    define(function() {
        return template;
    });

// NodeJS
} else if (typeof exports !== 'undefined') {
    module.exports = template;
} else {
    this.template = template;
}

})();

这样打包,少了很多的适用性,因为有些加载器上的define规则 不是这个样式,这样就没办法适用了,

如下;

// RequireJS && SeaJS
if (typeof define === 'function') {
    define("想在此处会有一些名称",['template'],function(template) {
        return template;
    });

// NodeJS
} else if (typeof exports !== 'undefined') {
    module.exports = template;
} else {
    this.template = template;
}

})();

不知道 怎么样可以做到这样的需要求,

我看了一下 tmodjs的源码,发现支持 cmd,amd,default,的那段https://github.com/aui/tmodjs/blob/master/src/AOTcompile.js#L82
我自己加了一条规则 重写了一下,但是最后发现,define的地方,还是需要修改。觉得这个地方需要在grunt或者什么地方去配置。将配置的信息加到根据需要编译文件名字来定,
define('static/js/a',['template'], function(){})

@aui
Copy link
Owner

aui commented Jun 30, 2014

对 define 自动添加 id 与依赖信息,这个不应该是 r.js 或者 spmjs 做的事情么?

@aui
Copy link
Owner

aui commented Jul 4, 2014

除非这个模块是一个通用的规范,否则不建议做成通用的。后续我考虑支持配置模块的exports

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

2 participants