Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 3652c51

Browse files
author
Scott J. Miles
committed
Merge pull request #37 from azakus/recursive-build
Recursive platform build
2 parents c005e53 + ebf91ea commit 3652c51

File tree

4 files changed

+66
-188
lines changed

4 files changed

+66
-188
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
platform.min*
88
platform.native*
99
platform.sandbox*
10+
platform.concat*
1011
build.bat

build.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
"build/if-poly.js",
3+
"../ShadowDOM/build.json",
4+
"build/else.js",
5+
"../CustomElements/src/sidetable.js",
6+
"src/patches-shadowdom-native.js",
7+
"build/end-if.js",
8+
"src/lang.js",
9+
"src/dom.js",
10+
"src/template.js",
11+
"src/inspector.js",
12+
"../observe-js/src/observe.js",
13+
"../NodeBind/src/NodeBind.js",
14+
"../TemplateBinding/src/TemplateBinding.js",
15+
"../polymer-expressions/build.json",
16+
"src/patches-mdv.js",
17+
"../HTMLImports/build.json",
18+
"../CustomElements/build.json",
19+
"src/patches-custom-elements.js",
20+
"src/microtask.js",
21+
"../PointerEvents/build.json",
22+
"../PointerGestures/build.json"
23+
]

gruntfile.js

+40-187
Original file line numberDiff line numberDiff line change
@@ -4,149 +4,25 @@
44
* license that can be found in the LICENSE file.
55
*/
66
module.exports = function(grunt) {
7-
ShadowDOMNative = [
8-
'../CustomElements/src/sidetable.js',
9-
'src/patches-shadowdom-native.js'
10-
];
117

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+
}
13825

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-
15026
// karma setup
15127
var browsers;
15228
(function() {
@@ -183,61 +59,31 @@ module.exports = function(grunt) {
18359
browsers: browsers
18460
}
18561
},
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+
}
19170
}
19271
},
19372
uglify: {
19473
options: {
19574
banner: grunt.file.read('LICENSE'),
196-
nonull: true
75+
nonull: true,
76+
compress: {
77+
unsafe: false
78+
}
19779
},
19880
Platform: {
19981
options: {
20082
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'
22584
},
22685
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'
24187
}
24288
}
24389
},
@@ -266,10 +112,17 @@ module.exports = function(grunt) {
266112
grunt.loadNpmTasks('grunt-contrib-uglify');
267113
grunt.loadNpmTasks('grunt-contrib-yuidoc');
268114
grunt.loadNpmTasks('grunt-karma');
115+
grunt.loadNpmTasks('grunt-concat-sourcemap');
269116

270117
// 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']);
273126
grunt.registerTask('docs', ['yuidoc']);
274127
grunt.registerTask('test', ['karma:platform']);
275128
grunt.registerTask('test-buildbot', ['karma:buildbot']);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"karma-mocha": "*",
1313
"karma-ie-launcher": "*",
1414
"karma-script-launcher": "*",
15-
"karma-crbot-reporter": "*"
15+
"karma-crbot-reporter": "*",
16+
"grunt-concat-sourcemap": "~0.3.0"
1617
}
1718
}

0 commit comments

Comments
 (0)