Comments (16)
感觉上可以用,但直觉上是会有问题的,比如我有startup/foo
和startup/bar
,分别是用在2个页面里的,那么它们是不应该互斥的
回到最初的问题,我认为是不是这样就能解决:
combine = {
foo: {
modules: [...]
},
bar: {
modules: [...], // 这里不要去管是否会重复
negative: ['foo'] // 表示要把`foo`里有的去掉
}
}
当然这样如果有N个配置,还是要写一些negative
配置,只是相比之前的一堆自己写要简单也逻辑清晰
from edp-build.
foo
和bar
如果是 key 的话,那么执行的顺序是不太容易保证的。万一 bar 先执行了 或者 foo negative bar 并且 bar negative foo,我感觉好像是一个很麻烦的事情。
我有startup/foo和startup/bar,分别是用在2个页面里的,那么它们是不应该互斥的
是不应该互斥的,这里提到的foo
和bar
应该就是具体的某个 Action 了,他们应该把 公共代码中的 模块id 排除掉。
{
"combine": {
".v2": true,
"exclude": [
"~er", "xxx", "foo", "bar/**"
],
"modules": [
{ "ria": [ "~er", "~esui" ] },
{ "startup": [ "~foo", "~bar" ] },
{
"negative": ["ria", "startup"],
"modules": [
{"bcc/List": ["bcc/ListView", "bcc/ListModel"]},
{"bcc/Form": ["bcc/FormView", "bcc/FormModel"]},
]
}
]
}
}
from edp-build.
太复杂了,combine的object里有modules item,里面每个module还有modules item,看着都哭了
from edp-build.
from edp-build.
这应该不是最终的样子,只是用来说明一下采用的方式吧
from edp-build.
我想的是这样的效果:
var combine = {
'base': {
include: ['jquery', 'underscore']
},
'startup/foo': {
include: ['foo/**'],
negative: ['base']
},
'startup/bar': {
include: ['bar/**'],
negative: 'base'
},
'lazy/fooDetail': {
include: ['detail/foo/**'],
negative: ['foo']
}
}
上面的表示:
- 有一个
base
包含基础库 foo
和bar
分别用于2个html页面,所以它们各自有自己的策略,但都不要base
fooDetail
用于在foo.html
中点击某个按钮时要加载的模块,所以它不要foo
,同时因为foo
不要base
,fooDetail
也就隐式地不要了base
from edp-build.
我理解 @leeight 的意思,是希望很多combine的模块里,公共的部分能有地方去进行统一配置。但是我觉得,combine是一个Object,每一个key代表一个希望被合并的module,这点最好还是不要变,否则会不太好理解。
可以为每个希望被合并的module,增加一些项,这些项在modules
处理后的集合中进行处理。参考了下rjs,我觉得,可以有:
- includes: 要引入的模块,包含其依赖
- includeShallows: 要引入的模块,不包含其依赖
- excludes: 要排除的模块,包含其依赖
- excludeShallows: 要排除的模块,不包含其依赖
这样,配置代码可能会变成这样:
var base = [sys-base, echarts];
var combine = {
'common/dep': {
modules: base
},
'startup': {
modules: [bizCommon],
excludes: base
}
};
return combine;
from edp-build.
事实上不用数组,我们也可以根据每个配置项里的negative
之类的属性,来算出顺序的,无非是一个依赖图,把这个交给程序更合适。用数组并且前后negative
关系反了是会很麻烦的,甚至问题都排查不到
from edp-build.
事实上不用数组,我们也可以根据每个配置项里的negative之类的属性,来算出顺序的
没理解
from edp-build.
立理指的应该是先处理哪个后处理哪个的问题
from edp-build.
没理解
我是基于你的观点进行的补充,我也认为使用数组其实不是太合适,保持原有的对象的模式,让程序来计算这些对象间的互斥关系,进而决定build的顺序即可
from edp-build.
- 那就保持对象的模式吧,也可以
- 新增一个
negative
应该就可以了,多重复几次就多重复几次吧,不过看起来会更清晰。 includeShallows
和excludeShallows
我感觉好像意义不是很大耶。
最终推荐的配置应该就是这样子了吧?
var combine = {
'base': {
modules: ['jquery', 'underscore']
},
'startup/foo': {
modules: ['foo/**', '!foo/bar'],
negative: ['base']
},
'startup/bar': {
modules: ['bar/**', '!bar/foo'],
negative: 'base'
},
'lazy/fooDetail': {
modules: ['detail/foo/**'],
negative: ['foo']
}
}
from edp-build.
我建议还是不要叫negative,毕竟negative这个单词还没在edp或者rjs里出现过。叫exclude或者excludes?
from edp-build.
关于includeShallows和excludeShallows,有时候还是有意义的。我为echarts写optimizer的时候就遇到了适用的场景。在项目的build中,excludeShallows的意义比includeShallows大些。不过我觉得可以不加,以后遇到在加好了
from edp-build.
叫exclude或者excludes?
include
和exclude
最早就已经被用掉了,现在exclude
的实现貌似就是excludeShallows
的意思,只把本模块排除掉(实际上也就把它依赖的模块也间接的排除了)。如果继续采用exclude
的话,貌似就需要让他扮演真正exclude
的意思(把它以及它依赖的模块都排除在外?)
from edp-build.
@otakustay 主席给点意见?
from edp-build.
Related Issues (20)
- 增加处理器缓存支持能力,提升构建速度
- file-info 模块单独提取出来便于扩展依赖使用 HOT 1
- replace-tag-attribute 在特定情况下不符合预期 HOT 1
- 模块编译在有`define`声明的情况下修改脚本导致错误 HOT 3
- HTML minifier 提示找不到模块 HOT 2
- module processor在combine配置文件的时候报错 HOT 1
- html-minifer 内置 etpl customAttrSurround 配置 HOT 1
- babelProcessor 需要改用babel-core以支持babel6
- 增加JsCompressor的利用多核CPU的能力
- 一个自动化打包构建的思路 HOT 1
- v1.2.0+ 版本build后有保留字的内容不会特殊处理
- less-compiler的bug or feature? HOT 2
- pathMapper issue
- 编译less丢失css私有前缀
- PathMapper中对amdConfig的对象的eval带来的副作用
- JsCompressor 能不能支持下 es6?
- md5-renamer 遇到带空格的路径,没有去空格导致windows下输出错误 HOT 1
- ModuleCompiler处理paths的时候,需要支持 https? 的配置
- babel-processor和tpl-merge配合使用的问题 HOT 4
- 项目引用less > 2.0.0,LessCompiler的relativeUrls没有效果
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 edp-build.