spmjs / grunt-cmd-transport

Transport everything into common module.
MIT License
70 stars 32 forks source link

依赖提取后,产生无用的http请求 #74

Closed niuben1983 closed 9 years ago

niuben1983 commented 10 years ago

define("main/main", ["helloworld/hello", "helloworld/world"], function(a) { var b = a("helloworld/hello"); alert(b.increment(10)) });

这个是transport后的代码!

这个依赖关系是:main-->hello-->world, 我只需要依赖hello就可以了, 现在就会多出一个world 的无用请求!

popomore commented 10 years ago

hello 不是依赖 world 么,为何是无用的

niuben1983 commented 10 years ago

hello与world 合并后成为一个新hello.js的文件,代码如下

define("helloworld/hello", ["./world"], function(a, b) { var c = a("./world"); b.increment = function(a) { return c.add(a, 1) } }), define("helloworld/world", [], function(a, b) { b.add = function(a, b) { return a + b } });

main文件我只需要依赖hello, 压缩后只有一个hello文件就不存在world文件了!

刚才点错了。sorry!

popomore commented 10 years ago

要不 combo,要不合并。现在这种方式 main 打包的时候是不知道 hello 怎么打包的。

niuben1983 commented 10 years ago

小白一名,不明白,具体gruntfile的transport代码如下

transport: { options: { paths: ['static'] // where is the module, default value is ['sea-modules'] }, helloworld: { options: { idleading: 'helloworld/' }, files: [{ cwd: 'static/helloworld', src: '*/.js', dest: '.build/helloworld' }] }, main: { options: { idleading: 'main/' }, files: [{ cwd: 'static/main', src: '*/.js', dest: '.build/main' }] } }, 能具体解释下么!

popomore commented 10 years ago

没用过可以先用 spm build,自己配置很繁琐

popomore commented 10 years ago

https://github.com/spmjs/spm-build/tree/master/examples/simple-grunt