|
4 | 4 | * license that can be found in the LICENSE file.
|
5 | 5 | */
|
6 | 6 | module.exports = function(grunt) {
|
7 |
| - ShadowDOMNative = [ |
8 |
| - '../CustomElements/src/sidetable.js', |
9 |
| - 'src/patches-shadowdom-native.js' |
10 |
| - ]; |
11 | 7 |
|
12 |
| - ShadowDOMPolyfill = [ |
13 |
| - 'sidetable.js', |
14 |
| - 'wrappers.js', |
15 |
| - 'wrappers/events.js', |
16 |
| - 'wrappers/NodeList.js', |
17 |
| - 'wrappers/Node.js', |
18 |
| - 'querySelector.js', |
19 |
| - 'wrappers/node-interfaces.js', |
20 |
| - 'wrappers/CharacterData.js', |
21 |
| - 'wrappers/Element.js', |
22 |
| - 'wrappers/HTMLElement.js', |
23 |
| - 'wrappers/HTMLContentElement.js', |
24 |
| - 'wrappers/HTMLShadowElement.js', |
25 |
| - 'wrappers/HTMLTemplateElement.js', |
26 |
| - 'wrappers/HTMLUnknownElement.js', |
27 |
| - 'wrappers/generic.js', |
28 |
| - 'wrappers/ShadowRoot.js', |
29 |
| - 'ShadowRenderer.js', |
30 |
| - 'wrappers/elements-with-form-property.js', |
31 |
| - 'wrappers/Document.js', |
32 |
| - 'wrappers/Window.js', |
33 |
| - 'wrappers/MutationObserver.js', |
34 |
| - 'wrappers/Range.js', |
35 |
| - 'wrappers/override-constructors.js' |
36 |
| - ]; |
37 |
| - ShadowDOMPolyfill = ShadowDOMPolyfill.map(function(p) { |
38 |
| - return '../ShadowDOM/src/' + p; |
39 |
| - }); |
40 |
| - ShadowDOMPolyfill.push( |
41 |
| - 'src/patches-shadowdom-polyfill.js', |
42 |
| - 'src/ShadowCSS.js' |
43 |
| - ); |
44 |
| - |
45 |
| - Lib = [ |
46 |
| - 'src/lang.js', |
47 |
| - 'src/dom.js', |
48 |
| - 'src/template.js', |
49 |
| - 'src/inspector.js' |
50 |
| - ]; |
51 |
| - |
52 |
| - MDV = [ |
53 |
| - '../observe-js/src/observe.js', |
54 |
| - '../NodeBind/src/NodeBind.js', |
55 |
| - '../TemplateBinding/src/TemplateBinding.js', |
56 |
| - '../polymer-expressions/third_party/esprima/esprima.js', |
57 |
| - '../polymer-expressions/src/polymer-expressions.js', |
58 |
| - 'src/patches-mdv.js' |
59 |
| - ]; |
60 |
| - |
61 |
| - PointerEvents = [ |
62 |
| - 'boot.js', |
63 |
| - 'touch-action.js', |
64 |
| - 'PointerEvent.js', |
65 |
| - 'pointermap.js', |
66 |
| - 'sidetable.js', |
67 |
| - 'dispatcher.js', |
68 |
| - 'installer.js', |
69 |
| - 'mouse.js', |
70 |
| - 'touch.js', |
71 |
| - 'ms.js', |
72 |
| - 'platform-events.js', |
73 |
| - 'capture.js', |
74 |
| - ]; |
75 |
| - PointerEvents = PointerEvents.map(function(p) { |
76 |
| - return '../PointerEvents/src/' + p; |
77 |
| - }); |
78 |
| - |
79 |
| - PointerGestures = [ |
80 |
| - 'PointerGestureEvent.js', |
81 |
| - 'initialize.js', |
82 |
| - 'sidetable.js', |
83 |
| - 'pointermap.js', |
84 |
| - 'dispatcher.js', |
85 |
| - 'hold.js', |
86 |
| - 'track.js', |
87 |
| - 'flick.js', |
88 |
| - 'tap.js' |
89 |
| - ]; |
90 |
| - PointerGestures = PointerGestures.map(function(p) { |
91 |
| - return '../PointerGestures/src/' + p; |
92 |
| - }); |
93 |
| - |
94 |
| - HTMLImports = [ |
95 |
| - '../HTMLImports/src/HTMLImports.js', |
96 |
| - '../HTMLImports/src/Parser.js', |
97 |
| - '../HTMLImports/src/boot.js' |
98 |
| - ]; |
99 |
| - |
100 |
| - CustomElements = [ |
101 |
| - '../CustomElements/MutationObservers/MutationObserver.js', |
102 |
| - '../CustomElements/src/MutationObserver.js', |
103 |
| - '../CustomElements/src/CustomElements.js', |
104 |
| - '../CustomElements/src/Observer.js', |
105 |
| - '../CustomElements/src/HTMLElementElement.js', |
106 |
| - '../CustomElements/src/Parser.js', |
107 |
| - '../CustomElements/src/boot.js', |
108 |
| - 'src/patches-custom-elements.js', |
109 |
| - 'src/microtask.js' |
110 |
| - ]; |
111 |
| - |
112 |
| - Main = [].concat( |
113 |
| - Lib, |
114 |
| - MDV, |
115 |
| - HTMLImports, |
116 |
| - CustomElements, |
117 |
| - PointerEvents, |
118 |
| - PointerGestures |
119 |
| - ); |
120 |
| - |
121 |
| - ConditionalShadowdom = [].concat( |
122 |
| - 'build/if-poly.js', |
123 |
| - ShadowDOMPolyfill, |
124 |
| - 'build/else.js', |
125 |
| - ShadowDOMNative, |
126 |
| - 'build/end-if.js' |
127 |
| - ); |
128 |
| - |
129 |
| - ConditionalPlatform = [].concat( |
130 |
| - 'build/shadowdom.conditional.js', |
131 |
| - Main |
132 |
| - ); |
133 |
| - |
134 |
| - NativeShadowPlatform = [].concat( |
135 |
| - ShadowDOMNative, |
136 |
| - Main |
137 |
| - ); |
| 8 | + // recursive module builder |
| 9 | + var path = require('path'); |
| 10 | + function readManifest(filename, modules) { |
| 11 | + modules = modules || []; |
| 12 | + var lines = grunt.file.readJSON(filename); |
| 13 | + var dir = path.dirname(filename); |
| 14 | + lines.forEach(function(line) { |
| 15 | + var fullpath = path.join(dir, line); |
| 16 | + if (line.slice(-5) == '.json') { |
| 17 | + // recurse |
| 18 | + readManifest(fullpath, modules); |
| 19 | + } else { |
| 20 | + modules.push(fullpath); |
| 21 | + } |
| 22 | + }); |
| 23 | + return modules; |
| 24 | + } |
138 | 25 |
|
139 |
| - SandboxedChromeAppsPlatform = [].concat( |
140 |
| - 'build/shadowdom.conditional.js', |
141 |
| - Lib, |
142 |
| - MDV, |
143 |
| - 'src/patches-html-imports-csp.js', |
144 |
| - HTMLImports, |
145 |
| - CustomElements, |
146 |
| - PointerEvents, |
147 |
| - PointerGestures |
148 |
| - ); |
149 |
| - |
150 | 26 | // karma setup
|
151 | 27 | var browsers;
|
152 | 28 | (function() {
|
@@ -183,61 +59,31 @@ module.exports = function(grunt) {
|
183 | 59 | browsers: browsers
|
184 | 60 | }
|
185 | 61 | },
|
186 |
| - concat: { |
187 |
| - ShadowDom: { |
188 |
| - src: ConditionalShadowdom, |
189 |
| - dest: 'build/shadowdom.conditional.js', |
190 |
| - nonull: true |
| 62 | + concat_sourcemap: { |
| 63 | + Platform: { |
| 64 | + options: { |
| 65 | + sourcesContent: true |
| 66 | + }, |
| 67 | + files: { |
| 68 | + 'platform.concat.js': readManifest('build.json') |
| 69 | + } |
191 | 70 | }
|
192 | 71 | },
|
193 | 72 | uglify: {
|
194 | 73 | options: {
|
195 | 74 | banner: grunt.file.read('LICENSE'),
|
196 |
| - nonull: true |
| 75 | + nonull: true, |
| 76 | + compress: { |
| 77 | + unsafe: false |
| 78 | + } |
197 | 79 | },
|
198 | 80 | Platform: {
|
199 | 81 | options: {
|
200 | 82 | sourceMap: 'platform.min.js.map',
|
201 |
| - //mangle: false, |
202 |
| - //beautify: true, |
203 |
| - //report: 'gzip', |
204 |
| - compress: { |
205 |
| - // TODO(sjmiles): should be false by default (?) |
206 |
| - // https://github.com/mishoo/UglifyJS2/issues/165 |
207 |
| - unsafe: false |
208 |
| - } |
209 |
| - }, |
210 |
| - files: { |
211 |
| - 'platform.min.js': ConditionalPlatform |
212 |
| - } |
213 |
| - }, |
214 |
| - PlatformNative: { |
215 |
| - options: { |
216 |
| - sourceMap: 'platform.native.min.js.map', |
217 |
| - //mangle: false, |
218 |
| - //beautify: true, |
219 |
| - //report: 'gzip', |
220 |
| - compress: { |
221 |
| - // TODO(sjmiles): should be false by default (?) |
222 |
| - // https://github.com/mishoo/UglifyJS2/issues/165 |
223 |
| - unsafe: false |
224 |
| - } |
| 83 | + sourceMapIn: 'platform.concat.js.map' |
225 | 84 | },
|
226 | 85 | files: {
|
227 |
| - 'platform.native.min.js': NativeShadowPlatform |
228 |
| - } |
229 |
| - }, |
230 |
| - PlatformSandboxedChromeApps: { |
231 |
| - options: { |
232 |
| - sourceMap: 'platform.sandbox.min.js.map', |
233 |
| - compress: { |
234 |
| - // TODO(sjmiles): should be false by default (?) |
235 |
| - // https://github.com/mishoo/UglifyJS2/issues/165 |
236 |
| - unsafe: false |
237 |
| - } |
238 |
| - }, |
239 |
| - files: { |
240 |
| - 'platform.sandbox.min.js': SandboxedChromeAppsPlatform |
| 86 | + 'platform.min.js': 'platform.concat.js' |
241 | 87 | }
|
242 | 88 | }
|
243 | 89 | },
|
@@ -266,10 +112,17 @@ module.exports = function(grunt) {
|
266 | 112 | grunt.loadNpmTasks('grunt-contrib-uglify');
|
267 | 113 | grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
268 | 114 | grunt.loadNpmTasks('grunt-karma');
|
| 115 | + grunt.loadNpmTasks('grunt-concat-sourcemap'); |
269 | 116 |
|
270 | 117 | // tasks
|
271 |
| - grunt.registerTask('default', ['concat', 'uglify']); |
272 |
| - grunt.registerTask('minify', ['concat', 'uglify']); |
| 118 | + grunt.registerTask('sourcemap_copy', 'Copy sourcesContent between sourcemaps', function(source, dest) { |
| 119 | + var sourceMap = grunt.file.readJSON(source); |
| 120 | + var destMap = grunt.file.readJSON(dest); |
| 121 | + destMap.sourcesContent = sourceMap.sourcesContent; |
| 122 | + grunt.file.write(dest, JSON.stringify(destMap)); |
| 123 | + }); |
| 124 | + |
| 125 | + grunt.registerTask('default', ['concat_sourcemap', 'uglify', 'sourcemap_copy:platform.concat.js.map:platform.min.js.map']); |
273 | 126 | grunt.registerTask('docs', ['yuidoc']);
|
274 | 127 | grunt.registerTask('test', ['karma:platform']);
|
275 | 128 | grunt.registerTask('test-buildbot', ['karma:buildbot']);
|
|
0 commit comments