mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
add build support
This commit is contained in:
67
gulpfile.js
Normal file
67
gulpfile.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2013 The Polymer Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style
|
||||
* license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
var
|
||||
gulp = require('gulp'),
|
||||
concat = require('gulp-concat'),
|
||||
uglify = require('gulp-uglify'),
|
||||
path = require('path'),
|
||||
uconcat = require('unique-concat'),
|
||||
fs = require('fs')
|
||||
;
|
||||
|
||||
function defineBuildTask(name, output, folderName) {
|
||||
gulp.task(name, function() {
|
||||
output = output || name;
|
||||
folderName = folderName || name;
|
||||
var manifest = './src/' + folderName + '/build.json';
|
||||
var list = readManifest(manifest);
|
||||
gulp.src(list)
|
||||
.pipe(concat(output + '.js'))
|
||||
.pipe(uglify({
|
||||
mangle: false,
|
||||
compress: false,
|
||||
output: {
|
||||
beautify: true
|
||||
}
|
||||
}))
|
||||
.pipe(gulp.dest('dist/'))
|
||||
;
|
||||
|
||||
gulp.src(list)
|
||||
.pipe(concat(output + '.min.js'))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest('dist/'))
|
||||
;
|
||||
});
|
||||
}
|
||||
|
||||
function readJSON(filename) {
|
||||
var blob = fs.readFileSync(filename, 'utf8');
|
||||
return JSON.parse(blob);
|
||||
}
|
||||
|
||||
function readManifest(filename, modules) {
|
||||
modules = modules || [];
|
||||
var lines = readJSON(filename);
|
||||
var dir = path.dirname(filename);
|
||||
lines.forEach(function(line) {
|
||||
var fullpath = path.join(dir, line);
|
||||
if (line.slice(-5) == '.json') {
|
||||
// recurse
|
||||
modules = modules.concat(readManifest(fullpath, modules));
|
||||
} else {
|
||||
// TODO(dfreedm): make this smarter
|
||||
modules = uconcat(modules, [fullpath]);
|
||||
}
|
||||
});
|
||||
return modules;
|
||||
}
|
||||
|
||||
defineBuildTask('default', 'webcomponents', 'WebComponents');
|
||||
defineBuildTask('CustomElements');
|
||||
defineBuildTask('HTMLImports');
|
||||
defineBuildTask('ShadowDOM');
|
||||
29
package.json
Normal file
29
package.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "webcomponents.js-dev",
|
||||
"version": "0.0.0",
|
||||
"description": "webcomponents.js-dev",
|
||||
"main": "gulpfile.js",
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"dependencies": {
|
||||
"gulp": "^3.8.8",
|
||||
"gulp-concat": "^2.4.1",
|
||||
"gulp-uglify": "^1.0.1",
|
||||
"unique-concat": "^0.2.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Polymer/webcomponents.js-dev.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/Polymer/webcomponents.js-dev/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Polymer/webcomponents.js-dev"
|
||||
}
|
||||
10
src/CustomElements/build.json
Normal file
10
src/CustomElements/build.json
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
"../WeakMap/WeakMap.js",
|
||||
"../MutationObserver/MutationObserver.js",
|
||||
"base.js",
|
||||
"traverse.js",
|
||||
"observe.js",
|
||||
"upgrade.js",
|
||||
"register.js",
|
||||
"boot.js"
|
||||
]
|
||||
13
src/HTMLImports/build.json
Normal file
13
src/HTMLImports/build.json
Normal file
@@ -0,0 +1,13 @@
|
||||
[
|
||||
"../WeakMap/WeakMap.js",
|
||||
"../MutationObserver/MutationObserver.js",
|
||||
"base.js",
|
||||
"path.js",
|
||||
"xhr.js",
|
||||
"Loader.js",
|
||||
"Observer.js",
|
||||
"parser.js",
|
||||
"importer.js",
|
||||
"dynamic.js",
|
||||
"boot.js"
|
||||
]
|
||||
51
src/ShadowDOM/build.json
Normal file
51
src/ShadowDOM/build.json
Normal file
@@ -0,0 +1,51 @@
|
||||
[
|
||||
"../WeakMap/WeakMap.js",
|
||||
"wrappers.js",
|
||||
"ArraySlice.js",
|
||||
"microtask.js",
|
||||
"MutationObserver.js",
|
||||
"TreeScope.js",
|
||||
"wrappers/events.js",
|
||||
"wrappers/TouchEvent.js",
|
||||
"wrappers/NodeList.js",
|
||||
"wrappers/HTMLCollection.js",
|
||||
"wrappers/Node.js",
|
||||
"querySelector.js",
|
||||
"wrappers/node-interfaces.js",
|
||||
"wrappers/CharacterData.js",
|
||||
"wrappers/Text.js",
|
||||
"wrappers/DOMTokenList.js",
|
||||
"wrappers/Element.js",
|
||||
"wrappers/HTMLElement.js",
|
||||
"wrappers/HTMLCanvasElement.js",
|
||||
"wrappers/HTMLContentElement.js",
|
||||
"wrappers/HTMLFormElement.js",
|
||||
"wrappers/HTMLImageElement.js",
|
||||
"wrappers/HTMLShadowElement.js",
|
||||
"wrappers/HTMLTemplateElement.js",
|
||||
"wrappers/HTMLMediaElement.js",
|
||||
"wrappers/HTMLAudioElement.js",
|
||||
"wrappers/HTMLOptionElement.js",
|
||||
"wrappers/HTMLSelectElement.js",
|
||||
"wrappers/HTMLTableElement.js",
|
||||
"wrappers/HTMLTableSectionElement.js",
|
||||
"wrappers/HTMLTableRowElement.js",
|
||||
"wrappers/HTMLUnknownElement.js",
|
||||
"wrappers/SVGElement.js",
|
||||
"wrappers/SVGUseElement.js",
|
||||
"wrappers/SVGElementInstance.js",
|
||||
"wrappers/CanvasRenderingContext2D.js",
|
||||
"wrappers/WebGLRenderingContext.js",
|
||||
"wrappers/Range.js",
|
||||
"wrappers/generic.js",
|
||||
"wrappers/ShadowRoot.js",
|
||||
"ShadowRenderer.js",
|
||||
"wrappers/elements-with-form-property.js",
|
||||
"wrappers/Selection.js",
|
||||
"wrappers/Document.js",
|
||||
"wrappers/Window.js",
|
||||
"wrappers/DataTransfer.js",
|
||||
"wrappers/FormData.js",
|
||||
"wrappers/XMLHttpRequest.js",
|
||||
"wrappers/override-constructors.js"
|
||||
]
|
||||
13
src/WebComponents/build.json
Normal file
13
src/WebComponents/build.json
Normal file
@@ -0,0 +1,13 @@
|
||||
[
|
||||
"build/boot.js",
|
||||
"build/if-poly.js",
|
||||
"../ShadowDOM/build.json",
|
||||
"../ShadowCss/ShadowCss.js",
|
||||
"build/end-if.js",
|
||||
"shadowdom.js",
|
||||
"../HTMLImports/build.json",
|
||||
"../CustomElements/build.json",
|
||||
"lang.js",
|
||||
"dom.js",
|
||||
"unresolved.js"
|
||||
]
|
||||
72
src/WebComponents/build/boot.js
Normal file
72
src/WebComponents/build/boot.js
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
* Code distributed by Google as part of the polymer project is also
|
||||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
*/
|
||||
|
||||
window.WebComponents = window.WebComponents || {};
|
||||
|
||||
// process flags
|
||||
(function(scope){
|
||||
|
||||
// import
|
||||
var flags = scope.flags || {};
|
||||
|
||||
var file = 'webcomponents.js';
|
||||
var script = document.querySelector('script[src*="' + file + '"]');
|
||||
|
||||
// Flags. Convert url arguments to flags
|
||||
var flags = {};
|
||||
if (!flags.noOpts) {
|
||||
// from url
|
||||
location.search.slice(1).split('&').forEach(function(o) {
|
||||
o = o.split('=');
|
||||
o[0] && (flags[o[0]] = o[1] || true);
|
||||
});
|
||||
// from script
|
||||
for (var i=0, a; (a=script.attributes[i]); i++) {
|
||||
if (a.name !== 'src') {
|
||||
flags[a.name] = a.value || true;
|
||||
}
|
||||
}
|
||||
// log flags
|
||||
if (flags.log) {
|
||||
var parts = flags.log.split(',');
|
||||
flags.log = {};
|
||||
parts.forEach(function(f) {
|
||||
flags.log[f] = true;
|
||||
});
|
||||
} else {
|
||||
flags.log = {};
|
||||
}
|
||||
}
|
||||
|
||||
// Determine default settings.
|
||||
// If any of these flags match 'native', then force native ShadowDOM; any
|
||||
// other truthy value, or failure to detect native
|
||||
// ShadowDOM, results in polyfill
|
||||
flags.shadow = (flags.shadow || flags.shadowdom || flags.polyfill);
|
||||
if (flags.shadow === 'native') {
|
||||
flags.shadow = false;
|
||||
} else {
|
||||
flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot;
|
||||
}
|
||||
|
||||
if (flags.shadow && document.querySelectorAll('script').length > 1) {
|
||||
console.log('Warning: platform.js is not the first script on the page. ' +
|
||||
'See http://www.polymer-project.org/docs/start/platform.html#setup ' +
|
||||
'for details.');
|
||||
}
|
||||
|
||||
// forward flags
|
||||
if (flags.register) {
|
||||
window.CustomElements = window.CustomElements || {flags: {}};
|
||||
window.CustomElements.flags.register = flags.register;
|
||||
}
|
||||
|
||||
// export
|
||||
scope.flags = flags;
|
||||
})(WebComponents);
|
||||
6
src/WebComponents/build/build.json
Normal file
6
src/WebComponents/build/build.json
Normal file
@@ -0,0 +1,6 @@
|
||||
[
|
||||
"shadowdom.js",
|
||||
"lang.js",
|
||||
"dom.js",
|
||||
"unresolved.js"
|
||||
]
|
||||
1
src/WebComponents/build/else.js
Normal file
1
src/WebComponents/build/else.js
Normal file
@@ -0,0 +1 @@
|
||||
} else {
|
||||
1
src/WebComponents/build/end-if.js
Normal file
1
src/WebComponents/build/end-if.js
Normal file
@@ -0,0 +1 @@
|
||||
}
|
||||
2
src/WebComponents/build/if-poly.js
Normal file
2
src/WebComponents/build/if-poly.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// select ShadowDOM impl
|
||||
if (WebComponents.flags.shadow) {
|
||||
Reference in New Issue
Block a user