1 | define(["./buildControlBase"], function(bc) { |
---|
2 | var defaultBc= { |
---|
3 | // v1.6- default values |
---|
4 | internStrings:true, |
---|
5 | internSkipList:[], |
---|
6 | optimize:"", |
---|
7 | layerOptimize:"shrinksafe", |
---|
8 | cssOptimize:"", |
---|
9 | cssImportIgnore:"", |
---|
10 | stripConsole:"normal", |
---|
11 | scopeMap:[], |
---|
12 | insertAbsMids:1, |
---|
13 | applyDojoPragmas:1, |
---|
14 | |
---|
15 | |
---|
16 | // this is a dojo pragma |
---|
17 | replaceLoaderConfig:1, |
---|
18 | |
---|
19 | defaultConfig:{ |
---|
20 | hasCache:{ |
---|
21 | // these are the values given above, not-built client code may test for these so they need to be available |
---|
22 | 'dojo-built':1, |
---|
23 | 'dojo-loader':1, |
---|
24 | 'dom':1, |
---|
25 | 'host-browser':1, |
---|
26 | |
---|
27 | // default |
---|
28 | "config-selectorEngine":"acme" |
---|
29 | }, |
---|
30 | async:0 |
---|
31 | }, |
---|
32 | |
---|
33 | files:[], |
---|
34 | dirs:[], |
---|
35 | trees:[], |
---|
36 | replacements:{}, |
---|
37 | |
---|
38 | staticHasFeatures:{ |
---|
39 | // consider turning these hard on for standard 1.x build |
---|
40 | //'config-publishRequireResult':1, |
---|
41 | //'config-tlmSiblingOfDojo':1, |
---|
42 | |
---|
43 | 'extend-dojo':1, |
---|
44 | 'dojo-amd-factory-scan':0, |
---|
45 | 'dojo-built':1, |
---|
46 | 'dojo-combo-api':0, |
---|
47 | 'dojo-log-api':1, |
---|
48 | 'dojo-test-sniff':0,// must be turned on for several tests to work |
---|
49 | 'dojo-config-addOnLoad':1, |
---|
50 | 'dojo-config-api':1, |
---|
51 | 'dojo-config-require':1, |
---|
52 | 'dojo-dom-ready-api':1, |
---|
53 | 'dojo-guarantee-console':1, |
---|
54 | 'dojo-has-api':1, |
---|
55 | 'dojo-inject-api':1, |
---|
56 | 'dojo-loader':1, |
---|
57 | 'dojo-modulePaths':1, |
---|
58 | 'dojo-moduleUrl':1, |
---|
59 | 'dojo-publish-privates':0, |
---|
60 | 'dojo-requirejs-api':0, |
---|
61 | 'dojo-sniff':1, |
---|
62 | 'dojo-sync-loader':1, |
---|
63 | 'dojo-timeout-api':1, |
---|
64 | 'dojo-trace-api':0, |
---|
65 | 'dojo-undef-api':0, |
---|
66 | 'dojo-v1x-i18n-Api':1, |
---|
67 | 'dojo-xhr-factory':1, |
---|
68 | 'dom':1, |
---|
69 | 'host-browser':1, |
---|
70 | 'host-node':0, |
---|
71 | 'host-rhino':0 |
---|
72 | }, |
---|
73 | |
---|
74 | buildFlags:{ |
---|
75 | stripConsole:"error", |
---|
76 | optimizeHas:1 |
---|
77 | }, |
---|
78 | |
---|
79 | discoveryProcs:["build/discover"], |
---|
80 | |
---|
81 | plugins:{ |
---|
82 | "dojo/text":"build/plugins/text", |
---|
83 | "dojo/i18n":"build/plugins/i18n", |
---|
84 | "dojo/has":"build/plugins/has", |
---|
85 | "dojo/domReady":"build/plugins/domReady", |
---|
86 | "dojo/loadInit":"build/plugins/loadInit", |
---|
87 | "dojo/require":"build/plugins/require", |
---|
88 | "dojo/selector/_loader":"build/plugins/querySelector" |
---|
89 | }, |
---|
90 | |
---|
91 | gates:[ |
---|
92 | // [synchronized?, gate-name, gate-message] |
---|
93 | [0, "read", "reading resources"], |
---|
94 | [0, "text", "processing raw resource content"], |
---|
95 | [0, "tokenize", "tokenizing resource"], |
---|
96 | [0, "tokens", "processing resource tokens"], |
---|
97 | [0, "parse", "parsing resource"], |
---|
98 | [1, "ast", "processing resource AST"], |
---|
99 | [1, "optimize", "executing global optimizations"], |
---|
100 | [1, "write", "writing resources"], |
---|
101 | [1, "cleanup", "cleaning up"], |
---|
102 | [1, "report", "reporting"] |
---|
103 | ], |
---|
104 | |
---|
105 | transformConfig: {}, |
---|
106 | |
---|
107 | transforms:{ |
---|
108 | trace: ["build/transforms/trace", "read"], |
---|
109 | read: ["build/transforms/read", "read"], |
---|
110 | dojoPragmas: ["build/transforms/dojoPragmas", "read"], |
---|
111 | insertSymbols: ["build/transforms/insertSymbols", "read"], |
---|
112 | depsScan: ["build/transforms/depsScan", "ast"], |
---|
113 | hasFixup: ["build/transforms/hasFixup", "ast"], |
---|
114 | write: ["build/transforms/write", "write"], |
---|
115 | writeAmd: ["build/transforms/writeAmd", "write"], |
---|
116 | writeOptimized: ["build/transforms/writeOptimized", "write"], |
---|
117 | copy: ["build/transforms/copy", "write"], |
---|
118 | writeDojo: ["build/transforms/writeDojo", "write"], |
---|
119 | optimizeCss: ["build/transforms/optimizeCss", "optimize"], |
---|
120 | writeCss: ["build/transforms/writeCss", "write"], |
---|
121 | hasFindAll: ["build/transforms/hasFindAll", "read"], |
---|
122 | hasReport: ["build/transforms/hasReport", "cleanup"], |
---|
123 | depsDump: ["build/transforms/depsDump", "cleanup"], |
---|
124 | dojoReport: ["build/transforms/dojoReport", "report"], |
---|
125 | report: ["build/transforms/report", "report"] |
---|
126 | }, |
---|
127 | |
---|
128 | transformJobs:[[ |
---|
129 | // immediately filter the stuff to not be transformed in any way |
---|
130 | function(resource, bc) { |
---|
131 | return (bc.mini && resource.tag.miniExclude) || (!bc.copyTests && resource.tag.test) || (resource.tag.ignore); |
---|
132 | }, |
---|
133 | [] |
---|
134 | ],[ |
---|
135 | // if the tag says just copy, then just copy |
---|
136 | function(resource) { |
---|
137 | return resource.tag.copyOnly; |
---|
138 | }, |
---|
139 | ["copy"] |
---|
140 | ],[ |
---|
141 | // the synthetic report module |
---|
142 | function(resource) { |
---|
143 | return resource.tag.report; |
---|
144 | }, |
---|
145 | ["dojoReport", "insertSymbols", "report"] |
---|
146 | ],[ |
---|
147 | // dojo.js, the loader |
---|
148 | function(resource, bc) { |
---|
149 | if (resource.mid=="dojo/dojo") { |
---|
150 | bc.loader= resource; |
---|
151 | resource.boots= []; |
---|
152 | // the loader is treated as an AMD module when creating the "dojo" layer, but and AMD dependency scan won't |
---|
153 | // work because it's not an AMD module; therefore, initialize deps here and make sure not to do the depsScan transform |
---|
154 | resource.deps= []; |
---|
155 | bc.amdResources[resource.mid]= resource; |
---|
156 | return true; |
---|
157 | } |
---|
158 | return false; |
---|
159 | }, |
---|
160 | ["read", "dojoPragmas", "hasFindAll", "hasFixup", "writeDojo", "writeOptimized"] |
---|
161 | ],[ |
---|
162 | // package has module |
---|
163 | function(resource) { |
---|
164 | if (/^\w+\/has$/.test(resource.mid)) { |
---|
165 | bc.amdResources[resource.mid]= resource; |
---|
166 | return true; |
---|
167 | } |
---|
168 | return false; |
---|
169 | }, |
---|
170 | ["read", "dojoPragmas", "hasFindAll", "hasFixup", "depsScan", "writeAmd", "writeOptimized", "hasReport", "depsDump"] |
---|
171 | ],[ |
---|
172 | // nls resources |
---|
173 | function(resource) { |
---|
174 | if (/\/nls\//.test(resource.mid) || /\/nls\/.+\.js$/.test(resource.src)) { |
---|
175 | resource.tag.nls= 1; |
---|
176 | bc.amdResources[resource.mid]= resource; |
---|
177 | return true; |
---|
178 | } |
---|
179 | return false; |
---|
180 | }, |
---|
181 | ["read", "dojoPragmas", "hasFindAll", "hasFixup", "depsScan", "writeAmd"] |
---|
182 | ],[ |
---|
183 | // synthetic AMD modules (used to create layers on-the-fly |
---|
184 | function(resource) { |
---|
185 | if (resource.tag.synthetic && resource.tag.amd){ |
---|
186 | bc.amdResources[resource.mid]= resource; |
---|
187 | return true; |
---|
188 | } |
---|
189 | return false; |
---|
190 | }, |
---|
191 | // just like regular AMD modules, but without a bunch of unneeded transforms |
---|
192 | ["depsScan", "writeAmd", "writeOptimized"] |
---|
193 | ],[ |
---|
194 | // synthetic dojo/loadInit! resources |
---|
195 | // FIXME: can't this be added to the previous transform? |
---|
196 | function(resource) { |
---|
197 | if (resource.tag.loadInitResource){ |
---|
198 | bc.amdResources[resource.mid]= resource; |
---|
199 | return true; |
---|
200 | } |
---|
201 | return false; |
---|
202 | }, |
---|
203 | // just like regular AMD modules (the next transform job), but without a bunch of unneeded transforms |
---|
204 | ["writeAmd", "writeOptimized"] |
---|
205 | ],[ |
---|
206 | // AMD module: |
---|
207 | // already marked as an amd resource |
---|
208 | // ...or... |
---|
209 | // not dojo/dojo.js (filtered above), not package has module (filtered above), not nls bundle (filtered above), not test or building test, not build control script or profile script but still a Javascript resource... |
---|
210 | function(resource) { |
---|
211 | if (resource.tag.amd || (/\.js$/.test(resource.src) && (!resource.tag.test || bc.copyTests=="build") && !/\.(bcs|profile)\.js$/.test(resource.src))) { |
---|
212 | bc.amdResources[resource.mid]= resource; |
---|
213 | return true; |
---|
214 | } |
---|
215 | return false; |
---|
216 | }, |
---|
217 | ["read", "dojoPragmas", "hasFindAll", "insertSymbols", "hasFixup", "depsScan", "writeAmd", "writeOptimized"] |
---|
218 | ],[ |
---|
219 | // a test resource; if !bc.copyTests then the resource was filtered in the first item; otherwise, if the resource is a potential module and building tests, then it was filtered above; |
---|
220 | function(resource, bc) { |
---|
221 | return resource.tag.test; |
---|
222 | }, |
---|
223 | ["read", "dojoPragmas", "write"] |
---|
224 | ],[ |
---|
225 | // html file; may need access contents for template interning and/or dojoPragmas; therefore, can't use copy transform |
---|
226 | function(resource, bc) { |
---|
227 | return /\.(html|htm)$/.test(resource.src); |
---|
228 | }, |
---|
229 | ["read", "dojoPragmas", "write"] |
---|
230 | ],[ |
---|
231 | // css that are designated to compact |
---|
232 | function(resource, bc) { |
---|
233 | return /\.css$/.test(resource.src); |
---|
234 | }, |
---|
235 | ["read", "optimizeCss", "write"] |
---|
236 | ],[ |
---|
237 | // just copy everything else except tests which were copied above iff desired... |
---|
238 | function(resource) { |
---|
239 | return !resource.tag.test; |
---|
240 | }, |
---|
241 | ["copy"] |
---|
242 | ] |
---|
243 | ] |
---|
244 | }; |
---|
245 | for (var p in defaultBc) { |
---|
246 | bc[p]= defaultBc[p]; |
---|
247 | } |
---|
248 | return bc; |
---|
249 | }); |
---|